commit 7e41f7e3b739b4777035a29bacc4c07279cc6e0c Author: Arturo Filastò art@fuffa.org Date: Thu Nov 13 12:34:50 2014 +0100
Write the settings.ini file when installing ooniprobe. --- MANIFEST.in | 1 + ooni/settings.py | 9 +++++---- setup.py | 9 +++++++++ 3 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/MANIFEST.in b/MANIFEST.in index da56999..7fd57f3 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -9,3 +9,4 @@ include data/oonideckgen.1 include data/ooniprobe.1 include data/oonireport.1 include data/ooniresources.1 +include ooni/settings.ini diff --git a/ooni/settings.py b/ooni/settings.py index fbf85c2..8496c16 100644 --- a/ooni/settings.py +++ b/ooni/settings.py @@ -43,17 +43,18 @@ class OConfig(object): else: embedded_settings = os.path.join(get_ooni_root(), 'settings.ini') settings = SafeConfigParser() - settings.readfp(open(embedded_settings)) + with open(embedded_settings) as fp: + settings.readfp(fp) return os.path.abspath(settings.get("directories", "data_dir")) - #return abspath(os.path.join(__file__, '..', '..', 'data'))
def set_paths(self, ooni_home=None): if ooni_home: self._custom_home = ooni_home
- self.nettest_directory = abspath(os.path.join(__file__, '..', 'nettests')) + self.nettest_directory = os.path.join(get_ooni_root(), 'nettests')
- self.ooni_home = os.path.join(expanduser('~'+self.current_user), '.ooni') + self.ooni_home = os.path.join(expanduser('~'+self.current_user), + '.ooni') if self._custom_home: self.ooni_home = self._custom_home self.inputs_directory = os.path.join(self.ooni_home, 'inputs') diff --git a/setup.py b/setup.py index 444bcd8..d06540b 100644 --- a/setup.py +++ b/setup.py @@ -5,6 +5,7 @@ from ooni import __version__, __author__ import os import sys import tempfile +from ConfigParser import SafeConfigParser
from os.path import join as pj from setuptools import setup @@ -42,6 +43,13 @@ class install(_st_install): files ] ) + settings = SafeConfigParser() + with open("ooni/settings.ini") as fp: + settings.readfp(fp) + settings.set("directories", "data_dir", + os.path.join(share_path, "ooni")) + with open("ooni/settings.ini", "w+") as fp: + settings.write(fp)
def run(self): share_path = os.path.abspath(pj(self.prefix, 'share')) @@ -98,6 +106,7 @@ setup( package_dir={'ooni': 'ooni'}, data_files=data_files, packages=packages, + include_package_data = True, scripts=["bin/oonideckgen", "bin/ooniprobe", "bin/oonireport", "bin/ooniresources"], dependency_links=dependency_links,
tor-commits@lists.torproject.org