def callbackGoodnight(self): print("Conversation::callbackGoodnight called") self.__isAwake = False self.disableEvents() delay = Event.computeNextEvent(self.wakeupTime) t = threading.Timer(delay, self.callbackGoodnight) self.threads[1] = t t.start()
def callbackWakeup(self): print("Conversation::callbackWakeup called") self.__isAwake = True self.enableEvents() delay = Event.computeNextEvent(self.wakeupTime) t = threading.Timer(delay, self.callbackWakeup) self.threads[0] = t t.start()
def setWakeup(self, wakeupTime): if (isinstance(wakeupTime, datetime)): self.wakeupTime = wakeupTime if (self.threads[0] != None): self.threads[0].cancel() delay = Event.computeNextEvent(wakeupTime) t = threading.Timer(delay, self.callbackWakeup) self.threads[0] = t t.start() else: print("Conversation >> WAKEUP NOT A DATETIME")
def setGoodnight(self, goodnightTime): if (isinstance(goodnightTime, datetime)): self.goodnightTime = goodnightTime + timedelta( minutes=self.delayToGetAsleep) if (self.threads[1] != None): self.threads[1].cancel() delay = Event.computeNextEvent(self.goodnightTime) t = threading.Timer(delay, self.callbackGoodnight) self.threads[1] = t t.start() else: print("Conversation >> GOODNIGHT NOT A DATETIME")