# HG changeset patch # User Robert Casties # Date 1478881246 -3600 # Node ID 4dee9586cc44cf40fce732e05c4f60f88f81df60 # Parent 5b3cd0b66b30a7ce166d218769be0a56b587ae1d added checks for matching ids in start/end save. diff -r 5b3cd0b66b30 -r 4dee9586cc44 importFromOpenMind/importer/check_ismi_log.py --- a/importFromOpenMind/importer/check_ismi_log.py Wed Nov 02 16:56:27 2016 +0100 +++ b/importFromOpenMind/importer/check_ismi_log.py Fri Nov 11 17:20:46 2016 +0100 @@ -77,7 +77,7 @@ if tm: tstamp = tm.group(1) - sm = re.search('START Saving (\w+) \[ID=(\d*)', line) + sm = re.search('START Saving (\w+) \[ID=(\w*)', line) if sm: return {'time': tstamp, 'oc': sm.group(1), 'id': sm.group(2)} @@ -85,6 +85,10 @@ if sm: return {'time': tstamp, 'id': sm.group(1)} + sm = re.search('END Saving (\w+) \[ID=(\d*)', line) + if sm: + return {'time': tstamp, 'oc': sm.group(1), 'id': sm.group(2)} + return None @@ -269,6 +273,7 @@ with open(inFilename) as f: linecnt = 0 saving = 0 + openSaves = {} savingPrev = 0 deleting = 0 saveCtx = None @@ -285,9 +290,14 @@ log('DEBUG', line) # parse time and id saveCtx = parseStart(line) + saveId = saveCtx['id'] + if saveId in openSaves: + log('ERROR', "Duplicate save for same id! %s"%saveCtx) + + openSaves[saveId] = saveCtx - if saving > 1: - log("ERROR", "Concurrent save (%s) in #%s of %s"%(saving, linecnt, line)) + if len(openSaves) > 1: + log("ERROR", "Multiple open save (%s) in #%s of %s"%(saving, linecnt, line)) # TODO: what now? elif 'Deleting entity' in line: @@ -345,16 +355,29 @@ saves.append(parseSave(line)) elif '*************** END Saving' in line: + log('DEBUG', line) saving -= 1 + saveCtx = parseStart(line) + saveId = saveCtx['id'] + if saveId in openSaves: + log('DEBUG', "End save matches start save: %s"%saveCtx) + del openSaves[saveId] + + elif 'null' in openSaves: + log('DEBUG', "Assume end save (of %s) matches start save null: %s"%(len(openSaves), saveCtx)) + del openSaves['null'] + + else: + log("ERROR", "End save without start save! %s"%saveCtx) + # make sure delete is off deleting = 0 - log('DEBUG', line) - if saving > 0: - log("ERROR", "Concurrent end save (%s) in #%s of %s"%(saving, linecnt, line)) + if len(openSaves) > 0: + log('WARNING', "Still open saves (%s) during end save in #%s of %s"%(saving, linecnt, line)) elif saving < 0: - log("ERROR", "Too many END saves!") + log('ERROR', "Too many END saves!") break log("INFO", "saving %s"%saveCtx)