Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
pmavrin committed Feb 6, 2018
1 parent e1f01ad commit c3753a7
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 14 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ buildNumber.properties
*.ear

# VLC Plugin
libvlc/x64/plugins/plugins.dat
libvlc/x64/plugins/plugins.dat

# Config
config/*.properties
2 changes: 1 addition & 1 deletion cameras-test.bat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
mvn package exec:java -Dexec.mainClass="ru.ifmo.acm.testing.CamerasTest"
mvn package exec:java -Dexec.mainClass="org.icpclive.testing.CamerasTest"
2 changes: 1 addition & 1 deletion main-screen.bat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
mvn package exec:java -Dsun.java2d.opengl=True -D_sun.java2d.trace=count,out:opengl.log -Dexec.mainClass="ru.ifmo.acm.backend.MainToFile"
mvn package exec:java -Dsun.java2d.opengl=True -D_sun.java2d.trace=count,out:opengl.log -Dexec.mainClass="org.icpclive.backend.MainToFile"
2 changes: 1 addition & 1 deletion split-screen.bat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
mvn package exec:java -Dexec.mainClass="ru.ifmo.acm.backend.SplitScreen"
mvn package exec:java -Dexec.mainClass="org.icpclive.backend.SplitScreen"
10 changes: 10 additions & 0 deletions src/main/java/org/icpclive/Config.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
package org.icpclive;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

/**
* Created by icpclive on 2/6/2018.
*/
public class Config {

public static Properties loadProperties(String name) throws IOException {
Properties properties = new Properties();
properties.load(new FileInputStream("config/" + name + ".properties"));
return properties;
}
}
8 changes: 6 additions & 2 deletions src/main/java/org/icpclive/events/PCMS/PCMSEventsLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.icpclive.Config;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
Expand Down Expand Up @@ -29,6 +30,10 @@

import java.util.HashMap;

import static org.icpclive.events.ContestInfo.Status.BEFORE;
import static org.icpclive.events.ContestInfo.Status.PAUSED;
import static org.icpclive.events.ContestInfo.Status.RUNNING;

public class PCMSEventsLoader extends EventsLoader {
private static final Logger log = LogManager.getLogger(PCMSEventsLoader.class);

Expand All @@ -49,8 +54,7 @@ public void loadProblemsInfo(String problemsFile) throws IOException {
TeamInfo[] initialStandings;

public PCMSEventsLoader() throws IOException {
properties = new Properties();
properties.load(this.getClass().getClassLoader().getResourceAsStream("events.properties"));
properties = Config.loadProperties("events");

ContestInfo.CONTEST_LENGTH = Integer.parseInt(properties.getProperty("contest.length", "" + 5 * 60 * 60 * 1000));
ContestInfo.FREEZE_TIME = Integer.parseInt(properties.getProperty("freeze.time", "" + 4 * 60 * 60 * 1000));
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/icpclive/events/WF/WFEventsLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.google.gson.JsonObject;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.icpclive.Config;
import org.icpclive.backend.Preparation;
import org.icpclive.events.ContestInfo;
import org.icpclive.events.EventsLoader;
Expand Down Expand Up @@ -41,8 +42,7 @@ public class WFEventsLoader extends EventsLoader {

public WFEventsLoader() {
try {
Properties properties = new Properties();
properties.load(getClass().getClassLoader().getResourceAsStream("events.properties"));
Properties properties = Config.loadProperties("events");

login = properties.getProperty("login");
password = properties.getProperty("password");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.icpclive.Config;
import org.icpclive.ContextListener;
import org.icpclive.events.ContestInfo;
import org.icpclive.events.TeamInfo;
Expand All @@ -19,13 +20,9 @@ public class MainScreenProperties {
public MainScreenProperties() {
Properties properties = new Properties();
try {
// properties.load(getClass().getResourceAsStream("/mainscreen.properties"));
// FileInputStream fileInputStream = new FileInputStream(
// new File("src/resources/mainscreen.properties"));
properties.load(new InputStreamReader(getClass().getResourceAsStream("/mainscreen.properties"),
Charset.forName("UTF-8")));
properties = Config.loadProperties("mainscreen");
} catch (IOException e) {
log.error("error", e);
log.error("Cannot read mainscreen properties file", e);
}

latency = Long.parseLong(properties.getProperty("latency.time"));
Expand Down

0 comments on commit c3753a7

Please sign in to comment.