X-Git-Url: https://git.kaliko.me/?a=blobdiff_plain;f=sima%2Flaunch.py;h=27e9d6bfdab60e75a2832a2b8e3683b7d341adf7;hb=568365b3b2ec343ffa3e1b2159c38abbe88011eb;hp=9cd36232abecaf1779d29e6b9236a4fa54be5293;hpb=abb05a55c1b6c27a11bbd90efbc594ad6331bbc6;p=mpd-sima.git diff --git a/sima/launch.py b/sima/launch.py index 9cd3623..27e9d6b 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,12 @@ 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() 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') @@ -118,24 +122,6 @@ def start(sopt, restart=False): SimaDB(db_path=db_file).purge_history(duration=0) sys.exit(0) - - # TODO: To remove eventually in next major realese v0.18 - # Create Database - db_file = config.get('sima', 'db_file') - if (sopt.options.get('create_db', None) - or not isfile(db_file)): - logger.info('Creating database in "%s"', 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) - - # TODO: To remove eventually in next major realese v0.18 - if sopt.options.get('generate_config'): - config.write(sys.stdout, space_around_delimiters=True) - sys.exit(0) - logger.info('Starting (%s)...', info.__version__) sima = core.Sima(config)