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

[tor-commits] [ooni-probe/master] Make the defaults paths relative to the ooni home directory.



commit 575ecd79e8428e413d4952e19f618be6b8c6ff13
Author: Arturo Filastò <art@xxxxxxxxx>
Date:   Mon Jan 13 12:53:20 2014 +0100

    Make the defaults paths relative to the ooni home directory.
---
 data/ooniprobe.conf.sample |    2 +-
 ooni/deck.py               |    7 ++-----
 ooni/oonibclient.py        |    1 -
 ooni/settings.py           |    6 ++++++
 ooni/utils/log.py          |    2 +-
 5 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/data/ooniprobe.conf.sample b/data/ooniprobe.conf.sample
index 4ce1e19..3a1b6f4 100644
--- a/data/ooniprobe.conf.sample
+++ b/data/ooniprobe.conf.sample
@@ -4,7 +4,7 @@
 
 basic:
     # Where OONIProbe should be writing it's log file
-    logfile: /var/log/ooniprobe.log
+    logfile: ~/.ooni/ooniprobe.log
 privacy:
     # Should we include the IP address of the probe in the report?
     includeip: false
diff --git a/ooni/deck.py b/ooni/deck.py
index 23bb9a1..faddfa4 100644
--- a/ooni/deck.py
+++ b/ooni/deck.py
@@ -16,9 +16,7 @@ from hashlib import sha256
 class InputFile(object):
     def __init__(self, input_hash):
         self.id = input_hash
-        cached_input_dir = os.path.join(config.advanced.data_dir,
-                'inputs')
-        cache_path = os.path.join(cached_input_dir, input_hash)
+        cache_path = os.path.join(config.inputs_directory, input_hash)
         self.cached_file = cache_path
         self.cached_descriptor = cache_path + '.desc'
     
@@ -96,8 +94,7 @@ class Deck(InputFile):
 
     @property
     def cached_file(self):
-        cached_deck_dir = os.path.join(config.advanced.data_dir, 'decks')
-        return os.path.join(cached_deck_dir, self.deckHash)
+        return os.path.join(config.decks_directory, self.deckHash)
    
     @property
     def cached_descriptor(self):
diff --git a/ooni/oonibclient.py b/ooni/oonibclient.py
index 5735155..1fa2e5b 100644
--- a/ooni/oonibclient.py
+++ b/ooni/oonibclient.py
@@ -75,7 +75,6 @@ class OONIBClient(object):
                 # we have reached the retry count.
                 if attempts < self.retries:
                     log.err("Lookup failed. Retrying.")
-                    log.exception(err)
                     attempts += 1
                     perform_request(attempts)
                 else:
diff --git a/ooni/settings.py b/ooni/settings.py
index 7d8a7bd..de24a76 100644
--- a/ooni/settings.py
+++ b/ooni/settings.py
@@ -1,4 +1,5 @@
 import os
+import sys
 import yaml
 from shutil import copyfile
 from os.path import abspath, expanduser
@@ -31,12 +32,16 @@ class OConfig(object):
             self.data_directory = abspath(expanduser(self.global_options['datadir']))
         elif self.advanced.get('data_dir'):
             self.data_directory = self.advanced['data_dir']
+        elif hasattr(sys, 'real_prefix'):
+            self.data_directory = os.path.abspath(os.path.join(sys.prefix, 'share', 'ooni'))
         else:
             self.data_directory = '/usr/share/ooni/'
+
         self.nettest_directory = abspath(os.path.join(__file__, '..', 'nettests'))
 
         self.ooni_home = os.path.join(expanduser('~'), '.ooni')
         self.inputs_directory = os.path.join(self.ooni_home, 'inputs')
+        self.decks_directory = os.path.join(self.ooni_home, 'decks')
         self.reports_directory = os.path.join(self.ooni_home, 'reports')
 
         if self.global_options.get('configfile'):
@@ -51,6 +56,7 @@ class OConfig(object):
             print "Creating it in '%s'." % self.ooni_home
             os.mkdir(self.ooni_home)
             os.mkdir(self.inputs_directory)
+            os.mkdir(self.decks_directory)
         if not os.path.isdir(self.reports_directory):
             os.mkdir(self.reports_directory)
 
diff --git a/ooni/utils/log.py b/ooni/utils/log.py
index 036a4b4..e0ad5d9 100644
--- a/ooni/utils/log.py
+++ b/ooni/utils/log.py
@@ -28,7 +28,7 @@ def start(logfile=None, application_name="ooniprobe"):
     daily_logfile = None
 
     if not logfile:
-        logfile = config.basic.logfile
+        logfile = os.path.expanduser(config.basic.logfile)
 
     log_folder = os.path.dirname(logfile)
     log_filename = os.path.basename(logfile)



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