def readTimes(self): print "[times] reading events" with open(self.TIMEFILE,"r") as infile: # with open("timesbck.txt","r") as infile: lines = infile.readlines() lines = [line.strip() for line in lines if len(lines)>2] for line in lines: ta, tb, action = line.split(" ",2) ta, tb = u.fromTimestamp(ta), u.fromTimestamp(tb) self.events.append( [ta,tb, action] )
def startLoop(self): self.doLoop = True self.thread.start() def stopLoop(self): self.doLoop = False # doesn't actually kill the thread def loop(self): while self.doLoop: self.readTimes() self.checkTimes() self.writeTimes() time.sleep(self.DELAY) if __name__ == '__main__': events = Events() events.startLoop() while True: test = raw_input("test") print test if test == "e": events.stopLoop() if test == "a": ta = u.fromTimestamp(1450306547) tb = u.fromTimestamp(1450306647) events.addEvent(ta,tb, "another thing")