From 5f836f6211398f76b0fa924cce53d14010671cb3 Mon Sep 17 00:00:00 2001 From: Achim Friedland Date: Fri, 2 Nov 2018 20:10:36 +0100 Subject: [PATCH] Try/catch to skip invalid JSON in dirtyDB --- bin/dirty-db-cleaner.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bin/dirty-db-cleaner.py b/bin/dirty-db-cleaner.py index d3e49a0d2..29fd73bea 100755 --- a/bin/dirty-db-cleaner.py +++ b/bin/dirty-db-cleaner.py @@ -31,8 +31,11 @@ with open(dirtydb_input, 'r') as fd: print 'Reading %s' % dirtydb_input for line in fd: lines += 1 - data = json.loads(line) - dirtydb[data['key']] = line + try: + data = json.loads(line) + dirtydb[data['key']] = line + except: + print("Skipping invalid JSON!") if lines % 10000 == 0: sys.stderr.write('.') print