[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [metrics-web/master] Implement an own config file parser for ExoneraTor.



commit 1936362e79e747decd0b28a9145042a369e6e5db
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Thu Dec 13 14:10:10 2012 +0100

    Implement an own config file parser for ExoneraTor.
---
 .../ernie/cron/ExoneraTorDatabaseImporter.java     |   27 +++++++++++++++++--
 1 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/src/org/torproject/ernie/cron/ExoneraTorDatabaseImporter.java b/src/org/torproject/ernie/cron/ExoneraTorDatabaseImporter.java
index 2e6916a..5d007c2 100644
--- a/src/org/torproject/ernie/cron/ExoneraTorDatabaseImporter.java
+++ b/src/org/torproject/ernie/cron/ExoneraTorDatabaseImporter.java
@@ -57,9 +57,30 @@ public class ExoneraTorDatabaseImporter {
 
   /* Learn JDBC string and directory to parse descriptors from. */
   private static void readConfiguration() {
-    Configuration config = new Configuration();
-    jdbcString = config.getExoneraTorDatabaseJdbc();
-    importDirString = config.getExoneraTorImportDirectory();
+    File configFile = new File("config");
+    if (!configFile.exists()) {
+      System.err.println("Could not find config file.  Exiting.");
+      System.exit(1);
+    }
+    String line = null;
+    try {
+      BufferedReader br = new BufferedReader(new FileReader(configFile));
+      while ((line = br.readLine()) != null) {
+        if (line.startsWith("#") || line.length() < 1) {
+          continue;
+        } else if (line.startsWith("ExoneraTorDatabaseJdbc")) {
+          jdbcString = line.split(" ")[1];
+        } else if (line.startsWith("ExoneraTorImportDirectory")) {
+          importDirString = line.split(" ")[1];
+        } else {
+          /* Ignore unrecognized configuration keys. */
+        }
+      }
+      br.close();
+    } catch (IOException e) {
+      System.err.println("Could not parse config file.  Exiting.");
+      System.exit(1);
+    }
   }
 
   /* Database connection. */



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits