diff py/rlgall.py @ 68:67bcca6e3cb1

Prevent crashes if no ttyrec files can be associated with a game. If the postprocessing step finds no ttyrec files created between a game's end and the previous game's end, it will no longer index an empty list and crash. The condition of finding no ttyrec files is still a bug that requires investigation.
author John "Elwin" Edwards
date Sat, 16 Jan 2016 02:12:50 +0000
parents 6542a7cf826b
children 2cca66b3e262
line wrap: on
line diff
--- a/py/rlgall.py	Sat Nov 21 20:01:41 2015 -0500
+++ b/py/rlgall.py	Sat Jan 16 02:12:50 2016 +0000
@@ -226,8 +226,13 @@
           lowlim = itsEntries[i-1]["endt"]
         hilim = itsEntries[i]["endt"]
         recs = [ k[1] for k in vfilekeys if lowlim <= k[0] < hilim ]
-        itsEntries[i]["startt"] = recnameToTS(recs[0])
-        itsEntries[i]["ttyrecs"] = recs
+        if len(recs) == 0:
+          # There inexplicably are no files.  TODO log an error.
+          itsEntries[i]["startt"] = lowlim
+          itsEntries[i]["ttyrecs"] = []
+        else:
+          itsEntries[i]["startt"] = recnameToTS(recs[0])
+          itsEntries[i]["ttyrecs"] = recs
     cur.close()
     conn.close()
   def putIntoDB(self, dictlist, conn):