X-Git-Url: https://git.kaliko.me/?a=blobdiff_plain;f=sima%2Flaunch.py;h=890f96bfd1641db6c1b6a3b1e357ffe7ea4c8571;hb=6e0cb104973681f2344de9c5ae4f04c62686401b;hp=4cdcae03ef49d8e5ff6120e6d388b36274661221;hpb=bd2085416b7e7e52dec62f872ad87ea4cadb05f2;p=mpd-sima.git diff --git a/sima/launch.py b/sima/launch.py index 4cdcae0..890f96b 100644 --- a/sima/launch.py +++ b/sima/launch.py @@ -26,6 +26,7 @@ import sys from importlib import __import__ as sima_import from os.path import isfile +from os import rename ## # third parties components @@ -92,7 +93,13 @@ def start(sopt, restart=False): 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() + # Migration from v0.17.0 + dbinfo = SimaDB(db_path=db_file).get_info() + if not dbinfo: # v0.17.0 → v0.18+ migration + logger.warning('Backing up database!') + rename(db_file, db_file + '-old-version-backup') + logger.info('Creating an new database in "%s"', db_file) SimaDB(db_path=db_file).create_db() if sopt.options.get('command'): @@ -109,12 +116,10 @@ def start(sopt, restart=False): if cmd == "create-db": if not isfile(db_file): logger.info('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('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')