Skip to content

Commit

Permalink
Update API key location and retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
spencerng committed Feb 3, 2019
1 parent 3bbe719 commit be7a712
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ Temporary Items
/.gradle/
/build/
/out/
/src/main/resources/secret.txt
/src/main/resources/apikey/secret.txt
21 changes: 21 additions & 0 deletions .idea/artifacts/org_usfirst_frc_team25_scouting_client_main.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile 'com.google.code.gson:gson:2.7'
compile files('libs/TBA-APIv3-Java-Library.jar')
compile group: 'commons-io', name: 'commons-io', version: '2.0.1'
}

jfx {
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: org.usfirst.frc.team25.scouting.client.ui.Main

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import javafx.stage.Stage;
import org.usfirst.frc.team25.scouting.data.BlueAlliance;

import java.io.IOException;

public class Main extends Application {


Expand All @@ -17,7 +19,7 @@ public static void main(String[] args) {

@Override
public void start(Stage primaryStage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("/fxml/main.fxml"));
Parent root = FXMLLoader.load(getClass().getClassLoader().getResource("fxml/main.fxml"));
primaryStage.setTitle("Raider Robotix Scouting Client");
primaryStage.setScene(new Scene(root, 820, 370));
primaryStage.setResizable(false);
Expand All @@ -28,7 +30,11 @@ public void start(Stage primaryStage) throws Exception {
System.exit(0);
});

BlueAlliance.initializeApi(getClass());
try {
BlueAlliance.initializeApi(getClass());
} catch (IOException e) {

}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.thebluealliance.api.v3.models.Event;
import com.thebluealliance.api.v3.models.Match;
import com.thebluealliance.api.v3.models.Team;
import org.apache.commons.io.IOUtils;

import java.io.File;
import java.io.FileNotFoundException;
Expand All @@ -23,8 +24,11 @@ public class BlueAlliance {

private static TBA TBA;

public static void initializeApi(Class c) {
String apiKey = FileManager.getFileString(new File(c.getResource("/secret.txt").getFile()));
public static void initializeApi(Class c) throws IOException {


String apiKey = IOUtils.toString(c.getClassLoader().getResourceAsStream("apikey/secret.txt"), "utf5");

TBA = new TBA(apiKey);
}

Expand Down

0 comments on commit be7a712

Please sign in to comment.