]> kaliko git repositories - mpd-sima.git/blobdiff - sima/utils/config.py
Improved log handling
[mpd-sima.git] / sima / utils / config.py
index cdaefd198022a23bf71d54300383dd80623a1937..b3a8d46a8c0c9a4d94ed001295226e631eecf61e 100644 (file)
@@ -25,6 +25,7 @@ Parse configuration file and set defaults for missing options.
 
 # IMPORTS
 import configparser
+import logging
 import sys
 
 from configparser import Error
@@ -105,8 +106,8 @@ class ConfMan(object):  # CONFIG MANAGER CLASS
         * command line options (overrides previous)
     """
 
-    def __init__(self, logger, options=None):
-        self.log = logger
+    def __init__(self, options=None):
+        self.log = logging.getLogger('sima')
         # options settings priority:
         # defauts < env. var. < conf. file < command line
         self.conf_file = options.get('conf_file')
@@ -119,20 +120,8 @@ class ConfMan(object):  # CONFIG MANAGER CLASS
         ## INIT CALLS
         self.init_config()
         self.supersedes_config_with_cmd_line_options()
-
-    def get_pw(self):
-        try:
-            self.config.getboolean('MPD', 'password')
-            self.log.debug('No password set, proceeding without ' +
-                           'authentication...')
-            return None
-        except ValueError:
-            # ValueError if password not a boolean, hence an actual password.
-            pwd = self.config.get('MPD', 'password')
-            if not pwd:
-                self.log.debug('Password set as an empty string.')
-                return None
-            return pwd
+        # generate dbfile
+        self.config['sima']['db_file'] = join(self.config['sima']['var_dir'], 'sima.db')
 
     def control_mod(self):
         """
@@ -208,7 +197,6 @@ class ConfMan(object):  # CONFIG MANAGER CLASS
 
         ## Sima sqlite DB
         self.config['sima']['var_dir'] = join(data_dir)
-        self.config['sima']['db_file'] = join(data_dir, 'sima.db')
 
         # If no conf file present, uses defaults
         if not isfile(self.conf_file):