comparison 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
comparison
equal deleted inserted replaced
67:5b6211e2e36f 68:67bcca6e3cb1
224 lowlim = prev 224 lowlim = prev
225 else: 225 else:
226 lowlim = itsEntries[i-1]["endt"] 226 lowlim = itsEntries[i-1]["endt"]
227 hilim = itsEntries[i]["endt"] 227 hilim = itsEntries[i]["endt"]
228 recs = [ k[1] for k in vfilekeys if lowlim <= k[0] < hilim ] 228 recs = [ k[1] for k in vfilekeys if lowlim <= k[0] < hilim ]
229 itsEntries[i]["startt"] = recnameToTS(recs[0]) 229 if len(recs) == 0:
230 itsEntries[i]["ttyrecs"] = recs 230 # There inexplicably are no files. TODO log an error.
231 itsEntries[i]["startt"] = lowlim
232 itsEntries[i]["ttyrecs"] = []
233 else:
234 itsEntries[i]["startt"] = recnameToTS(recs[0])
235 itsEntries[i]["ttyrecs"] = recs
231 cur.close() 236 cur.close()
232 conn.close() 237 conn.close()
233 def putIntoDB(self, dictlist, conn): 238 def putIntoDB(self, dictlist, conn):
234 cur = conn.cursor() 239 cur = conn.cursor()
235 cur.executemany(self.insertq, [ d for d in dictlist if d["game"] == self ]) 240 cur.executemany(self.insertq, [ d for d in dictlist if d["game"] == self ])