我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用timer.begin()。
def __repr__(self): timertype = { TIMERTYPE.NONE: "nothing", TIMERTYPE.WAKEUP: "wakeup", TIMERTYPE.WAKEUPTOSTANDBY: "wakeuptostandby", TIMERTYPE.AUTOSTANDBY: "autostandby", TIMERTYPE.AUTODEEPSTANDBY: "autodeepstandby", TIMERTYPE.STANDBY: "standby", TIMERTYPE.DEEPSTANDBY: "deepstandby", TIMERTYPE.REBOOT: "reboot", TIMERTYPE.RESTART: "restart" }[self.timerType] if not self.disabled: return "PowerTimerEntry(type=%s, begin=%s)" % (timertype, ctime(self.begin)) else: return "PowerTimerEntry(type=%s, begin=%s Disabled)" % (timertype, ctime(self.begin))
def setAutoincreaseEnd(self, entry = None): if not self.autoincrease: return False if entry is None: new_end = int(time()) + self.autoincreasetime else: new_end = entry.begin - 30 dummyentry = PowerTimerEntry(self.begin, new_end, disabled=True, afterEvent = self.afterEvent, timerType = self.timerType) dummyentry.disabled = self.disabled timersanitycheck = TimerSanityCheck(NavigationInstance.instance.PowerManager.timer_list, dummyentry) if not timersanitycheck.check(): simulTimerList = timersanitycheck.getSimulTimerList() if simulTimerList is not None and len(simulTimerList) > 1: new_end = simulTimerList[1].begin new_end -= 30 # 30 Sekunden Prepare-Zeit lassen if new_end <= time(): return False self.end = new_end return True
def getAutoSleepWindow(self): now = time() if self.autosleepwindow == 'yes': if now < self.autosleepbegin and now < self.autosleepend: self.begin = self.autosleepbegin self.end = self.autosleepend elif now > self.autosleepbegin and now > self.autosleepend: while self.autosleepend < now: self.autosleepend += 86400 while self.autosleepbegin + 86400 < self.autosleepend: self.autosleepbegin += 86400 self.begin = self.autosleepbegin self.end = self.autosleepend if not (now > self.autosleepbegin - self.prepare_time - 3 and now < self.autosleepend): eActionMap.getInstance().unbindAction('', self.keyPressed) self.state = 0 self.timeChanged() return False return True
def getPriorityCheck(self,prioPT,prioPTae): shiftPT = breakPT = False nextPTlist = NavigationInstance.instance.PowerTimer.getNextPowerManagerTime(getNextTimerTyp = True) for entry in nextPTlist: #check timers within next 15 mins will started or ended if abs(entry[0] - time()) > 900: continue #faketime if entry[1] is None and entry[2] is None and entry[3] is None: if debug: print "shift#2 - entry is faketime", ctime(entry[0]), entry shiftPT = True continue #is timer in list itself? if entry[0] == self.begin and entry[1] == self.timerType and entry[2] is None and entry[3] == self.state \ or entry[0] == self.end and entry[1] is None and entry[2] == self.afterEvent and entry[3] == self.state: if debug: print "entry is itself", ctime(entry[0]), entry nextPTitself = True else: nextPTitself = False if (entry[1] in prioPT or entry[2] in prioPTae) and not nextPTitself: if debug: print "break#2 <= 900", ctime(entry[0]), entry breakPT = True break return shiftPT, breakPT
def getNextPowerManagerTimeOld(self, getNextStbPowerOn = False): now = int(time()) nextPTlist = [(-1,None,None,None)] for timer in self.timer_list: if timer.timerType != TIMERTYPE.AUTOSTANDBY and timer.timerType != TIMERTYPE.AUTODEEPSTANDBY: next_act = timer.getNextWakeup(getNextStbPowerOn) if next_act + 3 < now: continue if getNextStbPowerOn and debug: print "[powertimer] next stb power up", strftime("%a, %Y/%m/%d %H:%M", localtime(next_act)) next_timertype = next_afterevent = None if nextPTlist[0][0] == -1: if abs(next_act - timer.begin) <= 30: next_timertype = timer.timerType elif abs(next_act - timer.end) <= 30: next_afterevent = timer.afterEvent nextPTlist = [(next_act,next_timertype,next_afterevent,timer.state)] else: if abs(next_act - timer.begin) <= 30: next_timertype = timer.timerType elif abs(next_act - timer.end) <= 30: next_afterevent = timer.afterEvent nextPTlist.append((next_act,next_timertype,next_afterevent,timer.state)) nextPTlist.sort() return nextPTlist
def setAutoincreaseEnd(self, entry = None): if not self.autoincrease: return False if entry is None: new_end = int(time()) + self.autoincreasetime else: new_end = entry.begin -30 dummyentry = RecordTimerEntry(self.service_ref, self.begin, new_end, self.name, self.description, self.eit, disabled=True, justplay = self.justplay, afterEvent = self.afterEvent, dirname = self.dirname, tags = self.tags) dummyentry.disabled = self.disabled timersanitycheck = TimerSanityCheck(NavigationInstance.instance.RecordTimer.timer_list, dummyentry) if not timersanitycheck.check(): simulTimerList = timersanitycheck.getSimulTimerList() if simulTimerList is not None and len(simulTimerList) > 1: new_end = simulTimerList[1].begin new_end -= 30 # allow 30 seconds for prepare if new_end <= time(): return False self.end = new_end return True
def getNextRecordingTime(self, getNextStbPowerOn = False): #getNextStbPowerOn = True returns tuple -> (timer.begin, set standby) nextrectime = self.getNextRecordingTimeOld(getNextStbPowerOn) faketime = time()+300 if getNextStbPowerOn: if config.timeshift.isRecording.value: if 0 < nextrectime[0] < faketime: return nextrectime else: return faketime, 0 else: return nextrectime else: if config.timeshift.isRecording.value: if 0 < nextrectime < faketime: return nextrectime else: return faketime else: return nextrectime
def setAutoincreaseEnd(self, entry = None): if not self.autoincrease: return False if entry is None: new_end = int(time()) + self.autoincreasetime else: new_end = entry.begin - 30 dummyentry = RecordTimerEntry(self.service_ref, self.begin, new_end, self.name, self.description, self.eit, disabled=True, justplay = self.justplay, afterEvent = self.afterEvent, dirname = self.dirname, tags = self.tags) dummyentry.disabled = self.disabled timersanitycheck = TimerSanityCheck(NavigationInstance.instance.RecordTimer.timer_list, dummyentry) if not timersanitycheck.check(): simulTimerList = timersanitycheck.getSimulTimerList() if simulTimerList is not None and len(simulTimerList) > 1: new_end = simulTimerList[1].begin new_end -= 30 # 30 Sekunden Prepare-Zeit lassen if new_end <= time(): return False self.end = new_end return True
def __init__(self, begin, end, disabled = False, afterEvent = AFTEREVENT.NONE, timerType = TIMERTYPE.WAKEUP, checkOldTimers = False): timer.TimerEntry.__init__(self, int(begin), int(end)) if checkOldTimers: if self.begin < time() - 1209600: self.begin = int(time()) if self.end < self.begin: self.end = self.begin self.dontSave = False self.disabled = disabled self.timer = None self.__record_service = None self.start_prepare = 0 self.timerType = timerType self.afterEvent = afterEvent self.autoincrease = False self.autoincreasetime = 3600 * 24 # 1 day self.autosleepinstandbyonly = 'no' self.autosleepdelay = 60 self.autosleeprepeat = 'once' self.log_entries = [] self.resetState()
def do_backoff(self): if self.backoff == 0: self.backoff = 5*60 else: self.backoff *= 2 if self.backoff > 1800: self.backoff = 1800 self.log(10, "backoff: retry in %d minutes" % (int(self.backoff)/60)) # # If this is the first backoff of a repeat timer remember the original # begin/end times, so that we can use *these* when setting up the # repeat. # A repeat timer (self.repeat != 0) is one set for a given time on a # day. # A timer that repeats every <n> mins has autosleeprepeat="repeated" and # is a different beast, whcih doesn't need, and mustn't have, this. # if self.repeated and not hasattr(self, "real_begin"): self.real_begin = self.begin self.real_end = self.end
def setAutoincreaseEnd(self, entry = None): if not self.autoincrease: return False if entry is None: new_end = int(time()) + self.autoincreasetime else: new_end = entry.begin -30 dummyentry = PowerTimerEntry(self.begin, new_end, disabled=True, afterEvent = self.afterEvent, timerType = self.timerType) dummyentry.disabled = self.disabled timersanitycheck = TimerSanityCheck(NavigationInstance.instance.PowerManager.timer_list, dummyentry) if not timersanitycheck.check(): simulTimerList = timersanitycheck.getSimulTimerList() if simulTimerList is not None and len(simulTimerList) > 1: new_end = simulTimerList[1].begin new_end -= 30 # 30 Sekunden Prepare-Zeit lassen if new_end <= time(): return False self.end = new_end return True
def calculateFilename(self, name=None): service_name = self.service_ref.getServiceName() begin_date = strftime("%Y%m%d %H%M", localtime(self.begin)) name = name or self.name filename = begin_date + " - " + service_name if name: if config.recording.filename_composition.value == "event": filename = name + ' - ' + begin_date + "_" + service_name elif config.recording.filename_composition.value == "short": filename = strftime("%Y%m%d", localtime(self.begin)) + " - " + name elif config.recording.filename_composition.value == "long": filename += " - " + name + " - " + self.description else: filename += " - " + name # standard if config.recording.ascii_filenames.value: filename = ASCIItranslit.legacyEncode(filename) self.Filename = Directories.getRecordingFilename(filename, self.MountPath) self.log(0, "Filename calculated as: '%s'" % self.Filename) return self.Filename
def setAutoincreaseEnd(self, entry = None): if not self.autoincrease: return False if entry is None: new_end = int(time()) + self.autoincreasetime else: new_end = entry.begin -30 dummyentry = RecordTimerEntry(self.service_ref, self.begin, new_end, self.name, self.description, self.eit, disabled=True, justplay = self.justplay, afterEvent = self.afterEvent, dirname = self.dirname, tags = self.tags) dummyentry.disabled = self.disabled timersanitycheck = TimerSanityCheck(NavigationInstance.instance.RecordTimer.timer_list, dummyentry) if not timersanitycheck.check(): simulTimerList = timersanitycheck.getSimulTimerList() if simulTimerList is not None and len(simulTimerList) > 1: new_end = simulTimerList[1].begin new_end -= 30 # 30 Sekunden Prepare-Zeit lassen if new_end <= time(): return False self.end = new_end return True
def resetTimerWakeup(): global wasTimerWakeup if os.path.exists("/tmp/was_powertimer_wakeup"): os.remove("/tmp/was_powertimer_wakeup") if debug: print "[POWERTIMER] reset wakeup state" wasTimerWakeup = False # parses an event, and gives out a (begin, end, name, duration, eit)-tuple. # begin and end will be corrected
def parseEvent(ev): begin = ev.getBeginTime() end = begin + ev.getDuration() return begin, end
def __init__(self, begin, end, disabled = False, afterEvent = AFTEREVENT.NONE, timerType = TIMERTYPE.WAKEUP, checkOldTimers = False, autosleepdelay = 60): timer.TimerEntry.__init__(self, int(begin), int(end)) if checkOldTimers: if self.begin < time() - 1209600: self.begin = int(time()) if self.end < self.begin: self.end = self.begin self.dontSave = False self.disabled = disabled self.timer = None self.__record_service = None self.start_prepare = 0 self.timerType = timerType self.afterEvent = afterEvent self.autoincrease = False self.autoincreasetime = 3600 * 24 # 1 day self.autosleepinstandbyonly = 'no' self.autosleepdelay = autosleepdelay self.autosleeprepeat = 'once' self.autosleepwindow = 'no' self.autosleepbegin = self.begin self.autosleepend = self.end self.nettraffic = 'no' self.trafficlimit = 100 self.netip = 'no' self.ipadress = "0.0.0.0" self.log_entries = [] self.resetState() self.messageBoxAnswerPending = False #check autopowertimer if (self.timerType == TIMERTYPE.AUTOSTANDBY or self.timerType == TIMERTYPE.AUTODEEPSTANDBY) and not self.disabled and time() > 3600 and self.begin > time(): self.begin = int(time()) #the begin is in the future -> set to current time = no start delay of this timer
def getNextActivation(self): if self.state == self.StateEnded or self.state == self.StateFailed: return self.end next_state = self.state + 1 return {self.StatePrepared: self.start_prepare, self.StateRunning: self.begin, self.StateEnded: self.end }[next_state]
def getNextWakeup(self, getNextStbPowerOn = False): next_state = self.state + 1 if getNextStbPowerOn: if next_state == 3 and (self.timerType == TIMERTYPE.WAKEUP or self.timerType == TIMERTYPE.WAKEUPTOSTANDBY or self.afterEvent == AFTEREVENT.WAKEUP or self.afterEvent == AFTEREVENT.WAKEUPTOSTANDBY): if self.start_prepare > time() and (self.timerType == TIMERTYPE.WAKEUP or self.timerType == TIMERTYPE.WAKEUPTOSTANDBY): #timer start time is later as now - begin time was changed while running timer return self.start_prepare elif self.begin > time() and (self.timerType == TIMERTYPE.WAKEUP or self.timerType == TIMERTYPE.WAKEUPTOSTANDBY): #timer start time is later as now - begin time was changed while running timer return self.begin if self.afterEvent == AFTEREVENT.WAKEUP or self.afterEvent == AFTEREVENT.WAKEUPTOSTANDBY: return self.end next_day = 0 count_day = 0 wd_timer = datetime.fromtimestamp(self.begin).isoweekday()*-1 wd_repeated = bin(128+self.repeated) for s in range(wd_timer-1,-8,-1): count_day +=1 if int(wd_repeated[s]): next_day = s break if next_day == 0: for s in range(-1,wd_timer-1,-1): count_day +=1 if int(wd_repeated[s]): next_day = s break #return self.begin + 86400 * count_day return self.start_prepare + 86400 * count_day elif next_state == 2 and (self.timerType == TIMERTYPE.WAKEUP or self.timerType == TIMERTYPE.WAKEUPTOSTANDBY): return self.begin elif next_state == 1 and (self.timerType == TIMERTYPE.WAKEUP or self.timerType == TIMERTYPE.WAKEUPTOSTANDBY): return self.start_prepare elif next_state < 3 and (self.afterEvent == AFTEREVENT.WAKEUP or self.afterEvent == AFTEREVENT.WAKEUPTOSTANDBY): return self.end else: return -1 if self.state == self.StateEnded or self.state == self.StateFailed: return self.end return {self.StatePrepared: self.start_prepare, self.StateRunning: self.begin, self.StateEnded: self.end}[next_state]
def timeChanged(self): old_prepare = self.start_prepare self.start_prepare = self.begin - self.prepare_time self.backoff = 0 if int(old_prepare) > 60 and int(old_prepare) != int(self.start_prepare): self.log(15, "time changed, start prepare is now: %s" % ctime(self.start_prepare))
def isAutoDeepstandbyEnabled(self): ret = True if Screens.Standby.inStandby: now = time() for timer in self.timer_list: if timer.timerType == TIMERTYPE.AUTODEEPSTANDBY: if timer.begin <= now + 900: ret = not (timer.getNetworkTraffic() or timer.getNetworkAdress()) elif timer.autosleepwindow == 'yes': ret = timer.autosleepbegin <= now + 900 if not ret: break return ret
def getNextZapTime(self): now = time() for timer in self.timer_list: if timer.begin < now: continue return timer.begin return -1
def resetTimerWakeup(): global wasRecTimerWakeup if os.path.exists("/tmp/was_rectimer_wakeup"): os.remove("/tmp/was_rectimer_wakeup") if debug: print "[RECORDTIMER] reset wakeup state" wasRecTimerWakeup = False # parses an event and returns a (begin, end, name, duration, eit)-tuple. # begin and end will be corrected
def __repr__(self): if not self.disabled: return "RecordTimerEntry(name=%s, begin=%s, serviceref=%s, justplay=%s, isAutoTimer=%s)" % (self.name, ctime(self.begin), self.service_ref, self.justplay, self.isAutoTimer) else: return "RecordTimerEntry(name=%s, begin=%s, serviceref=%s, justplay=%s, isAutoTimer=%s, Disabled)" % (self.name, ctime(self.begin), self.service_ref, self.justplay, self.isAutoTimer)
def calculateFilename(self, name=None): service_name = self.service_ref.getServiceName() begin_date = strftime("%Y%m%d %H%M", localtime(self.begin)) self.name = name or self.name filename = begin_date + " - " + service_name if self.name: if config.recording.filename_composition.value == "veryveryshort": filename = self.name elif config.recording.filename_composition.value == "veryshort": filename = self.name + " - " + begin_date elif config.recording.filename_composition.value == "event": filename = self.name + ' - ' + begin_date + "_" + service_name elif config.recording.filename_composition.value == "short": filename = strftime("%Y%m%d", localtime(self.begin)) + " - " + self.name elif config.recording.filename_composition.value == "shortwithtime": filename = strftime("%Y%m%d %H%M", localtime(self.begin)) + " - " + self.name elif config.recording.filename_composition.value == "long": filename += " - " + self.name + " - " + self.description else: filename += " - " + self.name # standard if config.recording.ascii_filenames.value: filename = ASCIItranslit.legacyEncode(filename) self.Filename = Directories.getRecordingFilename(filename, self.MountPath) if debug: self.log(0, "Filename calculated as: '%s'" % self.Filename) return self.Filename
def getNextActivation(self, getNextStbPowerOn = False): self.isStillRecording = False next_state = self.state + 1 if getNextStbPowerOn: if next_state == 3: self.isStillRecording = True next_day = 0 count_day = 0 wd_timer = datetime.fromtimestamp(self.begin).isoweekday()*-1 wd_repeated = bin(128+int(self.repeated)) for s in range(wd_timer-1,-8,-1): count_day +=1 if int(wd_repeated[s]): next_day = s break if next_day == 0: for s in range(-1,wd_timer-1,-1): count_day +=1 if int(wd_repeated[s]): next_day = s break #return self.begin + 86400 * count_day return self.start_prepare + 86400 * count_day elif next_state == 2: return self.begin elif next_state == 1: return self.start_prepare else: return -1 if self.state == self.StateEnded or self.state == self.StateFailed: if self.end > time(): self.isStillRecording = True return self.end if next_state == self.StateEnded or next_state == self.StateFailed: if self.end > time(): self.isStillRecording = True return {self.StatePrepared: self.start_prepare, self.StateRunning: self.begin, self.StateEnded: self.end}[next_state]
def timeChanged(self): old_prepare = self.start_prepare self.start_prepare = self.begin - self.prepare_time self.backoff = 0 if int(old_prepare) > 60 and int(old_prepare) != int(self.start_prepare): self.log(15, _("record time changed, start prepare is now: %s") % ctime(self.start_prepare))
def checkWrongRunningTimers(self): now = time() + 100 if int(now) > 1072224000: wrong_timers = [entry for entry in (self.processed_timers + self.timer_list) if entry.state in (1, 2) and entry.begin > now] for timer in wrong_timers: timer.state = RecordTimerEntry.StateWaiting self.timeChanged(timer)
def getNextZapTime(self): now = time() for timer in self.timer_list: if not timer.justplay or timer.begin < now: continue return timer.begin return -1
def getStillRecording(self): isStillRecording = False now = time() for timer in self.timer_list: if timer.isStillRecording: isStillRecording = True break elif abs(timer.begin - now) <= 10 and not abs(timer.end - now) <= 10: isStillRecording = True break return isStillRecording
def parseEvent(ev, description = True): if description: name = ev.getEventName() description = ev.getShortDescription() if description == "": description = ev.getExtendedDescription() else: name = "" description = "" begin = ev.getBeginTime() end = begin + ev.getDuration() eit = ev.getEventId() begin -= config.recording.margin_before.value * 60 end += config.recording.margin_after.value * 60 return (begin, end, name, description, eit)
def __repr__(self): return "RecordTimerEntry(name=%s, begin=%s, serviceref=%s, justplay=%s, isAutoTimer=%s)" % (self.name, ctime(self.begin), self.service_ref, self.justplay, self.isAutoTimer)
def calculateFilename(self, name=None): service_name = self.service_ref.getServiceName() begin_date = strftime("%Y%m%d %H%M", localtime(self.begin)) name = name or self.name filename = begin_date + " - " + service_name if name: if config.recording.filename_composition.value == "short": filename = strftime("%Y%m%d", localtime(self.begin)) + " - " + name elif config.recording.filename_composition.value == "long": filename += " - " + name + " - " + self.description else: filename += " - " + name # standard if config.recording.ascii_filenames.value: filename = ASCIItranslit.legacyEncode(filename) if not self.dirname: dirname = findSafeRecordPath(defaultMoviePath()) else: dirname = findSafeRecordPath(self.dirname) if dirname is None: dirname = findSafeRecordPath(defaultMoviePath()) self.dirnameHadToFallback = True if not dirname: return None self.Filename = Directories.getRecordingFilename(filename, dirname) self.log(0, "Filename calculated as: '%s'" % self.Filename) return self.Filename
def timeChanged(self): old_prepare = self.start_prepare self.start_prepare = self.begin - self.prepare_time self.backoff = 0 if int(old_prepare) != int(self.start_prepare): self.log(15, "record time changed, start prepare is now: %s" % ctime(self.start_prepare))
def getNextZapTime(self, isWakeup=False): now = time() for timer in self.timer_list: if not timer.justplay or timer.begin < now or isWakeup and timer.zap_wakeup in ("from_standby", "never"): continue return timer.begin return -1
def isNextRecordAfterEventActionAuto(self): now = time() t = None for timer in self.timer_list: if timer.justplay or timer.begin < now: continue if t is None or t.begin == timer.begin: t = timer if t.afterEvent == AFTEREVENT.AUTO: return True return False
def __repr__(self): timertype = { TIMERTYPE.WAKEUP: "wakeup", TIMERTYPE.WAKEUPTOSTANDBY: "wakeuptostandby", TIMERTYPE.AUTOSTANDBY: "autostandby", TIMERTYPE.AUTODEEPSTANDBY: "autodeepstandby", TIMERTYPE.STANDBY: "standby", TIMERTYPE.DEEPSTANDBY: "deepstandby", TIMERTYPE.REBOOT: "reboot", TIMERTYPE.RESTART: "restart" }[self.timerType] if not self.disabled: return "PowerTimerEntry(type=%s, begin=%s)" % (timertype, ctime(self.begin)) else: return "PowerTimerEntry(type=%s, begin=%s Disabled)" % (timertype, ctime(self.begin))
def getNextWakeup(self): if self.state == self.StateEnded or self.state == self.StateFailed: return self.end if self.timerType != TIMERTYPE.WAKEUP and self.timerType != TIMERTYPE.WAKEUPTOSTANDBY and not self.afterEvent: return -1 elif self.timerType != TIMERTYPE.WAKEUP and self.timerType != TIMERTYPE.WAKEUPTOSTANDBY and self.afterEvent: return self.end next_state = self.state + 1 return {self.StatePrepared: self.start_prepare, self.StateRunning: self.begin, self.StateEnded: self.end }[next_state]
def createTimer(xml): timertype = str(xml.get("timertype") or "wakeup") timertype = { "wakeup": TIMERTYPE.WAKEUP, "wakeuptostandby": TIMERTYPE.WAKEUPTOSTANDBY, "autostandby": TIMERTYPE.AUTOSTANDBY, "autodeepstandby": TIMERTYPE.AUTODEEPSTANDBY, "standby": TIMERTYPE.STANDBY, "deepstandby": TIMERTYPE.DEEPSTANDBY, "reboot": TIMERTYPE.REBOOT, "restart": TIMERTYPE.RESTART }[timertype] begin = int(xml.get("begin")) end = int(xml.get("end")) repeated = xml.get("repeated").encode("utf-8") disabled = long(xml.get("disabled") or "0") afterevent = str(xml.get("afterevent") or "nothing") afterevent = { "nothing": AFTEREVENT.NONE, "wakeuptostandby": AFTEREVENT.WAKEUPTOSTANDBY, "standby": AFTEREVENT.STANDBY, "deepstandby": AFTEREVENT.DEEPSTANDBY }[afterevent] autosleepinstandbyonly = str(xml.get("autosleepinstandbyonly") or "no") autosleepdelay = str(xml.get("autosleepdelay") or "0") autosleeprepeat = str(xml.get("autosleeprepeat") or "once") entry = PowerTimerEntry(begin, end, disabled, afterevent, timertype) entry.repeated = int(repeated) entry.autosleepinstandbyonly = autosleepinstandbyonly entry.autosleepdelay = int(autosleepdelay) entry.autosleeprepeat = autosleeprepeat for l in xml.findall("log"): time = int(l.get("time")) code = int(l.get("code")) msg = l.text.strip().encode("utf-8") entry.log_entries.append((time, code, msg)) return entry
def doActivate(self, w): # when activating a timer which has already passed, # simply abort the timer. don't run trough all the stages. if w.shouldSkip(): w.state = PowerTimerEntry.StateEnded else: # when active returns true, this means "accepted". # otherwise, the current state is kept. # the timer entry itself will fix up the delay then. if w.activate(): w.state += 1 try: self.timer_list.remove(w) except: print '[PowerManager]: Remove list failed' # did this timer reached the last state? if w.state < PowerTimerEntry.StateEnded: # no, sort it into active list insort(self.timer_list, w) else: # yes. Process repeated, and re-add. if w.repeated: # If we have saved original begin/end times for a backed off timer # restore those values now if hasattr(w, "real_begin"): w.begin = w.real_begin w.end = w.real_end # Now remove the temporary holding attributes... del w.real_begin del w.real_end w.processRepeated() w.state = PowerTimerEntry.StateWaiting self.addTimerEntry(w) else: # Remove old timers as set in config self.cleanupDaily(config.recording.keep_timers.value) insort(self.processed_timers, w) self.stateChanged(w)
def timeChanged(self): old_prepare = self.start_prepare self.start_prepare = self.begin - self.prepare_time self.backoff = 0 if int(old_prepare) > 60 and int(old_prepare) != int(self.start_prepare): self.log(15, "record time changed, start prepare is now: %s" % ctime(self.start_prepare))
def getStillRecording(self): isStillRecording = False now = time() for timer in self.timer_list: if timer.isStillRecording: isStillRecording = True break elif abs(timer.begin - now) <= 10: isStillRecording = True break return isStillRecording