X-Git-Url: https://git.kaliko.me/?a=blobdiff_plain;f=sima%2Flaunch.py;h=0ff7da3aa38e220ad0fb54777559cb0681f434e5;hb=fb2e50c81fb9588a1f7b8ac2b9e1d598c6f03d44;hp=9689afdbb166032daac9201d3344815f271cea72;hpb=6194c3ae982cf2a89044b7dc077dfb9915e5b106;p=mpd-sima.git diff --git a/sima/launch.py b/sima/launch.py index 9689afd..0ff7da3 100644 --- a/sima/launch.py +++ b/sima/launch.py @@ -88,6 +88,13 @@ def start(sopt, restart=False): set_logger(verbosity, logfile) logger.debug('Command line say: %s', sopt.options) + # Create database if not present + db_file = config.get('sima', 'db_file') + if not isfile(db_file): + logger.debug('Creating database in "%s"', db_file) + open(db_file, 'a').close() # TODO: to remove with new simadb in v0.18 + SimaDB(db_path=db_file).create_db() + if sopt.options.get('command'): cmd = sopt.options.get('command') if cmd == "generate-config": @@ -100,15 +107,13 @@ def start(sopt, restart=False): config_test(config) sys.exit(0) if cmd == "create-db": - db_file = config.get('sima', 'db_file') if not isfile(db_file): logger.info('Creating database in "%s"', db_file) - open(db_file, 'a').close() + open(db_file, 'a').close() # TODO: to remove with new simadb in v0.18 SimaDB(db_path=db_file).create_db() - if sopt.options.get('create_db', None): - logger.info('Done, bye...') else: logger.info('Database already there, not overwriting %s', db_file) + logger.info('Done, bye...') sys.exit(0) if cmd == "purge-history": db_file = config.get('sima', 'db_file')