logger = logging.getLogger('sima')
logger.setLevel(cli_loglevel)
# loads configuration
- conf_manager = ConfMan(logger, sopt.options)
- config = conf_manager.config
+ config = ConfMan(logger, sopt.options).config
logger.setLevel(getattr(logging,
config.get('log', 'verbosity').upper())) # pylint: disable=E1103
logger.debug('Command line say: {0}'.format(sopt.options))
-
# Create Database
+ db_file = config.get('sima', 'db_file')
if (sopt.options.get('create_db', None)
- or not isfile(conf_manager.db_file)):
- logger.info('Creating database in "{}"'.format(conf_manager.db_file))
- open(conf_manager.db_file, 'a').close()
- SimaDB(db_path=conf_manager.db_file).create_db()
+ or not isfile(db_file)):
+ logger.info('Creating database in "{}"'.format(db_file))
+ open(db_file, 'a').close()
+ SimaDB(db_path=db_file).create_db()
if sopt.options.get('create_db', None):
logger.info('Done, bye...')
sys.exit(0)
logger.info('Starting...')
- sima = core.Sima(config, conf_manager.db_file)
+ sima = core.Sima(config)
# Loading internal plugins
for plugin in PLUGINS:
"""Main class, plugin and player management
"""
- def __init__(self, conf, dbfile):
+ def __init__(self, conf):
self.enabled = True
self.config = conf
- self.sdb = SimaDB(db_path=dbfile)
+ self.sdb = SimaDB(db_path=conf.get('sima', 'db_file'))
self.log = getLogger('sima')
self.plugins = list()
- self.player = self._get_player() # Player client
+ self.player = self.__get_player() # Player client
try:
self.player.connect()
except (PlayerError, PlayerUnHandledError) as err:
self.shutdown()
self.short_history = deque(maxlen=60)
- def _get_player(self):
+ def __get_player(self):
"""Instanciate the player"""
host = self.config.get('MPD', 'host')
port = self.config.get('MPD', 'port')
'daemon': "false",
'pidfile': "",},
'log': {
- 'verbosity': "info"},
+ 'verbosity': "info",
+ 'logfile': "",},
'lastfm': {
'dynamic': "10",
'similarity': "20",
self.init_config()
self.control_conf()
self.supersedes_config_with_cmd_line_options()
+ self.config['sima']['db_file'] = self.db_file
def get_pw(self):
try:
self.db_file = join(data_dir, 'sima.db')
config = configparser.SafeConfigParser()
-
# If no conf file present, uses defaults
if not isfile(self.conf_file):
self.config = config