Index: RecordTimer.py =================================================================== RCS file: /cvs/enigma2/RecordTimer.py,v retrieving revision 1.93 diff -u -r1.93 RecordTimer.py --- RecordTimer.py 5 Sep 2007 14:19:58 -0000 1.93 +++ RecordTimer.py 30 Nov 2007 12:09:30 -0000 @@ -91,7 +91,7 @@ Notifications.AddNotification(Screens.Standby.TryQuitMainloop, 1, onSessionOpenCallback=RecordTimerEntry.stopTryQuitMainloop) ################################################################# - def __init__(self, serviceref, begin, end, name, description, eit, disabled = False, justplay = False, afterEvent = AFTEREVENT.NONE, checkOldTimers = False): + def __init__(self, serviceref, begin, end, name, description, eit, disabled = False, justplay = False, afterEvent = AFTEREVENT.NONE, checkOldTimers = False, type = "record"): timer.TimerEntry.__init__(self, int(begin), int(end)) if checkOldTimers == True: @@ -112,7 +112,17 @@ self.timer = None self.__record_service = None self.start_prepare = 0 - self.justplay = justplay + # Fallback + if justplay: + print "justplay is obsolete, please use type=\"zap\"" + type = "zap" + if type in ["zap", "shutdown", "bootup"]: + self.end = self.begin + 1 + self.type = type + else: + if type != "record": + print "invalid type supplied, assume \"record\"" + self.type = "record" self.afterEvent = afterEvent self.log_entries = [] @@ -146,7 +156,7 @@ #begin_date + " - " + service_name + description) def tryPrepare(self): - if self.justplay: + if self.type in ["zap", "shutdown", "bootup"]: return True else: self.calculateFilename() @@ -240,7 +250,7 @@ if self.cancelled: return True - if self.justplay: + if self.type == "zap": if Screens.Standby.inStandby: self.log(11, "wakeup and zap") #set service to zap after standby @@ -251,6 +261,12 @@ self.log(11, "zapping") NavigationInstance.instance.playService(self.service_ref.ref) return True + elif self.type == "shutdown": + self.log(11, "shutting down") + return True + elif self.type == "bootup": + self.log(11, "booting up") + return True else: self.log(11, "start recording") record_res = self.record_service.start() @@ -265,13 +281,13 @@ return True elif next_state == self.StateEnded: self.log(12, "stop recording") - if not self.justplay: + if self.type not in ["zap", "shutdown", "bootup"]: NavigationInstance.instance.stopRecordService(self.record_service) self.record_service = None if self.afterEvent == AFTEREVENT.STANDBY: if not Screens.Standby.inStandby: # not already in standby Notifications.AddNotificationWithCallback(self.sendStandbyNotification, MessageBox, _("A finished record timer wants to set your\nDreambox to standby. Do that now?"), timeout = 20) - if self.afterEvent == AFTEREVENT.DEEPSTANDBY: + if self.afterEvent == AFTEREVENT.DEEPSTANDBY or self.type == "shutdown": if not Screens.Standby.inTryQuitMainloop: # not a shutdown messagebox is open if Screens.Standby.inStandby: # not in standby RecordTimerEntry.TryQuitMainloop() # start shutdown handling without screen @@ -345,6 +361,19 @@ record_service = property(lambda self: self.__record_service, setRecordService) + def getJustplay(self): + print "justplay is obsolete, please use type-property" + return int(self.type == "zap") + + def setJustplay(self, justplay): + print "justplay is obsolete, please use type-property" + if justplay: + self.type = "zap" + else: + self.type = "record" + + justplay = property(getJustplay, setJustplay) + def createTimer(xml): begin = int(xml.getAttribute("begin")) end = int(xml.getAttribute("end")) @@ -353,6 +382,13 @@ repeated = xml.getAttribute("repeated").encode("utf-8") disabled = long(xml.getAttribute("disabled") or "0") justplay = long(xml.getAttribute("justplay") or "0") + type = xml.getAttribute("type").encode("utf-8") or "record" + if justplay: + print "justplay is obsolete, please use type=\"zap\"" + type = "zap" + if type not in ["zap", "shutdown", "bootup", "record"]: + print "invalid type, assuming record" + type = "record" afterevent = str(xml.getAttribute("afterevent") or "nothing") afterevent = { "nothing": AFTEREVENT.NONE, "standby": AFTEREVENT.STANDBY, "deepstandby": AFTEREVENT.DEEPSTANDBY }[afterevent] if xml.hasAttribute("eit") and xml.getAttribute("eit") != "None": @@ -362,7 +398,7 @@ name = xml.getAttribute("name").encode("utf-8") #filename = xml.getAttribute("filename").encode("utf-8") - entry = RecordTimerEntry(serviceref, begin, end, name, description, eit, disabled, justplay, afterevent) + entry = RecordTimerEntry(serviceref, begin, end, name, description, eit, disabled, afterEvent = afterevent, type = type) entry.repeated = int(repeated) for l in elementsWithTag(xml.childNodes, "log"): @@ -387,7 +423,7 @@ def isRecording(self): isRunning = False for timer in self.timer_list: - if timer.isRunning() and not timer.justplay: + if timer.isRunning() and not timer.type in ["zap", "shutdown", "bootup"]: isRunning = True return isRunning @@ -460,7 +496,7 @@ if timer.eit is not None: list.append(' eit="' + str(timer.eit) + '"') list.append(' disabled="' + str(int(timer.disabled)) + '"') - list.append(' justplay="' + str(int(timer.justplay)) + '"') + list.append(' type="' + str(timer.type) + '"') list.append('>\n') if config.recording.debug.value: @@ -484,7 +520,8 @@ def getNextZapTime(self): now = time.time() for timer in self.timer_list: - if not timer.justplay or timer.begin < now: + # TODO: checking bootup here is a little hackish + if not timer.type in ["zap", "bootup"] or timer.begin < now: continue return timer.begin return -1 @@ -492,7 +529,7 @@ def getNextRecordingTime(self): now = time.time() for timer in self.timer_list: - if timer.justplay or timer.begin < now: + if timer.type != "record" or timer.begin < now: continue return timer.begin return -1 Index: lib/python/Components/TimerList.py =================================================================== RCS file: /cvs/enigma2/lib/python/Components/TimerList.py,v retrieving revision 1.33 diff -u -r1.33 TimerList.py --- lib/python/Components/TimerList.py 19 Nov 2007 23:58:56 -0000 1.33 +++ lib/python/Components/TimerList.py 30 Nov 2007 12:09:42 -0000 @@ -31,13 +31,21 @@ repeatedtext += days[x] count += 1 flags = flags >> 1 - if timer.justplay: + if timer.type == "zap": res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 50, 400, 20, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, repeatedtext + ((" %s "+ _("(ZAP)")) % (FuzzyTime(timer.begin)[1])))) + elif timer.type == "bootup": + res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 50, 400, 20, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, repeatedtext + ((" %s "+ _("(BOOTUP)")) % (FuzzyTime(timer.begin)[1])))) + elif timer.type == "shutdown": + res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 50, 400, 20, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, repeatedtext + ((" %s "+ _("(SHUTDOWN)")) % (FuzzyTime(timer.begin)[1])))) else: res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 50, 400, 20, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, repeatedtext + ((" %s ... %s (%d " + _("mins") + ")") % (FuzzyTime(timer.begin)[1], FuzzyTime(timer.end)[1], (timer.end - timer.begin) / 60)))) else: - if timer.justplay: - res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 50, 400, 20, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, repeatedtext + (("%s, %s " + _("(ZAP)")) % (FuzzyTime(timer.begin))))) + if timer.type == "zap": + res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 50, 400, 20, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, repeatedtext + ((" %s, %s "+ _("(ZAP)")) % (FuzzyTime(timer.begin))))) + elif timer.type == "bootup": + res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 50, 400, 20, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, repeatedtext + ((" %s, %s "+ _("(BOOTUP)")) % (FuzzyTime(timer.begin))))) + elif timer.type == "shutdown": + res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 50, 400, 20, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, repeatedtext + ((" %s, %s "+ _("(SHUTDOWN)")) % (FuzzyTime(timer.begin))))) else: res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 50, 400, 20, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, repeatedtext + (("%s, %s ... %s (%d " + _("mins") + ")") % (FuzzyTime(timer.begin) + FuzzyTime(timer.end)[1:] + ((timer.end - timer.begin) / 60,))))) @@ -47,8 +55,13 @@ elif timer.state == TimerEntry.StatePrepared: state = _("about to start") elif timer.state == TimerEntry.StateRunning: - if timer.justplay: + # TODO: is type != recording useful now that length was shortened to 1sec + if timer.type == "zap": state = _("zapped") + elif timer.type == "bootup": + state = _("booted") + elif timer.type == "shutdown": + state = _("shut down") else: state = _("recording...") else: Index: lib/python/Screens/TimerEntry.py =================================================================== RCS file: /cvs/enigma2/lib/python/Screens/TimerEntry.py,v retrieving revision 1.62 diff -u -r1.62 TimerEntry.py --- lib/python/Screens/TimerEntry.py 26 Oct 2007 17:01:07 -0000 1.62 +++ lib/python/Screens/TimerEntry.py 30 Nov 2007 12:09:56 -0000 @@ -42,7 +42,8 @@ self.createSetup("config") def createConfig(self): - justplay = self.timer.justplay + # TODO: think of a more unique name (we already have "type") + timertype = self.timer.type afterevent = { AFTEREVENT.NONE: "nothing", AFTEREVENT.DEEPSTANDBY: "deepstandby", AFTEREVENT.STANDBY: "standby"}[self.timer.afterEvent] @@ -81,7 +82,7 @@ weekday = (int(time.strftime("%w", time.localtime(self.timer.begin))) - 1) % 7 day[weekday] = 1 - self.timerentry_justplay = ConfigSelection(choices = [("zap", _("zap")), ("record", _("record"))], default = {0: "record", 1: "zap"}[justplay]) + self.timerentry_timertype = ConfigSelection(choices = [("zap", _("zap")), ("record", _("record")), ("bootup", _("bootup")), ("shutdown", _("shutdown"))], default = timertype) self.timerentry_afterevent = ConfigSelection(choices = [("nothing", _("do nothing")), ("standby", _("go to standby")), ("deepstandby", _("go to deep standby"))], default = afterevent) self.timerentry_type = ConfigSelection(choices = [("once",_("once")), ("repeated", _("repeated"))], default = type) self.timerentry_name = ConfigText(default = self.timer.name, fixed_size = False) @@ -128,7 +129,7 @@ self.list = [] self.list.append(getConfigListEntry(_("Name"), self.timerentry_name)) self.list.append(getConfigListEntry(_("Description"), self.timerentry_description)) - self.timerJustplayEntry = getConfigListEntry(_("Timer Type"), self.timerentry_justplay) + self.timerJustplayEntry = getConfigListEntry(_("Timer Type"), self.timerentry_timertype) self.list.append(self.timerJustplayEntry) self.timerTypeEntry = getConfigListEntry(_("Repeat Type"), self.timerentry_type) self.list.append(self.timerTypeEntry) @@ -168,18 +169,19 @@ self.entryEndDate = getConfigListEntry(_("End"), self.timerentry_enddate) if self.timerentry_type.value == "once": - if self.timerentry_justplay.value != "zap": + if self.timerentry_timertype.value not in ["zap", "shutdown", "bootup"]: self.list.append(self.entryEndDate) self.list.append(getConfigListEntry(" ", self.timerentry_endtime)) else: - if self.timerentry_justplay.value != "zap": + if self.timerentry_timertype.value not in ["zap", "shutdown", "bootup"]: self.list.append(getConfigListEntry(_("EndTime"), self.timerentry_endtime)) - if self.timerentry_justplay.value != "zap": + if self.timerentry_timertype.value not in ["zap", "shutdown", "bootup"]: self.list.append(getConfigListEntry(_("After event"), self.timerentry_afterevent)) self.channelEntry = getConfigListEntry(_("Channel"), self.timerentry_service) - self.list.append(self.channelEntry) + if self.timerentry_timertype.value not in ["bootup", "shutdown"]: + self.list.append(self.channelEntry) self[widget].list = self.list self[widget].l.setList(self.list) @@ -238,18 +240,20 @@ begin = self.getTimestamp(startdate, starttime) end = self.getTimestamp(enddate, endtime) - + + if self.timerentry_timertype.value in ["zap", "shutdown", "bootup"]: + end = begin + 1 # because of the dateChecks, startdate can't be < enddate. # however, the endtime can be less than the starttime. # in this case, add 1 day. - if end < begin: + elif end < begin: end += 86400 return begin, end def keyGo(self): self.timer.name = self.timerentry_name.value self.timer.description = self.timerentry_description.value - self.timer.justplay = self.timerentry_justplay.value == "zap" + self.timer.type = self.timerentry_timertype.value self.timer.resetRepeated() self.timer.afterEvent = {"nothing": AFTEREVENT.NONE, "deepstandby": AFTEREVENT.DEEPSTANDBY, "standby": AFTEREVENT.STANDBY}[self.timerentry_afterevent.value] Index: tests/test_timer.py =================================================================== RCS file: /cvs/enigma2/tests/test_timer.py,v retrieving revision 1.5 diff -u -r1.5 test_timer.py --- tests/test_timer.py 26 Mar 2007 18:25:29 -0000 1.5 +++ tests/test_timer.py 30 Nov 2007 12:09:56 -0000 @@ -39,7 +39,7 @@ afterevent="nothing" eit="56422" disabled="0" - justplay="0"> + type="record"> """ % (at + timer_start, at + timer_start + timer_length, repeat) ).childNodes[0])