From 161060b2c24bd37d7cd11f74297790dbe93504be Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sat, 25 Jul 2015 19:57:23 +0300 Subject: [PATCH] Report counts of new and exiting images --- reload_db.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/reload_db.py b/reload_db.py index 9dbbd02..ee51b39 100755 --- a/reload_db.py +++ b/reload_db.py @@ -15,10 +15,6 @@ from sqlobject.sqlbuilder import Insert from xsetbg_conf import xsetbg_conf from xsetbg_db import recreate_db, SQLiteMassInsert -fs_encoding = xsetbg_conf.get("images", "fs_encoding") -dump_file = open(sys.argv[1], 'rU') -xsetbg_db = recreate_db() - def convert_str(s): if s == "None": @@ -27,6 +23,11 @@ def convert_str(s): return int(float(s)) +fs_encoding = xsetbg_conf.get("images", "fs_encoding") +dump_file = open(sys.argv[1], 'rU') +xsetbg_db = recreate_db() +count_new = count_old = 0 + with SQLiteMassInsert() as txn: for line in dump_file: id, timestamp, filename = line.strip().split(None, 2) @@ -42,8 +43,13 @@ with SQLiteMassInsert() as txn: values['id'] = id query = txn.sqlrepr(Insert(xsetbg_db.sqlmeta.table, values=values)) txn.query(query) + count_new += 1 else: assert id is None or row.id == id assert row.last_shown == timestamp + count_old += 1 dump_file.close() + +print "New images:", count_new +print "Existing images:", count_old -- 2.39.5