Change logging a little so info about DB being rebuilt is always printed to stdout

This commit is contained in:
DarkPhoenix
2019-10-30 15:16:13 +03:00
parent 39dc7e4a46
commit cde0108cba
2 changed files with 12 additions and 2 deletions

View File

@@ -51,6 +51,7 @@ def db_needs_update():
except: except:
return None return None
if not os.path.isfile(DB_PATH): if not os.path.isfile(DB_PATH):
print('Gamedata DB not found')
return True return True
db_data_version = None db_data_version = None
db_schema_version = None db_schema_version = None
@@ -68,12 +69,21 @@ def db_needs_update():
except KeyboardInterrupt: except KeyboardInterrupt:
raise raise
except: except:
print('Error when fetching gamedata DB metadata')
return True return True
return data_version != db_data_version or GAMEDATA_SCHEMA_VERSION != db_schema_version if data_version != db_data_version:
print('Gamedata DB data version mismatch: needed {}, DB has {}'.format(data_version, db_data_version))
return True
if GAMEDATA_SCHEMA_VERSION != db_schema_version:
print('Gamedata DB schema version mismatch: needed {}, DB has {}'.format(GAMEDATA_SCHEMA_VERSION, db_schema_version))
return True
return False
def update_db(): def update_db():
print('Building gamedata DB...')
if os.path.isfile(DB_PATH): if os.path.isfile(DB_PATH):
os.remove(DB_PATH) os.remove(DB_PATH)

View File

@@ -76,6 +76,7 @@ parser.add_option("-p", "--profile", action="store", dest="profile_path", help="
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
if __name__ == "__main__": if __name__ == "__main__":
try: try:
@@ -118,7 +119,6 @@ if __name__ == "__main__":
pyfalog.info("Running in a thawed state.") pyfalog.info("Running in a thawed state.")
if db_needs_update() is True: if db_needs_update() is True:
pyfalog.info("Gamedata needs an update")
update_db() update_db()
# Lets get to the good stuff, shall we? # Lets get to the good stuff, shall we?