commit 08d61704cb74f876929b5b42ebcdbf1471d1aadd
Author: olafmk <mail(a)olaf-koehler.com>
Date: Sat Apr 12 13:31:18 2014 +0200
Resolved differences between paths (log,config,home) pointing to different users' home folders
(`logfile` and `config_file` were pointing to 'user/.ooni/...' and `ooni_home` to 'root/.ooni/...')
---
ooni/settings.py | 9 +++++----
ooni/utils/log.py | 2 +-
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/ooni/settings.py b/ooni/settings.py
index adeba85..c429b88 100644
--- a/ooni/settings.py
+++ b/ooni/settings.py
@@ -49,9 +49,12 @@ class OConfig(object):
if self.global_options.get('configfile'):
config_file = self.global_options['configfile']
+ self.config_file = expanduser(config_file)
else:
- config_file = os.path.join('~', '.ooni', 'ooniprobe.conf')
- self.config_file = expanduser(config_file)
+ self.config_file = os.path.join(self.ooni_home, 'ooniprobe.conf')
+
+ if 'logfile' in self.basic:
+ self.basic.logfile = expanduser(self.basic.logfile.replace('~','~'+self.current_user))
def initialize_ooni_home(self):
if not os.path.isdir(self.ooni_home):
@@ -72,8 +75,6 @@ class OConfig(object):
if hasattr(sys, 'real_prefix'):
usr_share_path = os.path.abspath(os.path.join(sys.prefix, 'share'))
- if not os.path.isdir(os.path.dirname(target_config_file)):
- os.mkdir(os.path.dirname(target_config_file))
with open(sample_config_file) as f:
with open(target_config_file, 'w+') as w:
for line in f:
diff --git a/ooni/utils/log.py b/ooni/utils/log.py
index 379b5c7..7364583 100644
--- a/ooni/utils/log.py
+++ b/ooni/utils/log.py
@@ -29,7 +29,7 @@ class OONILogger(object):
daily_logfile = None
if not logfile:
- logfile = os.path.expanduser(config.basic.logfile)
+ logfile = config.basic.logfile
log_folder = os.path.dirname(logfile)
log_filename = os.path.basename(logfile)