changeset 42:4dee9586cc44

added checks for matching ids in start/end save.
author Robert Casties <casties@mpiwg-berlin.mpg.de>
date Fri, 11 Nov 2016 17:20:46 +0100
parents 5b3cd0b66b30
children bb5390f752fc
files importFromOpenMind/importer/check_ismi_log.py
diffstat 1 files changed, 30 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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)