From 2f95935349afa14e1c9b6a9b608874574374a3c0 Mon Sep 17 00:00:00 2001 From: "John \"Elwin\" Edwards" Date: Sat, 16 Jan 2016 02:12:50 +0000 Subject: [PATCH] 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. --- py/rlgall.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/py/rlgall.py b/py/rlgall.py index 6188375..175f04f 100644 --- a/py/rlgall.py +++ b/py/rlgall.py @@ -226,8 +226,13 @@ class Game: 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):