changeset 1859:ac2ac7fe8a9b

core (memory, config): moved parseMainConf to tools/config so it can be used by frontends too
author Goffi <goffi@goffi.org>
date Mon, 29 Feb 2016 16:13:47 +0100
parents 06e13ae616cf
children afc7f6328394
files src/memory/memory.py src/tools/config.py
diffstat 2 files changed, 10 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/memory/memory.py	Sun Feb 28 13:42:31 2016 +0100
+++ b/src/memory/memory.py	Mon Feb 29 16:13:47 2016 +0100
@@ -236,7 +236,7 @@
         self.auth_sessions = PasswordSessions()  # remember the authenticated profiles
         self.disco = Discovery(host)
         fixLocalDir(False)  # XXX: tmp update code, will be removed in the future
-        self.config = self.parseMainConf()
+        self.config = tools_config.parseMainConf()
         database_file = os.path.expanduser(os.path.join(self.getConfig('', 'local_dir'), C.SAVEFILE_DATABASE))
         self.storage = SqliteStorage(database_file, host.version)
         PersistentDict.storage = self.storage
@@ -251,15 +251,6 @@
 
     ## Configuration ##
 
-    def parseMainConf(self):
-        """look for main .ini configuration file, and parse it"""
-        config = SafeConfigParser(defaults=C.DEFAULT_CONFIG)
-        try:
-            config.read(C.CONFIG_FILES)
-        except:
-            log.error(_("Can't read main config !"))
-        return config
-
     def getConfig(self, section, name, default=None):
         """Get the main configuration option
 
--- a/src/tools/config.py	Sun Feb 28 13:42:31 2016 +0100
+++ b/src/tools/config.py	Mon Feb 29 16:13:47 2016 +0100
@@ -43,7 +43,7 @@
     @param value (str): the new value
     @param silent (boolean): toggle logging output (must be True when called from sat.sh)
     """
-    config = SafeConfigParser()
+    config = SafeConfigParser(defaults=C.DEFAULT_CONFIG)
     target_file = None
     for file_ in C.CONFIG_FILES[::-1]:
         # we will eventually update the existing file with the highest priority, if it's a user personal file...
@@ -68,6 +68,14 @@
         log.warning(_(u"Config auto-update: %(option)s set to %(value)s in the file %(config_file)s") %
                     {'option': option, 'value': value, 'config_file': target_file})
 
+def parseMainConf():
+    """look for main .ini configuration file, and parse it"""
+    config = SafeConfigParser(defaults=C.DEFAULT_CONFIG)
+    try:
+        config.read(C.CONFIG_FILES)
+    except:
+        log.error(_("Can't read main config !"))
+    return config
 
 def getConfig(config, section, name, default=None):
     """Get a configuration option