我们从Python开源项目中,提取了以下30个代码示例,用于说明如何使用timer.name()。
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 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 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 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 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): 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 gotRecordEvent(self, record, event): # TODO: this is not working (never true), please fix. (comparing two swig wrapped ePtrs) if self.__record_service.__deref__() != record.__deref__(): return # self.log(16, "record event %d" % event) if event == iRecordableService.evRecordWriteError: print "WRITE ERROR on recording, disk full?" # show notification. the 'id' will make sure that it will be # displayed only once, even if more timers are failing at the # same time. (which is very likely in case of disk fullness) Notifications.AddPopup(text = _("Write error while recording. Disk full?\n"), type = MessageBox.TYPE_ERROR, timeout = 0, id = "DiskFullMessage") # ok, the recording has been stopped. we need to properly note # that in our state, with also keeping the possibility to re-try. # TODO: this has to be done. elif event == iRecordableService.evStart: RecordingsState(1) text = _("A recording has been started:\n%s") % self.name notify = config.usage.show_message_when_recording_starts.value and \ not Screens.Standby.inStandby and \ Screens.InfoBar.InfoBar.instance and \ Screens.InfoBar.InfoBar.instance.execing if self.dirnameHadToFallback: text = '\n'.join((text, _("Please note that the previously selected media could not be accessed and therefore the default directory is being used instead."))) notify = True if notify: from Screens.MessageBox import MessageBox Notifications.AddPopup(text = text, type = MessageBox.TYPE_INFO, timeout = 3) elif event == iRecordableService.evRecordAborted: NavigationInstance.instance.RecordTimer.removeEntry(self) elif event == iRecordableService.evGstRecordEnded: if self.repeated: self.processRepeated(findRunningEvent = False) NavigationInstance.instance.RecordTimer.doActivate(self) # we have record_service as property to automatically subscribe to record service events
def loadTimer(self): if not Directories.fileExists(self.Filename): return try: file = open(self.Filename, 'r') doc = xml.etree.cElementTree.parse(file) file.close() except SyntaxError: from Tools.Notifications import AddPopup from Screens.MessageBox import MessageBox AddPopup(_("The timer file (timers.xml) is corrupt and could not be loaded."), type = MessageBox.TYPE_ERROR, timeout = 0, id = "TimerLoadFailed") print "timers.xml failed to load!" try: os.rename(self.Filename, self.Filename + "_old") except (IOError, OSError): print "renaming broken timer failed" return except IOError: print "timers.xml not found!" return root = doc.getroot() checkit = False timer_text = "" for timer in root.findall("timer"): newTimer = createTimer(timer) conflict_list = self.record(newTimer, ignoreTSC=True, dosave=False, loadtimer=True) if conflict_list: checkit = True if newTimer in conflict_list: timer_text += _("\nTimer '%s' disabled!") % newTimer.name if checkit: from Tools.Notifications import AddPopup from Screens.MessageBox import MessageBox AddPopup(_("Timer overlap in timers.xml detected!\nPlease recheck it!") + timer_text, type = MessageBox.TYPE_ERROR, timeout = 0, id = "TimerLoadFailed")
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 loadTimer(self): if not Directories.fileExists(self.Filename): return try: doc = xml.etree.cElementTree.parse(self.Filename) except SyntaxError: from Tools.Notifications import AddPopup from Screens.MessageBox import MessageBox AddPopup(_("The timer file (timers.xml) is corrupt and could not be loaded."), type = MessageBox.TYPE_ERROR, timeout = 0, id = "TimerLoadFailed") print "timers.xml failed to load!" try: import os os.rename(self.Filename, self.Filename + "_old") except (IOError, OSError): print "renaming broken timer failed" return except IOError: print "timers.xml not found!" return root = doc.getroot() checkit = False timer_text = "" for timer in root.findall("timer"): newTimer = createTimer(timer) conflict_list = self.record(newTimer, ignoreTSC=True, dosave=False, loadtimer=True) if conflict_list: checkit = True if newTimer in conflict_list: timer_text += _("\nTimer '%s' disabled!") % newTimer.name if checkit: from Tools.Notifications import AddPopup from Screens.MessageBox import MessageBox AddPopup(_("Timer overlap in timers.xml detected!\nPlease recheck it!") + timer_text, type = MessageBox.TYPE_ERROR, timeout = 0, id = "TimerLoadFailed")
def loadTimer(self): try: file = open(self.Filename, 'r') doc = xml.etree.cElementTree.parse(file) file.close() except SyntaxError: from Tools.Notifications import AddPopup from Screens.MessageBox import MessageBox AddPopup(_("The timer file (timers.xml) is corrupt and could not be loaded."), type = MessageBox.TYPE_ERROR, timeout = 0, id = "TimerLoadFailed") print "[RecordTimer] timers.xml failed to load!" try: os.rename(self.Filename, self.Filename + "_old") except (IOError, OSError): print "[RecordTimer] renaming broken timer failed" return except IOError: print "[RecordTimer] timers.xml not found!" return root = doc.getroot() # put out a message when at least one timer overlaps checkit = False timer_text = "" for timer in root.findall("timer"): newTimer = createTimer(timer) conflict_list = self.record(newTimer, ignoreTSC=True, dosave=False, loadtimer=True) if conflict_list: checkit = True if newTimer in conflict_list: timer_text += _("\nTimer '%s' disabled!") % newTimer.name if checkit: from Tools.Notifications import AddPopup from Screens.MessageBox import MessageBox AddPopup(_("Timer overlap in timers.xml detected!\nPlease recheck it!") + timer_text, type = MessageBox.TYPE_ERROR, timeout = 0, id = "TimerLoadFailed")
def Plugins(path, **kwargs): return [ PluginDescriptor(where = [PluginDescriptor.WHERE_SESSIONSTART], fnc = autostart), PluginDescriptor(name="TV Charts", description="TV Charts Plugin", icon="plugin.png", where=PluginDescriptor.WHERE_EXTENSIONSMENU, fnc=main), PluginDescriptor(name="TV Charts", description="TV Charts Plugin", icon="plugin.png", where=PluginDescriptor.WHERE_PLUGINMENU, fnc=main) ]
def __repr__(self): return "RecordTimerEntry(name=%s, begin=%s, serviceref=%s, justplay=%s)" % (self.name, ctime(self.begin), self.service_ref, self.justplay)
def loadTimer(self): try: doc = xml.etree.cElementTree.parse(self.Filename) except SyntaxError: from Tools.Notifications import AddPopup from Screens.MessageBox import MessageBox AddPopup(_("The timer file (timers.xml) is corrupt and could not be loaded."), type = MessageBox.TYPE_ERROR, timeout = 0, id = "TimerLoadFailed") print "timers.xml failed to load!" try: import os os.rename(self.Filename, self.Filename + "_old") except (IOError, OSError): print "renaming broken timer failed" return except IOError: print "timers.xml not found!" return root = doc.getroot() checkit = False timer_text = "" for timer in root.findall("timer"): newTimer = createTimer(timer) conflict_list = self.record(newTimer, ignoreTSC=True, dosave=False, loadtimer=True) if conflict_list: checkit = True if newTimer in conflict_list: timer_text += _("\nTimer '%s' disabled!") % newTimer.name if checkit: from Tools.Notifications import AddPopup from Screens.MessageBox import MessageBox AddPopup(_("Timer overlap in timers.xml detected!\nPlease recheck it!") + timer_text, type = MessageBox.TYPE_ERROR, timeout = 0, id = "TimerLoadFailed")
def createTimer(xml): begin = int(xml.get("begin")) end = int(xml.get("end")) serviceref = ServiceReference(xml.get("serviceref").encode("utf-8")) description = xml.get("description").encode("utf-8") repeated = xml.get("repeated").encode("utf-8") rename_repeat = long(xml.get("rename_repeat") or "0") disabled = long(xml.get("disabled") or "0") justplay = long(xml.get("justplay") or "0") always_zap = long(xml.get("always_zap") or "0") conflict_detection = long(xml.get("conflict_detection") or "1") afterevent = str(xml.get("afterevent") or "nothing") afterevent = { "nothing": AFTEREVENT.NONE, "standby": AFTEREVENT.STANDBY, "deepstandby": AFTEREVENT.DEEPSTANDBY, "auto": AFTEREVENT.AUTO }[afterevent] eit = xml.get("eit") if eit and eit != "None": eit = long(eit) else: eit = None location = xml.get("location") if location and location != "None": location = location.encode("utf-8") else: location = None tags = xml.get("tags") if tags and tags != "None": tags = tags.encode("utf-8").split(' ') else: tags = None descramble = int(xml.get("descramble") or "1") record_ecm = int(xml.get("record_ecm") or "0") isAutoTimer = int(xml.get("isAutoTimer") or "0") name = xml.get("name").encode("utf-8") #filename = xml.get("filename").encode("utf-8") entry = RecordTimerEntry(serviceref, begin, end, name, description, eit, disabled, justplay, afterevent, dirname = location, tags = tags, descramble = descramble, record_ecm = record_ecm, conflict_detection = conflict_detection, isAutoTimer = isAutoTimer, always_zap = always_zap, rename_repeat = rename_repeat) entry.repeated = int(repeated) flags = xml.get("flags") if flags: entry.flags = set(flags.encode("utf-8").split(' ')) 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 openChoiceActionBeforeZap(self): if self.ts_dialog is None: type = _("record") if self.justplay: type = _("zap") elif self.always_zap: type = _("zap and record") message = _("You must switch to the service %s (%s - '%s')!\n") % (type, self.service_ref.getServiceName(), self.name) if self.repeated: message += _("Attention, this is repeated timer!\n") message += _("Timeshift is running. Select an action.\n") choice = [(_("Zap"), "zap"), (_("Don't zap and disable timer"), "disable"), (_("Don't zap and remove timer"), "remove")] if not self.InfoBarInstance.save_timeshift_file: choice.insert(1, (_("Save timeshift in movie dir and zap"), "save_movie")) if self.InfoBarInstance.timeshiftActivated(): choice.insert(0, (_("Save timeshift and zap"), "save")) else: choice.insert(1, (_("Save timeshift and zap"), "save")) else: message += _("Reminder, you have chosen to save timeshift file.") #if self.justplay or self.always_zap: # choice.insert(2, (_("Don't zap"), "continue")) choice.insert(2, (_("Don't zap"), "continue")) def zapAction(choice): start_zap = True if choice: if choice in ("zap", "save", "save_movie"): self.log(8, "zap to recording service") if choice in ("save", "save_movie"): ts = self.InfoBarInstance.getTimeshift() if ts and ts.isTimeshiftEnabled(): if choice =="save_movie": self.InfoBarInstance.save_timeshift_in_movie_dir = True self.InfoBarInstance.save_timeshift_file = True ts.saveTimeshiftFile() del ts self.InfoBarInstance.saveTimeshiftFiles() elif choice == "disable": self.disable() NavigationInstance.instance.RecordTimer.timeChanged(self) start_zap = False self.log(8, "zap canceled by the user, timer disabled") elif choice == "remove": start_zap = False self.afterEvent = AFTEREVENT.NONE NavigationInstance.instance.RecordTimer.removeEntry(self) self.log(8, "zap canceled by the user, timer removed") elif choice == "continue": if self.justplay: self.end = self.begin start_zap = False self.log(8, "zap canceled by the user") if start_zap: if not self.justplay: self.setRecordingPreferredTuner() self.failureCB(True) else: self.log(8, "zapping") NavigationInstance.instance.playService(self.service_ref.ref) self.ts_dialog = self.InfoBarInstance.session.openWithCallback(zapAction, MessageBox, message, simple=True, list=choice, timeout=20)
def createTimer(xml): begin = int(xml.get("begin")) end = int(xml.get("end")) serviceref = ServiceReference(xml.get("serviceref").encode("utf-8")) description = xml.get("description").encode("utf-8") repeated = xml.get("repeated").encode("utf-8") rename_repeat = long(xml.get("rename_repeat") or "1") disabled = long(xml.get("disabled") or "0") justplay = long(xml.get("justplay") or "0") always_zap = long(xml.get("always_zap") or "0") zap_wakeup = str(xml.get("zap_wakeup") or "always") conflict_detection = long(xml.get("conflict_detection") or "1") afterevent = str(xml.get("afterevent") or "nothing") afterevent = { "nothing": AFTEREVENT.NONE, "standby": AFTEREVENT.STANDBY, "deepstandby": AFTEREVENT.DEEPSTANDBY, "auto": AFTEREVENT.AUTO }[afterevent] eit = xml.get("eit") if eit and eit != "None": eit = long(eit) else: eit = None location = xml.get("location") if location and location != "None": location = location.encode("utf-8") else: location = None tags = xml.get("tags") if tags and tags != "None": tags = tags.encode("utf-8").split(' ') else: tags = None descramble = int(xml.get("descramble") or "1") record_ecm = int(xml.get("record_ecm") or "0") isAutoTimer = int(xml.get("isAutoTimer") or "0") name = xml.get("name").encode("utf-8") #filename = xml.get("filename").encode("utf-8") entry = RecordTimerEntry(serviceref, begin, end, name, description, eit, disabled, justplay, afterevent, dirname = location, tags = tags, descramble = descramble, record_ecm = record_ecm, isAutoTimer = isAutoTimer, always_zap = always_zap, zap_wakeup = zap_wakeup, rename_repeat = rename_repeat, conflict_detection = conflict_detection) entry.repeated = int(repeated) flags = xml.get("flags") if flags: entry.flags = set(flags.encode("utf-8").split(' ')) 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 openChoiceActionBeforeZap(self): if self.ts_dialog is None: type = _("record") if self.justplay: type = _("zap") elif self.always_zap: type = _("zap and record") message = _("You must switch to the service %s (%s - '%s')!\n") % (type, self.service_ref.getServiceName(), self.name) if self.repeated: message += _("Attention, this is repeated timer!\n") message += _("Timeshift is running. Select an action.\n") choice = [(_("Zap"), "zap"), (_("Don't zap and disable timer"), "disable"), (_("Don't zap and remove timer"), "remove")] if not self.InfoBarInstance.save_timeshift_file: choice.insert(0, (_("Save timeshift and zap"), "save")) else: message += _("Reminder, you have chosen to save timeshift file.") #if self.justplay or self.always_zap: # choice.insert(2, (_("Don't zap"), "continue")) choice.insert(2, (_("Don't zap"), "continue")) def zapAction(choice): start_zap = True if choice: if choice in ("zap", "save"): self.log(8, "zap to recording service") if choice == "save": ts = self.InfoBarInstance.getTimeshift() if ts and ts.isTimeshiftEnabled(): del ts self.InfoBarInstance.save_timeshift_file = True self.InfoBarInstance.SaveTimeshift() elif choice == "disable": self.disable() NavigationInstance.instance.RecordTimer.timeChanged(self) start_zap = False self.log(8, "zap canceled by the user, timer disabled") elif choice == "remove": start_zap = False self.afterEvent = AFTEREVENT.NONE NavigationInstance.instance.RecordTimer.removeEntry(self) self.log(8, "zap canceled by the user, timer removed") elif choice == "continue": if self.justplay: self.end = self.begin start_zap = False self.log(8, "zap canceled by the user") if start_zap: if not self.justplay: self.setRecordingPreferredTuner() self.failureCB(True) else: self.log(8, "zapping") NavigationInstance.instance.playService(self.service_ref.ref) self.ts_dialog = self.InfoBarInstance.session.openWithCallback(zapAction, MessageBox, message, simple=True, list=choice, timeout=20)
def createTimer(xml): begin = int(xml.get("begin")) end = int(xml.get("end")) serviceref = ServiceReference(xml.get("serviceref").encode("utf-8")) description = xml.get("description").encode("utf-8") repeated = xml.get("repeated").encode("utf-8") rename_repeat = long(xml.get("rename_repeat") or "1") disabled = long(xml.get("disabled") or "0") justplay = long(xml.get("justplay") or "0") always_zap = long(xml.get("always_zap") or "0") pipzap = long(xml.get("pipzap") or "0") conflict_detection = long(xml.get("conflict_detection") or "1") afterevent = str(xml.get("afterevent") or "nothing") afterevent = { "nothing": AFTEREVENT.NONE, "standby": AFTEREVENT.STANDBY, "deepstandby": AFTEREVENT.DEEPSTANDBY, "auto": AFTEREVENT.AUTO }[afterevent] eit = xml.get("eit") if eit and eit != "None": eit = long(eit) else: eit = None location = xml.get("location") if location and location != "None": location = location.encode("utf-8") else: location = None tags = xml.get("tags") if tags and tags != "None": tags = tags.encode("utf-8").split(' ') else: tags = None descramble = int(xml.get("descramble") or "1") record_ecm = int(xml.get("record_ecm") or "0") isAutoTimer = int(xml.get("isAutoTimer") or "0") name = xml.get("name").encode("utf-8") #filename = xml.get("filename").encode("utf-8") entry = RecordTimerEntry(serviceref, begin, end, name, description, eit, disabled, justplay, afterevent, dirname = location, tags = tags, descramble = descramble, record_ecm = record_ecm, isAutoTimer = isAutoTimer, always_zap = always_zap, rename_repeat = rename_repeat, conflict_detection = conflict_detection, pipzap = pipzap) entry.repeated = int(repeated) flags = xml.get("flags") if flags: entry.flags = set(flags.encode("utf-8").split(' ')) 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 createTimer(xml): begin = int(xml.get("begin")) end = int(xml.get("end")) serviceref = ServiceReference(xml.get("serviceref").encode("utf-8")) description = xml.get("description").encode("utf-8") repeated = xml.get("repeated").encode("utf-8") rename_repeat = long(xml.get("rename_repeat") or "1") disabled = long(xml.get("disabled") or "0") justplay = long(xml.get("justplay") or "0") always_zap = long(xml.get("always_zap") or "0") zap_wakeup = str(xml.get("zap_wakeup") or "always") conflict_detection = long(xml.get("conflict_detection") or "1") afterevent = str(xml.get("afterevent") or "nothing") afterevent = { "nothing": AFTEREVENT.NONE, "standby": AFTEREVENT.STANDBY, "deepstandby": AFTEREVENT.DEEPSTANDBY, "auto": AFTEREVENT.AUTO }[afterevent] eit = xml.get("eit") if eit and eit != "None": eit = long(eit) else: eit = None location = xml.get("location") if location and location != "None": location = location.encode("utf-8") else: location = None tags = xml.get("tags") if tags and tags != "None": tags = tags.encode("utf-8").split(' ') else: tags = None descramble = int(xml.get("descramble") or "1") record_ecm = int(xml.get("record_ecm") or "0") name = xml.get("name").encode("utf-8") #filename = xml.get("filename").encode("utf-8") entry = RecordTimerEntry(serviceref, begin, end, name, description, eit, disabled, justplay, afterevent, dirname = location, tags = tags, descramble = descramble, record_ecm = record_ecm, always_zap = always_zap, zap_wakeup = zap_wakeup, rename_repeat = rename_repeat, conflict_detection = conflict_detection) entry.repeated = int(repeated) flags = xml.get("flags") if flags: entry.flags = set(flags.encode("utf-8").split(' ')) 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