From fba21b71287a6772f69a556c668f0292889713c0 Mon Sep 17 00:00:00 2001 From: krateng Date: Fri, 8 Apr 2022 21:17:17 +0200 Subject: [PATCH] Added proper logging to upgrade script --- maloja/upgrade.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/maloja/upgrade.py b/maloja/upgrade.py index de85c00..5709953 100644 --- a/maloja/upgrade.py +++ b/maloja/upgrade.py @@ -35,7 +35,7 @@ def upgrade_db(callback_add_scrobbles): if os.path.exists(oldfolder): scrobblefiles = [f for f in os.listdir(oldfolder) if f.endswith(".tsv")] if len(scrobblefiles) > 0: - print(col['yellow']("Upgrading v2 Database to v3 Database. This could take a while...")) + log("Upgrading v2 Database to v3 Database. This could take a while...",color='yellow') idx = 0 for sf in scrobblefiles: idx += 1 @@ -48,10 +48,11 @@ def upgrade_db(callback_add_scrobbles): else: origin = 'unknown' + # TODO still tsv module here! from doreah import tsv scrobbles = tsv.parse(os.path.join(oldfolder,sf),"int","string","string","string","string",comments=False) scrobblelist = [] - print(f"\tImporting from {sf} ({idx}/{len(scrobblefiles)}) - {len(scrobbles)} Scrobbles") + log(f"\tImporting from {sf} ({idx}/{len(scrobblefiles)}) - {len(scrobbles)} Scrobbles") for scrobble in scrobbles: timestamp, artists, title, album, duration = scrobble if album in ('-',''): album = None @@ -73,4 +74,4 @@ def upgrade_db(callback_add_scrobbles): }) callback_add_scrobbles(scrobblelist) os.rename(os.path.join(oldfolder,sf),os.path.join(newfolder,sf)) - print(col['yellow']("Done!")) + log("Done!",color='yellow')