"Tyne": [4101, 13], "Wales": [4104, 32], "WestAnglia": [4101, 25], "WestDorset": [4103, 67], "Westcountry": [4101, 6] } schedulelist = [("daily", _("Daily")), ("monday", _("Monday")), ("tuesday", _("Tuesday")), ("wednesday", _("Wednesday")), ("thursday", _("Thursday")), ("friday", _("Friday")), ("saturday", _("Saturday")), ("sunday", _("Sunday"))] config.plugins.SlykEpg7day = ConfigSubsection() cfg = config.plugins.SlykEpg7day cfg.enabled = ConfigEnableDisable(default=False) cfg.wakeup = ConfigClock(default=((7 * 60) + 9) * 60) # 7:00 cfg.epgDescDays = ConfigSelectionNumber(default=3, stepwidth=1, min=1, max=7, wraparound=True) cfg.lamedb = ConfigYesNo(default=False) cfg.rytec = ConfigSelection(default='rytec', choices=[('unique', _('Unique IDs')), ('rytec', _('Match Rytec IDs'))]) cfg.timeshift = ConfigSelectionNumber(default=0, stepwidth=1, min=-7, max=7, wraparound=True) cfg.ukcable = ConfigYesNo(default=False)
def createConfig(self): afterevent = { AFTEREVENT.NONE: "nothing", AFTEREVENT.WAKEUP: "wakeup", AFTEREVENT.WAKEUPTOSTANDBY: "wakeuptostandby", AFTEREVENT.STANDBY: "standby", AFTEREVENT.DEEPSTANDBY: "deepstandby" }[self.timer.afterEvent] 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.timer.timerType] weekday_table = ("mon", "tue", "wed", "thu", "fri", "sat", "sun") time_table = [(1, "1"), (3, "3"), (5, "5"), (10, "10"), (15, "15"), (30, "30"), (45, "45"), (60, "60"), (75, "75"), (90, "90"), (105, "105"), (120, "120"), (135, "135"), (150, "150"), (165, "165"), (180, "180"), (195, "195"), (210, "210"), (225, "225"), (240, "240"), (255, "255"), (270, "270"), (285, "285"), (300, "300")] traffic_table = [(10, "10"), (50, "50"), (100, "100"), (500, "500"), (1000, "1000")] # calculate default values day = [] weekday = 0 for x in (0, 1, 2, 3, 4, 5, 6): day.append(0) if self.timer.repeated: # repeated type = "repeated" if self.timer.repeated == 31: # Mon-Fri repeated = "weekdays" elif self.timer.repeated == 127: # daily repeated = "daily" else: flags = self.timer.repeated repeated = "user" count = 0 for x in (0, 1, 2, 3, 4, 5, 6): if flags == 1: # weekly print "Set to weekday " + str(x) weekday = x if flags & 1 == 1: # set user defined flags day[x] = 1 count += 1 else: day[x] = 0 flags >>= 1 if count == 1: repeated = "weekly" else: # once type = "once" repeated = None weekday = int(strftime("%u", localtime(self.timer.begin))) - 1 day[weekday] = 1 if SystemInfo["DeepstandbySupport"]: shutdownString = _("go to deep standby") else: shutdownString = _("shut down") self.timerentry_timertype = ConfigSelection(choices=[ ("nothing", _("do nothing")), ("wakeup", _("wakeup")), ("wakeuptostandby", _("wakeup to standby")), ("autostandby", _("auto standby")), ("autodeepstandby", _("auto deepstandby")), ("standby", _("go to standby")), ("deepstandby", shutdownString), ("reboot", _("reboot system")), ("restart", _("restart GUI")) ], default=timertype) self.timerentry_afterevent = ConfigSelection(choices=[ ("nothing", _("do nothing")), ("wakeup", _("wakeup")), ("wakeuptostandby", _("wakeup to standby")), ("standby", _("go to standby")), ("deepstandby", shutdownString), ("nothing", _("do nothing")) ], default=afterevent) self.timerentry_type = ConfigSelection(choices=[("once", _("once")), ("repeated", _("repeated"))], default=type) self.timerentry_repeated = ConfigSelection( default=repeated, choices=[("daily", _("daily")), ("weekly", _("weekly")), ("weekdays", _("Mon-Fri")), ("user", _("user defined"))]) self.timerrntry_autosleepdelay = ConfigSelection( choices=time_table, default=self.timer.autosleepdelay) self.timerentry_autosleeprepeat = ConfigSelection( choices=[("once", _("once")), ("repeated", _("repeated"))], default=self.timer.autosleeprepeat) self.timerrntry_autosleepinstandbyonly = ConfigSelection( choices=[("yes", _("only in Standby")), ("no", _("Standard (always)")), ("noquery", _("without Query"))], default=self.timer.autosleepinstandbyonly) self.timerrntry_autosleepwindow = ConfigSelection( choices=[("yes", _("Yes")), ("no", _("No"))], default=self.timer.autosleepwindow) self.timerrntry_autosleepbegin = ConfigClock( default=self.timer.autosleepbegin) self.timerrntry_autosleepend = ConfigClock( default=self.timer.autosleepend) self.timerentry_date = ConfigDateTime(default=self.timer.begin, formatstring=_("%d.%B %Y"), increment=86400) self.timerentry_starttime = ConfigClock(default=self.timer.begin) self.timerentry_endtime = ConfigClock(default=self.timer.end) self.timerentry_showendtime = ConfigSelection( default=(((self.timer.end - self.timer.begin) / 60) > 4), choices=[(True, _("yes")), (False, _("no"))]) self.timerentry_repeatedbegindate = ConfigDateTime( default=self.timer.repeatedbegindate, formatstring=_("%d.%B %Y"), increment=86400) self.timerentry_weekday = ConfigSelection( default=weekday_table[weekday], choices=[("mon", _("Monday")), ("tue", _("Tuesday")), ("wed", _("Wednesday")), ("thu", _("Thursday")), ("fri", _("Friday")), ("sat", _("Saturday")), ("sun", _("Sunday"))]) self.timerentry_day = ConfigSubList() for x in (0, 1, 2, 3, 4, 5, 6): self.timerentry_day.append(ConfigYesNo(default=day[x])) self.timerrntry_showExtended = ConfigSelection( default=(self.timer.nettraffic == "yes" or self.timer.netip == "yes"), choices=[(True, _("yes")), (False, _("no"))]) self.timerrntry_nettraffic = ConfigSelection( choices=[("yes", _("Yes")), ("no", _("No"))], default=self.timer.nettraffic) self.timerrntry_trafficlimit = ConfigSelection( choices=traffic_table, default=self.timer.trafficlimit) self.timerrntry_netip = ConfigSelection(choices=[("yes", _("Yes")), ("no", _("No"))], default=self.timer.netip) self.timerrntry_ipadress = self.timer.ipadress.split(',') self.ipcount = ConfigSelectionNumber(default=len( self.timerrntry_ipadress), stepwidth=1, min=1, max=5) self.ipadressEntry = ConfigSubList() for x in (0, 1, 2, 3, 4, 5): try: self.ipadressEntry.append( ConfigIP(default=[ int(n) for n in self.timerrntry_ipadress[x].split('.') ] or [0, 0, 0, 0])) except: self.ipadressEntry.append(ConfigIP(default=[0, 0, 0, 0]))
# Calculate default begin/end from time import time, localtime, mktime now = localtime() begin = mktime(( now.tm_year, now.tm_mon, now.tm_mday, 07, 30, \ 0, now.tm_wday, now.tm_yday, now.tm_isdst) ) end = mktime(( now.tm_year, now.tm_mon, now.tm_mday, 20, 00, \ 0, now.tm_wday, now.tm_yday, now.tm_isdst) ) #Configuration config.plugins.epgrefresh = ConfigSubsection() config.plugins.epgrefresh.enabled = ConfigYesNo(default=False) config.plugins.epgrefresh.begin = ConfigClock(default=int(begin)) config.plugins.epgrefresh.end = ConfigClock(default=int(end)) config.plugins.epgrefresh.interval_seconds = ConfigNumber(default=120) config.plugins.epgrefresh.delay_standby = ConfigNumber(default=10) config.plugins.epgrefresh.inherit_autotimer = ConfigYesNo(default=False) config.plugins.epgrefresh.afterevent = ConfigYesNo(default=False) config.plugins.epgrefresh.force = ConfigYesNo(default=False) config.plugins.epgrefresh.skipProtectedServices = ConfigSelection( choices=[ ("bg_only", _("Background only")), ("always", _("Foreground also")), ], default="bg_only") config.plugins.epgrefresh.enablemessage = ConfigYesNo(default=True) config.plugins.epgrefresh.wakeup = ConfigYesNo(default=False) config.plugins.epgrefresh.lastscan = ConfigNumber(default=0)
class TimerEntry(Screen, ConfigListScreen): def __init__(self, session, timer, menu_path=""): Screen.__init__(self, session) screentitle = _("Timer entry") menu_path += screentitle if config.usage.show_menupath.value == 'large': title = menu_path self["menu_path_compressed"] = StaticText("") elif config.usage.show_menupath.value == 'small': title = screentitle print 'menu_path:',menu_path self["menu_path_compressed"] = StaticText(menu_path + " >" if not menu_path.endswith(' / ') else menu_path[:-3] + " >" or "") else: title = screentitle self["menu_path_compressed"] = StaticText("") self.setup_title = title Screen.setTitle(self, title) self.timer = timer self.entryDate = None self.entryService = None self["HelpWindow"] = Pixmap() self["HelpWindow"].hide() self["VKeyIcon"] = Boolean(False) self["description"] = Label("") self["oktext"] = Label(_("OK")) self["canceltext"] = Label(_("Cancel")) self["ok"] = Pixmap() self["cancel"] = Pixmap() self.createConfig() self["actions"] = NumberActionMap(["SetupActions", "GlobalActions", "PiPSetupActions", "ColorActions"], { "ok": self.keySelect, "save": self.keyGo, "cancel": self.keyCancel, "volumeUp": self.incrementStart, "volumeDown": self.decrementStart, "size+": self.incrementEnd, "size-": self.decrementEnd, }, -2) self["VirtualKB"] = ActionMap(["VirtualKeyboardActions"], { "showVirtualKeyboard": self.KeyText, }, -2) self["VirtualKB"].setEnabled(False) self.onChangedEntry = [ ] self.list = [] ConfigListScreen.__init__(self, self.list, session = session) self.createSetup("config") if not self.selectionChanged in self["config"].onSelectionChanged: self["config"].onSelectionChanged.append(self.selectionChanged) self.selectionChanged() def createConfig(self): justplay = self.timer.justplay always_zap = self.timer.always_zap pipzap = self.timer.pipzap rename_repeat = self.timer.rename_repeat conflict_detection = self.timer.conflict_detection afterevent = { AFTEREVENT.NONE: "nothing", AFTEREVENT.DEEPSTANDBY: "deepstandby", AFTEREVENT.STANDBY: "standby", AFTEREVENT.AUTO: "auto" }[self.timer.afterEvent] if self.timer.record_ecm and self.timer.descramble: recordingtype = "descrambled+ecm" elif self.timer.record_ecm: recordingtype = "scrambled+ecm" elif self.timer.descramble: recordingtype = "normal" weekday_table = ("mon", "tue", "wed", "thu", "fri", "sat", "sun") # calculate default values day = [] weekday = 0 for x in (0, 1, 2, 3, 4, 5, 6): day.append(0) if self.timer.repeated: # repeated type = "repeated" if self.timer.repeated == 31: # Mon-Fri repeated = "weekdays" elif self.timer.repeated == 127: # daily repeated = "daily" else: flags = self.timer.repeated repeated = "user" count = 0 for x in (0, 1, 2, 3, 4, 5, 6): if flags == 1: # weekly # print "Set to weekday " + str(x) weekday = x if flags & 1 == 1: # set user defined flags day[x] = 1 count += 1 else: day[x] = 0 flags >>= 1 if count == 1: repeated = "weekly" else: # once type = "once" repeated = None weekday = int(strftime("%u", localtime(self.timer.begin))) - 1 day[weekday] = 1 self.timerentry_justplay = ConfigSelection(choices = [ ("zap", _("zap")), ("record", _("record")), ("zap+record", _("zap and record"))], default = {0: "record", 1: "zap", 2: "zap+record"}[justplay + 2*always_zap]) if SystemInfo["DeepstandbySupport"]: shutdownString = _("go to deep standby") else: shutdownString = _("shut down") self.timerentry_afterevent = ConfigSelection(choices = [("nothing", _("do nothing")), ("standby", _("go to standby")), ("deepstandby", shutdownString), ("auto", _("auto"))], default = afterevent) self.timerentry_recordingtype = ConfigSelection(choices = [("normal", _("normal")), ("descrambled+ecm", _("descramble and record ecm")), ("scrambled+ecm", _("don't descramble, record ecm"))], default = recordingtype) self.timerentry_type = ConfigSelection(choices = [("once",_("once")), ("repeated", _("repeated"))], default = type) self.timerentry_name = ConfigText(default = self.timer.name.replace('\xc2\x86', '').replace('\xc2\x87', '').encode("utf-8"), visible_width = 50, fixed_size = False) self.timerentry_description = ConfigText(default = self.timer.description, visible_width = 50, fixed_size = False) self.timerentry_tags = self.timer.tags[:] # if no tags found, make name of event default tag set. if not self.timerentry_tags: tagname = self.timer.name.strip() if tagname: tagname = tagname[0].upper() + tagname[1:].replace(" ", "_") self.timerentry_tags.append(tagname) self.timerentry_tagsset = ConfigSelection(choices = [not self.timerentry_tags and "None" or " ".join(self.timerentry_tags)]) self.timerentry_repeated = ConfigSelection(default = repeated, choices = [("weekly", _("weekly")), ("daily", _("daily")), ("weekdays", _("Mon-Fri")), ("user", _("user defined"))]) self.timerentry_renamerepeat = ConfigYesNo(default = rename_repeat) self.timerentry_pipzap = ConfigYesNo(default = pipzap) self.timerentry_conflictdetection = ConfigYesNo(default = conflict_detection) self.timerentry_date = ConfigDateTime(default = self.timer.begin, formatstring = config.usage.date.full.value, increment = 86400) self.timerentry_starttime = ConfigClock(default = self.timer.begin) self.timerentry_endtime = ConfigClock(default = self.timer.end) self.timerentry_showendtime = ConfigSelection(default = False, choices = [(True, _("yes")), (False, _("no"))]) default = self.timer.dirname or defaultMoviePath() tmp = config.movielist.videodirs.value if default not in tmp: tmp.append(default) self.timerentry_dirname = ConfigSelection(default = default, choices = tmp) self.timerentry_repeatedbegindate = ConfigDateTime(default = self.timer.repeatedbegindate, formatstring = config.usage.date.full.value, increment = 86400) self.timerentry_weekday = ConfigSelection(default = weekday_table[weekday], choices = [("mon",_("Monday")), ("tue", _("Tuesday")), ("wed",_("Wednesday")), ("thu", _("Thursday")), ("fri", _("Friday")), ("sat", _("Saturday")), ("sun", _("Sunday"))]) self.timerentry_day = ConfigSubList() for x in (0, 1, 2, 3, 4, 5, 6): self.timerentry_day.append(ConfigYesNo(default = day[x])) # FIXME some service-chooser needed here servicename = "N/A" try: # no current service available? servicename = str(self.timer.service_ref.getServiceName()) except: pass self.timerentry_service_ref = self.timer.service_ref self.timerentry_service = ConfigSelection([servicename]) def createSetup(self, widget): self.list = [] self.entryName = getConfigListEntry(_("Name"), self.timerentry_name, _("Set the name the recording will get.")) self.list.append(self.entryName) self.entryDescription = getConfigListEntry(_("Description"), self.timerentry_description, _("Set the description of the recording.")) self.list.append(self.entryDescription) self.timerJustplayEntry = getConfigListEntry(_("Timer type"), self.timerentry_justplay, _("Chose between record and ZAP.")) self.list.append(self.timerJustplayEntry) self.timerTypeEntry = getConfigListEntry(_("Repeat type"), self.timerentry_type, _("A repeating timer or just once?")) self.list.append(self.timerTypeEntry) if self.timerentry_type.value == "once": self.frequencyEntry = None else: # repeated self.frequencyEntry = getConfigListEntry(_("Repeats"), self.timerentry_repeated, _("Choose between Daily, Weekly, Weekdays or user defined.")) self.list.append(self.frequencyEntry) self.repeatedbegindateEntry = getConfigListEntry(_("Starting on"), self.timerentry_repeatedbegindate, _("Set the date the timer must start.")) self.list.append(self.repeatedbegindateEntry) if self.timerentry_repeated.value == "daily": pass if self.timerentry_repeated.value == "weekdays": pass if self.timerentry_repeated.value == "weekly": self.list.append(getConfigListEntry(_("Weekday"), self.timerentry_weekday)) if self.timerentry_repeated.value == "user": self.list.append(getConfigListEntry(_("Monday"), self.timerentry_day[0])) self.list.append(getConfigListEntry(_("Tuesday"), self.timerentry_day[1])) self.list.append(getConfigListEntry(_("Wednesday"), self.timerentry_day[2])) self.list.append(getConfigListEntry(_("Thursday"), self.timerentry_day[3])) self.list.append(getConfigListEntry(_("Friday"), self.timerentry_day[4])) self.list.append(getConfigListEntry(_("Saturday"), self.timerentry_day[5])) self.list.append(getConfigListEntry(_("Sunday"), self.timerentry_day[6])) if self.timerentry_justplay.value != "zap": self.list.append(getConfigListEntry(_("Rename name and description for new events"), self.timerentry_renamerepeat)) self.entryDate = getConfigListEntry(_("Date"), self.timerentry_date, _("Set the date the timer must start.")) if self.timerentry_type.value == "once": self.list.append(self.entryDate) self.entryStartTime = getConfigListEntry(_("Start time"), self.timerentry_starttime, _("Set the time the timer must start.")) self.list.append(self.entryStartTime) self.entryShowEndTime = getConfigListEntry(_("Set end time"), self.timerentry_showendtime, _("Set the time the timer must stop.")) if self.timerentry_justplay.value == "zap": if SystemInfo["PIPAvailable"]: self.list.append(getConfigListEntry(_("Use as PiP if possible"), self.timerentry_pipzap)) # self.list.append(self.entryShowEndTime) self.entryEndTime = getConfigListEntry(_("End time"), self.timerentry_endtime, _("Set the time the timer must stop.")) if self.timerentry_justplay.value != "zap" or self.timerentry_showendtime.value: self.list.append(self.entryEndTime) self.conflictDetectionEntry = getConfigListEntry(_("Enable timer conflict detection"), self.timerentry_conflictdetection) self.list.append(self.conflictDetectionEntry) self.channelEntry = getConfigListEntry(_("Channel"), self.timerentry_service, _("Set the channel for this timer.")) self.list.append(self.channelEntry) self.dirname = getConfigListEntry(_("Location"), self.timerentry_dirname, _("Where should the recording be saved?")) self.tagsSet = getConfigListEntry(_("Tags"), self.timerentry_tagsset, _("Choose a tag for easy finding a recording.")) if self.timerentry_justplay.value != "zap": if config.usage.setup_level.index >= 2: # expert+ self.list.append(self.dirname) if getPreferredTagEditor(): self.list.append(self.tagsSet) self.list.append(getConfigListEntry(_("After event"), self.timerentry_afterevent, _("What action is required on completion of the timer? 'Auto' lets the box return to the state it had when the timer started. 'Do nothing', 'Go to standby' and 'Go to deep standby' do ecaxtly that."))) self.list.append(getConfigListEntry(_("Recording type"), self.timerentry_recordingtype, _("Descramble & record ECM' gives the option to descramble afterwards if descrambling on recording failed. 'Don't descramble, record ECM' save a scramble recording that can be descrambled on playback. 'Normal' means descramble the recording and don't record ECM."))) self[widget].list = self.list self[widget].l.setList(self.list) def selectionChanged(self): if self["config"].getCurrent(): if len(self["config"].getCurrent()) > 2 and self["config"].getCurrent()[2]: self["description"].setText(self["config"].getCurrent()[2]) if isinstance(self["config"].getCurrent()[1], ConfigText): if self.has_key("VKeyIcon"): self["VirtualKB"].setEnabled(True) self["VKeyIcon"].boolean = True if self.has_key("HelpWindow"): if self["config"].getCurrent()[1].help_window and self["config"].getCurrent()[1].help_window.instance is not None: helpwindowpos = self["HelpWindow"].getPosition() from enigma import ePoint self["config"].getCurrent()[1].help_window.instance.move(ePoint(helpwindowpos[0],helpwindowpos[1])) else: if self.has_key("VKeyIcon"): self["VirtualKB"].setEnabled(False) self["VKeyIcon"].boolean = False else: if self.has_key("VKeyIcon"): self["VirtualKB"].setEnabled(False) self["VKeyIcon"].boolean = False def createSummary(self): return SetupSummary # for summary: def changedEntry(self): for x in self.onChangedEntry: x() def getCurrentEntry(self): return self["config"].getCurrent() and self["config"].getCurrent()[0] or "" def getCurrentValue(self): return self["config"].getCurrent() and str(self["config"].getCurrent()[1].getText()) or "" def newConfig(self): if self["config"].getCurrent() in (self.timerTypeEntry, self.timerJustplayEntry, self.frequencyEntry, self.entryShowEndTime): self.createSetup("config") def KeyText(self): if self['config'].getCurrent()[0] in (_('Name'), _("Description")): self.session.openWithCallback(self.renameEntryCallback, VirtualKeyBoard, title=self["config"].getCurrent()[2], text = self["config"].getCurrent()[1].value) def keyLeft(self): cur = self["config"].getCurrent() if cur in (self.channelEntry, self.tagsSet): self.keySelect() elif cur in (self.entryName, self.entryDescription): self.renameEntry() else: ConfigListScreen.keyLeft(self) self.newConfig() def keyRight(self): cur = self["config"].getCurrent() if cur in (self.channelEntry, self.tagsSet): self.keySelect() elif cur in (self.entryName, self.entryDescription): self.renameEntry() else: ConfigListScreen.keyRight(self) self.newConfig() def renameEntry(self): cur = self["config"].getCurrent() if cur == self.entryName: title_text = _("Please enter new name:") old_text = self.timerentry_name.value else: title_text = _("Please enter new description:") old_text = self.timerentry_description.value self.session.openWithCallback(self.renameEntryCallback, VirtualKeyBoard, title=title_text, text=old_text) def renameEntryCallback(self, answer): if answer: if self["config"].getCurrent() == self.entryName: self.timerentry_name.value = answer self["config"].invalidate(self.entryName) else: self.timerentry_description.value = answer self["config"].invalidate(self.entryDescription) def handleKeyFileCallback(self, answer): if self["config"].getCurrent() in (self.channelEntry, self.tagsSet): self.keySelect() else: ConfigListScreen.handleKeyFileCallback(self, answer) self.newConfig() def keySelect(self): cur = self["config"].getCurrent() if cur == self.channelEntry: self.session.openWithCallback( self.finishedChannelSelection, ChannelSelection.SimpleChannelSelection, _("Select channel to record from"), currentBouquet=True ) elif config.usage.setup_level.index >= 2 and cur == self.dirname: self.session.openWithCallback( self.pathSelected, MovieLocationBox, _("Select target folder"), self.timerentry_dirname.value, minFree = 100 # We require at least 100MB free space ) elif getPreferredTagEditor() and cur == self.tagsSet: self.session.openWithCallback( self.tagEditFinished, getPreferredTagEditor(), self.timerentry_tags ) else: self.keyGo() def finishedChannelSelection(self, *args): if args: self.timerentry_service_ref = ServiceReference(args[0]) self.timerentry_service.setCurrentText(self.timerentry_service_ref.getServiceName()) self["config"].invalidate(self.channelEntry) def getTimestamp(self, date, mytime): d = localtime(date) dt = datetime(d.tm_year, d.tm_mon, d.tm_mday, mytime[0], mytime[1]) return int(mktime(dt.timetuple())) def getBeginEnd(self): date = self.timerentry_date.value endtime = self.timerentry_endtime.value starttime = self.timerentry_starttime.value begin = self.getTimestamp(date, starttime) end = self.getTimestamp(date, endtime) # if the endtime is less than the starttime, add 1 day. if end < begin: end += 86400 # if the timer type is a Zap and no end is set, set duration to 1 second so time is shown in EPG's. if self.timerentry_justplay.value == "zap": if not self.timerentry_showendtime.value: end = begin + (config.recording.margin_before.value*60) + 1 return begin, end def selectChannelSelector(self, *args): self.session.openWithCallback( self.finishedChannelSelectionCorrection, ChannelSelection.SimpleChannelSelection, _("Select channel to record from") ) def finishedChannelSelectionCorrection(self, *args): if args: self.finishedChannelSelection(*args) self.keyGo() def keyGo(self, result = None): if not self.timerentry_service_ref.isRecordable(): self.session.openWithCallback(self.selectChannelSelector, MessageBox, _("You didn't select a channel to record from."), MessageBox.TYPE_ERROR) return self.timer.name = self.timerentry_name.value self.timer.description = self.timerentry_description.value self.timer.justplay = self.timerentry_justplay.value == "zap" self.timer.always_zap = self.timerentry_justplay.value == "zap+record" self.timer.pipzap = self.timerentry_pipzap.value self.timer.rename_repeat = self.timerentry_renamerepeat.value self.timer.conflict_detection = self.timerentry_conflictdetection.value if self.timerentry_justplay.value == "zap": if not self.timerentry_showendtime.value: self.timerentry_endtime.value = self.timerentry_starttime.value self.timer.resetRepeated() self.timer.afterEvent = { "nothing": AFTEREVENT.NONE, "deepstandby": AFTEREVENT.DEEPSTANDBY, "standby": AFTEREVENT.STANDBY, "auto": AFTEREVENT.AUTO }[self.timerentry_afterevent.value] # There is no point doing anything after a Zap-only timer! # For a start, you can't actually configure anything in the menu, but # leaving it as AUTO means that the code may try to shutdown at Zap time # if the Zap timer woke the box up. # if self.timer.justplay: self.timer.afterEvent = AFTEREVENT.NONE self.timer.descramble = { "normal": True, "descrambled+ecm": True, "scrambled+ecm": False, }[self.timerentry_recordingtype.value] self.timer.record_ecm = { "normal": False, "descrambled+ecm": True, "scrambled+ecm": True, }[self.timerentry_recordingtype.value] self.timer.service_ref = self.timerentry_service_ref self.timer.tags = self.timerentry_tags if self.timer.dirname or self.timerentry_dirname.value != defaultMoviePath(): self.timer.dirname = self.timerentry_dirname.value config.movielist.last_timer_videodir.value = self.timer.dirname config.movielist.last_timer_videodir.save() if self.timerentry_type.value == "once": self.timer.begin, self.timer.end = self.getBeginEnd() if self.timerentry_type.value == "repeated": if self.timerentry_repeated.value == "daily": for x in (0, 1, 2, 3, 4, 5, 6): self.timer.setRepeated(x) if self.timerentry_repeated.value == "weekly": self.timer.setRepeated(self.timerentry_weekday.index) if self.timerentry_repeated.value == "weekdays": for x in (0, 1, 2, 3, 4): self.timer.setRepeated(x) if self.timerentry_repeated.value == "user": for x in (0, 1, 2, 3, 4, 5, 6): if self.timerentry_day[x].value: self.timer.setRepeated(x) self.timer.repeatedbegindate = self.getTimestamp(self.timerentry_repeatedbegindate.value, self.timerentry_starttime.value) if self.timer.repeated: self.timer.begin = self.getTimestamp(self.timerentry_repeatedbegindate.value, self.timerentry_starttime.value) self.timer.end = self.getTimestamp(self.timerentry_repeatedbegindate.value, self.timerentry_endtime.value) else: self.timer.begin = self.getTimestamp(time(), self.timerentry_starttime.value) self.timer.end = self.getTimestamp(time(), self.timerentry_endtime.value) # when a timer end is set before the start, add 1 day if self.timer.end < self.timer.begin: self.timer.end += 86400 if self.timer.eit is not None: event = eEPGCache.getInstance().lookupEventId(self.timer.service_ref.ref, self.timer.eit) if event: n = event.getNumOfLinkageServices() if n > 1: tlist = [] ref = self.session.nav.getCurrentlyPlayingServiceOrGroup() parent = self.timer.service_ref.ref selection = 0 for x in range(n): i = event.getLinkageService(parent, x) if i.toString() == ref.toString(): selection = x tlist.append((i.getName(), i)) self.session.openWithCallback(self.subserviceSelected, ChoiceBox, title=_("Please select a subservice to record..."), list = tlist, selection = selection) return elif n > 0: parent = self.timer.service_ref.ref self.timer.service_ref = ServiceReference(event.getLinkageService(parent, 0)) self.saveTimer() self.close((True, self.timer)) def changeTimerType(self): self.timerentry_justplay.selectNext() self.timerJustplayEntry = getConfigListEntry(_("Timer type"), self.timerentry_justplay) self["config"].invalidate(self.timerJustplayEntry) def incrementStart(self): self.timerentry_starttime.increment() self["config"].invalidate(self.entryStartTime) if self.timerentry_type.value == "once" and self.timerentry_starttime.value == [0, 0]: self.timerentry_date.value += 86400 self["config"].invalidate(self.entryDate) def decrementStart(self): self.timerentry_starttime.decrement() self["config"].invalidate(self.entryStartTime) if self.timerentry_type.value == "once" and self.timerentry_starttime.value == [23, 59]: self.timerentry_date.value -= 86400 self["config"].invalidate(self.entryDate) def incrementEnd(self): if self.entryEndTime is not None: self.timerentry_endtime.increment() self["config"].invalidate(self.entryEndTime) def decrementEnd(self): if self.entryEndTime is not None: self.timerentry_endtime.decrement() self["config"].invalidate(self.entryEndTime) def subserviceSelected(self, service): if not service is None: self.timer.service_ref = ServiceReference(service[1]) self.saveTimer() self.close((True, self.timer)) def saveTimer(self): self.session.nav.RecordTimer.saveTimer() def keyCancel(self): self.close((False,)) def pathSelected(self, res): if res is not None: if config.movielist.videodirs.value != self.timerentry_dirname.choices: self.timerentry_dirname.setChoices(config.movielist.videodirs.value, default=res) self.timerentry_dirname.value = res def tagEditFinished(self, ret): if ret is not None: self.timerentry_tags = ret self.timerentry_tagsset.setChoices([not ret and "None" or " ".join(ret)]) self["config"].invalidate(self.tagsSet)
def createConfig(self): afterevent = { AFTEREVENT.NONE: "nothing", AFTEREVENT.WAKEUPTOSTANDBY: "wakeuptostandby", AFTEREVENT.STANDBY: "standby", AFTEREVENT.DEEPSTANDBY: "deepstandby" }[self.timer.afterEvent] 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.timer.timerType] weekday_table = ("mon", "tue", "wed", "thu", "fri", "sat", "sun") # calculate default values day = [] weekday = 0 for x in (0, 1, 2, 3, 4, 5, 6): day.append(0) if self.timer.repeated: # repeated type = "repeated" if self.timer.repeated == 31: # Mon-Fri repeated = "weekdays" elif self.timer.repeated == 127: # daily repeated = "daily" else: flags = self.timer.repeated repeated = "user" count = 0 for x in (0, 1, 2, 3, 4, 5, 6): if flags == 1: # weekly print "Set to weekday " + str(x) weekday = x if flags & 1 == 1: # set user defined flags day[x] = 1 count += 1 else: day[x] = 0 flags >>= 1 if count == 1: repeated = "weekly" else: # once type = "once" repeated = None weekday = int(strftime("%u", localtime(self.timer.begin))) - 1 day[weekday] = 1 autosleepinstandbyonly = self.timer.autosleepinstandbyonly autosleepdelay = self.timer.autosleepdelay autosleeprepeat = self.timer.autosleeprepeat if SystemInfo["DeepstandbySupport"]: shutdownString = _("go to deep standby") else: shutdownString = _("shut down") self.timerentry_timertype = ConfigSelection(choices = [("wakeup", _("wakeup")),("wakeuptostandby", _("wakeup to standby")), ("autostandby", _("auto standby")), ("autodeepstandby", _("auto deepstandby")), ("standby", _("go to standby")), ("deepstandby", shutdownString), ("reboot", _("reboot system")), ("restart", _("restart GUI"))], default = timertype) self.timerentry_afterevent = ConfigSelection(choices = [("nothing", _("do nothing")), ("wakeuptostandby", _("wakeup to standby")), ("standby", _("go to standby")), ("deepstandby", shutdownString), ("nothing", _("do nothing"))], default = afterevent) self.timerentry_type = ConfigSelection(choices = [("once",_("once")), ("repeated", _("repeated"))], default = type) self.timerentry_repeated = ConfigSelection(default = repeated, choices = [("daily", _("daily")), ("weekly", _("weekly")), ("weekdays", _("Mon-Fri")), ("user", _("user defined"))]) self.timerrntry_autosleepdelay = ConfigInteger(default=autosleepdelay, limits = (10, 300)) self.timerentry_autosleeprepeat = ConfigSelection(choices = [("once",_("once")), ("repeated", _("repeated"))], default = autosleeprepeat) self.timerrntry_autosleepinstandbyonly = ConfigSelection(choices = [("yes",_("Yes")), ("no", _("No"))],default=autosleepinstandbyonly) self.timerentry_date = ConfigDateTime(default = self.timer.begin, formatstring = _("%d.%B %Y"), increment = 86400) self.timerentry_starttime = ConfigClock(default = self.timer.begin) self.timerentry_endtime = ConfigClock(default = self.timer.end) self.timerentry_showendtime = ConfigSelection(default = (((self.timer.end - self.timer.begin) /60 ) > 1), choices = [(True, _("yes")), (False, _("no"))]) self.timerentry_repeatedbegindate = ConfigDateTime(default = self.timer.repeatedbegindate, formatstring = _("%d.%B %Y"), increment = 86400) self.timerentry_weekday = ConfigSelection(default = weekday_table[weekday], choices = [("mon",_("Monday")), ("tue", _("Tuesday")), ("wed",_("Wednesday")), ("thu", _("Thursday")), ("fri", _("Friday")), ("sat", _("Saturday")), ("sun", _("Sunday"))]) self.timerentry_day = ConfigSubList() for x in (0, 1, 2, 3, 4, 5, 6): self.timerentry_day.append(ConfigYesNo(default = day[x]))
class TimerEntry(Screen, ConfigListScreen): def __init__(self, session, timer): Screen.__init__(self, session) self.timer = timer self.entryDate = None self.entryService = None self["oktext"] = Label(_("OK")) self["canceltext"] = Label(_("Cancel")) self["ok"] = Pixmap() self["cancel"] = Pixmap() self["key_yellow"] = Label(_("Timer type")) self["key_blue"] = Label() self.createConfig() self["actions"] = NumberActionMap(["SetupActions", "GlobalActions", "PiPSetupActions", "ColorActions"], { "ok": self.keySelect, "save": self.keyGo, "cancel": self.keyCancel, "volumeUp": self.incrementStart, "volumeDown": self.decrementStart, "size+": self.incrementEnd, "size-": self.decrementEnd, "yellow": self.changeTimerType, "blue": self.changeZapWakeupType }, -2) self.list = [] ConfigListScreen.__init__(self, self.list, session = session) self.setTitle(_("Timer entry")) self.createSetup("config") def createConfig(self): justplay = self.timer.justplay always_zap = self.timer.always_zap zap_wakeup = self.timer.zap_wakeup rename_repeat = self.timer.rename_repeat afterevent = { AFTEREVENT.NONE: "nothing", AFTEREVENT.DEEPSTANDBY: "deepstandby", AFTEREVENT.STANDBY: "standby", AFTEREVENT.AUTO: "auto" }[self.timer.afterEvent] if self.timer.record_ecm and self.timer.descramble: recordingtype = "descrambled+ecm" elif self.timer.record_ecm: recordingtype = "scrambled+ecm" elif self.timer.descramble: recordingtype = "normal" weekday_table = ("mon", "tue", "wed", "thu", "fri", "sat", "sun") # calculate default values day = [] weekday = 0 for x in (0, 1, 2, 3, 4, 5, 6): day.append(0) if self.timer.repeated: # repeated type = "repeated" if (self.timer.repeated == 31): # Mon-Fri repeated = "weekdays" elif (self.timer.repeated == 127): # daily repeated = "daily" else: flags = self.timer.repeated repeated = "user" count = 0 for x in (0, 1, 2, 3, 4, 5, 6): if flags == 1: # weekly print "Set to weekday " + str(x) weekday = x if flags & 1 == 1: # set user defined flags day[x] = 1 count += 1 else: day[x] = 0 flags = flags >> 1 if count == 1: repeated = "weekly" else: # once type = "once" repeated = None weekday = int(strftime("%u", localtime(self.timer.begin))) - 1 day[weekday] = 1 self.timerentry_justplay = ConfigSelection(choices = [ ("zap", _("zap")), ("record", _("record")), ("zap+record", _("zap and record"))], default = {0: "record", 1: "zap", 2: "zap+record"}[justplay + 2*always_zap]) if SystemInfo["DeepstandbySupport"]: shutdownString = _("go to deep standby") choicelist = [("always", _("always")), ("from_standby", _("only from standby")), ("from_deep_standby", _("only from deep standby")), ("never", _("never"))] else: shutdownString = _("shut down") choicelist = [("always", _("always")), ("never", _("never"))] self.timerentry_zapwakeup = ConfigSelection(choices = choicelist, default = zap_wakeup) self.timerentry_afterevent = ConfigSelection(choices = [("nothing", _("do nothing")), ("standby", _("go to standby")), ("deepstandby", shutdownString), ("auto", _("auto"))], default = afterevent) self.timerentry_recordingtype = ConfigSelection(choices = [("normal", _("normal")), ("descrambled+ecm", _("descramble and record ecm")), ("scrambled+ecm", _("don't descramble, record ecm"))], default = recordingtype) self.timerentry_type = ConfigSelection(choices = [("once",_("once")), ("repeated", _("repeated"))], default = type) self.timerentry_name = ConfigText(default = self.timer.name, visible_width = 50, fixed_size = False) self.timerentry_description = ConfigText(default = self.timer.description, visible_width = 50, fixed_size = False) self.timerentry_tags = self.timer.tags[:] self.timerentry_tagsset = ConfigSelection(choices = [not self.timerentry_tags and "None" or " ".join(self.timerentry_tags)]) self.timerentry_repeated = ConfigSelection(default = repeated, choices = [("weekly", _("weekly")), ("daily", _("daily")), ("weekdays", _("Mon-Fri")), ("user", _("user defined"))]) self.timerentry_renamerepeat = ConfigYesNo(default = rename_repeat) self.timerentry_date = ConfigDateTime(default = self.timer.begin, formatstring = _("%d.%B %Y"), increment = 86400) self.timerentry_starttime = ConfigClock(default = self.timer.begin) self.timerentry_endtime = ConfigClock(default = self.timer.end) self.timerentry_showendtime = ConfigSelection(default = ((self.timer.end - self.timer.begin) > 4), choices = [(True, _("yes")), (False, _("no"))]) default = self.timer.dirname or defaultMoviePath() tmp = config.movielist.videodirs.value if default not in tmp: tmp.append(default) self.timerentry_dirname = ConfigSelection(default = default, choices = tmp) self.timerentry_repeatedbegindate = ConfigDateTime(default = self.timer.repeatedbegindate, formatstring = _("%d.%B %Y"), increment = 86400) self.timerentry_weekday = ConfigSelection(default = weekday_table[weekday], choices = [("mon",_("Monday")), ("tue", _("Tuesday")), ("wed",_("Wednesday")), ("thu", _("Thursday")), ("fri", _("Friday")), ("sat", _("Saturday")), ("sun", _("Sunday"))]) self.timerentry_day = ConfigSubList() for x in (0, 1, 2, 3, 4, 5, 6): self.timerentry_day.append(ConfigYesNo(default = day[x])) # FIXME some service-chooser needed here servicename = "N/A" try: # no current service available? servicename = str(self.timer.service_ref.getServiceName()) except: pass self.timerentry_service_ref = self.timer.service_ref self.timerentry_service = ConfigSelection([servicename]) def createSetup(self, widget): self.list = [] self.entryName = getConfigListEntry(_("Name"), self.timerentry_name) self.list.append(self.entryName) self.entryDescription = getConfigListEntry(_("Description"), self.timerentry_description) self.list.append(self.entryDescription) self.timerJustplayEntry = getConfigListEntry(_("Timer type"), self.timerentry_justplay) self.list.append(self.timerJustplayEntry) self.timerTypeEntry = getConfigListEntry(_("Repeat type"), self.timerentry_type) self.list.append(self.timerTypeEntry) if self.timerentry_type.value == "once": self.frequencyEntry = None else: # repeated self.frequencyEntry = getConfigListEntry(_("Repeats"), self.timerentry_repeated) self.list.append(self.frequencyEntry) self.repeatedbegindateEntry = getConfigListEntry(_("Starting on"), self.timerentry_repeatedbegindate) self.list.append(self.repeatedbegindateEntry) if self.timerentry_repeated.value == "daily": pass if self.timerentry_repeated.value == "weekdays": pass if self.timerentry_repeated.value == "weekly": self.list.append(getConfigListEntry(_("Weekday"), self.timerentry_weekday)) if self.timerentry_repeated.value == "user": self.list.append(getConfigListEntry(_("Monday"), self.timerentry_day[0])) self.list.append(getConfigListEntry(_("Tuesday"), self.timerentry_day[1])) self.list.append(getConfigListEntry(_("Wednesday"), self.timerentry_day[2])) self.list.append(getConfigListEntry(_("Thursday"), self.timerentry_day[3])) self.list.append(getConfigListEntry(_("Friday"), self.timerentry_day[4])) self.list.append(getConfigListEntry(_("Saturday"), self.timerentry_day[5])) self.list.append(getConfigListEntry(_("Sunday"), self.timerentry_day[6])) if self.timerentry_justplay.value != "zap": self.list.append(getConfigListEntry(_("Rename name and description for new events"), self.timerentry_renamerepeat)) self.entryDate = getConfigListEntry(_("Date"), self.timerentry_date) if self.timerentry_type.value == "once": self.list.append(self.entryDate) self.entryStartTime = getConfigListEntry(_("Start time"), self.timerentry_starttime) self.list.append(self.entryStartTime) self.entryShowEndTime = getConfigListEntry(_("Set end time"), self.timerentry_showendtime) self.entryZapWakeup = getConfigListEntry(_("Wakeup receiver for start timer"), self.timerentry_zapwakeup) if self.timerentry_justplay.value == "zap": self.list.append(self.entryZapWakeup) self.list.append(self.entryShowEndTime) self["key_blue"].setText(_("Wakeup type")) else: self["key_blue"].setText("") self.entryEndTime = getConfigListEntry(_("End time"), self.timerentry_endtime) if self.timerentry_justplay.value != "zap" or self.timerentry_showendtime.value: self.list.append(self.entryEndTime) self.channelEntry = getConfigListEntry(_("Channel"), self.timerentry_service) self.list.append(self.channelEntry) self.dirname = getConfigListEntry(_("Location"), self.timerentry_dirname) self.tagsSet = getConfigListEntry(_("Tags"), self.timerentry_tagsset) if self.timerentry_justplay.value != "zap": if config.usage.setup_level.index >= 2: # expert+ self.list.append(self.dirname) if getPreferredTagEditor(): self.list.append(self.tagsSet) self.list.append(getConfigListEntry(_("After event"), self.timerentry_afterevent)) self.list.append(getConfigListEntry(_("Recording type"), self.timerentry_recordingtype)) self[widget].list = self.list self[widget].l.setList(self.list) def newConfig(self): print "newConfig", self["config"].getCurrent() if self["config"].getCurrent() in (self.timerTypeEntry, self.timerJustplayEntry, self.frequencyEntry, self.entryShowEndTime): self.createSetup("config") def keyLeft(self): cur = self["config"].getCurrent() if cur in (self.channelEntry, self.tagsSet): self.keySelect() elif cur in (self.entryName, self.entryDescription): self.renameEntry() else: ConfigListScreen.keyLeft(self) self.newConfig() def keyRight(self): cur = self["config"].getCurrent() if cur in (self.channelEntry, self.tagsSet): self.keySelect() elif cur in (self.entryName, self.entryDescription): self.renameEntry() else: ConfigListScreen.keyRight(self) self.newConfig() def renameEntry(self): cur = self["config"].getCurrent() if cur == self.entryName: title_text = _("Please enter new name:") old_text = self.timerentry_name.value else: title_text = _("Please enter new description:") old_text = self.timerentry_description.value self.session.openWithCallback(self.renameEntryCallback, VirtualKeyBoard, title=title_text, text=old_text) def renameEntryCallback(self, answer): if answer: cur = self["config"].getCurrent() if cur == self.entryName: self.timerentry_name.value = answer self["config"].invalidate(self.entryName) else: self.timerentry_description.value = answer self["config"].invalidate(self.entryDescription) def handleKeyFileCallback(self, answer): if self["config"].getCurrent() in (self.channelEntry, self.tagsSet): self.keySelect() else: ConfigListScreen.handleKeyFileCallback(self, answer) self.newConfig() def openMovieLocationBox(self, answer=""): self.session.openWithCallback( self.pathSelected, MovieLocationBox, _("Select target folder"), self.timerentry_dirname.value, filename = answer, minFree = 100 # We require at least 100MB free space ) def keySelect(self): cur = self["config"].getCurrent() if cur == self.channelEntry: self.session.openWithCallback( self.finishedChannelSelection, ChannelSelection.SimpleChannelSelection, _("Select channel to record from"), currentBouquet=True ) elif config.usage.setup_level.index >= 2 and cur == self.dirname: menu = [(_("Open select location"), "empty")] if self.timerentry_type.value == "repeated" and self.timerentry_name.value: menu.append((_("Open select location as timer name"), "timername")) if len(menu) == 1: self.openMovieLocationBox() elif len(menu) == 2: text = _("Select action") def selectAction(choice): if choice: if choice[1] == "timername": self.openMovieLocationBox(self.timerentry_name.value) elif choice[1] == "empty": self.openMovieLocationBox() self.session.openWithCallback(selectAction, ChoiceBox, title=text, list=menu) elif getPreferredTagEditor() and cur == self.tagsSet: self.session.openWithCallback( self.tagEditFinished, getPreferredTagEditor(), self.timerentry_tags ) else: self.keyGo() def finishedChannelSelection(self, *args): if args: self.timerentry_service_ref = ServiceReference(args[0]) self.timerentry_service.setCurrentText(self.timerentry_service_ref.getServiceName()) self["config"].invalidate(self.channelEntry) def getTimestamp(self, date, mytime): d = localtime(date) dt = datetime(d.tm_year, d.tm_mon, d.tm_mday, mytime[0], mytime[1]) return int(mktime(dt.timetuple())) def getBeginEnd(self): date = self.timerentry_date.value endtime = self.timerentry_endtime.value starttime = self.timerentry_starttime.value begin = self.getTimestamp(date, starttime) end = self.getTimestamp(date, endtime) # if the endtime is less than the starttime, add 1 day. if end < begin: end += 86400 return begin, end def selectChannelSelector(self, *args): self.session.openWithCallback( self.finishedChannelSelectionCorrection, ChannelSelection.SimpleChannelSelection, _("Select channel to record from") ) def finishedChannelSelectionCorrection(self, *args): if args: self.finishedChannelSelection(*args) self.keyGo() def keyGo(self, result = None): if not self.timerentry_service_ref.isRecordable(): self.session.openWithCallback(self.selectChannelSelector, MessageBox, _("You didn't select a channel to record from."), MessageBox.TYPE_ERROR) return self.timer.name = self.timerentry_name.value self.timer.description = self.timerentry_description.value self.timer.justplay = self.timerentry_justplay.value == "zap" self.timer.always_zap = self.timerentry_justplay.value == "zap+record" self.timer.zap_wakeup = self.timerentry_zapwakeup.value self.timer.rename_repeat = self.timerentry_renamerepeat.value if self.timerentry_justplay.value == "zap": if not self.timerentry_showendtime.value: self.timerentry_endtime.value = self.timerentry_starttime.value self.timerentry_afterevent.value = "nothing" self.timer.resetRepeated() self.timer.afterEvent = { "nothing": AFTEREVENT.NONE, "deepstandby": AFTEREVENT.DEEPSTANDBY, "standby": AFTEREVENT.STANDBY, "auto": AFTEREVENT.AUTO }[self.timerentry_afterevent.value] self.timer.descramble = { "normal": True, "descrambled+ecm": True, "scrambled+ecm": False, }[self.timerentry_recordingtype.value] self.timer.record_ecm = { "normal": False, "descrambled+ecm": True, "scrambled+ecm": True, }[self.timerentry_recordingtype.value] self.timer.service_ref = self.timerentry_service_ref self.timer.tags = self.timerentry_tags if self.timer.dirname or self.timerentry_dirname.value != defaultMoviePath(): self.timer.dirname = self.timerentry_dirname.value config.movielist.last_timer_videodir.value = self.timer.dirname config.movielist.last_timer_videodir.save() if self.timerentry_type.value == "once": self.timer.begin, self.timer.end = self.getBeginEnd() if self.timerentry_type.value == "repeated": if self.timerentry_repeated.value == "daily": for x in (0, 1, 2, 3, 4, 5, 6): self.timer.setRepeated(x) if self.timerentry_repeated.value == "weekly": self.timer.setRepeated(self.timerentry_weekday.index) if self.timerentry_repeated.value == "weekdays": for x in (0, 1, 2, 3, 4): self.timer.setRepeated(x) if self.timerentry_repeated.value == "user": for x in (0, 1, 2, 3, 4, 5, 6): if self.timerentry_day[x].value: self.timer.setRepeated(x) self.timer.repeatedbegindate = self.getTimestamp(self.timerentry_repeatedbegindate.value, self.timerentry_starttime.value) if self.timer.repeated: self.timer.begin = self.getTimestamp(self.timerentry_repeatedbegindate.value, self.timerentry_starttime.value) self.timer.end = self.getTimestamp(self.timerentry_repeatedbegindate.value, self.timerentry_endtime.value) else: self.timer.begin = self.getTimestamp(time.time(), self.timerentry_starttime.value) self.timer.end = self.getTimestamp(time.time(), self.timerentry_endtime.value) # when a timer end is set before the start, add 1 day if self.timer.end < self.timer.begin: self.timer.end += 86400 if self.timer.eit is not None: event = eEPGCache.getInstance().lookupEventId(self.timer.service_ref.ref, self.timer.eit) if event: n = event.getNumOfLinkageServices() if n > 1: tlist = [] ref = self.session.nav.getCurrentlyPlayingServiceOrGroup() parent = self.timer.service_ref.ref selection = 0 for x in range(n): i = event.getLinkageService(parent, x) if i.toString() == ref.toString(): selection = x tlist.append((i.getName(), i)) self.session.openWithCallback(self.subserviceSelected, ChoiceBox, title=_("Please select a subservice to record..."), list = tlist, selection = selection) return elif n > 0: parent = self.timer.service_ref.ref self.timer.service_ref = ServiceReference(event.getLinkageService(parent, 0)) self.saveTimer() self.close((True, self.timer)) def changeTimerType(self): self.timerentry_justplay.selectNext() self.timerJustplayEntry = getConfigListEntry(_("Timer type"), self.timerentry_justplay) self["config"].invalidate(self.timerJustplayEntry) self.createSetup("config") def changeZapWakeupType(self): if self.timerentry_justplay.value == "zap": self.timerentry_zapwakeup.selectNext() self["config"].invalidate(self.entryZapWakeup) def incrementStart(self): self.timerentry_starttime.increment() self["config"].invalidate(self.entryStartTime) if self.timerentry_type.value == "once" and self.timerentry_starttime.value == [0, 0]: self.timerentry_date.value = self.timerentry_date.value + 86400 self["config"].invalidate(self.entryDate) def decrementStart(self): self.timerentry_starttime.decrement() self["config"].invalidate(self.entryStartTime) if self.timerentry_type.value == "once" and self.timerentry_starttime.value == [23, 59]: self.timerentry_date.value = self.timerentry_date.value - 86400 self["config"].invalidate(self.entryDate) def incrementEnd(self): if self.entryEndTime is not None: self.timerentry_endtime.increment() self["config"].invalidate(self.entryEndTime) def decrementEnd(self): if self.entryEndTime is not None: self.timerentry_endtime.decrement() self["config"].invalidate(self.entryEndTime) def subserviceSelected(self, service): if not service is None: self.timer.service_ref = ServiceReference(service[1]) self.saveTimer() self.close((True, self.timer)) def saveTimer(self): self.session.nav.RecordTimer.saveTimer() def keyCancel(self): self.close((False,)) def pathSelected(self, res): if res is not None: if config.movielist.videodirs.value != self.timerentry_dirname.choices: self.timerentry_dirname.setChoices(config.movielist.videodirs.value, default=res) self.timerentry_dirname.value = res def tagEditFinished(self, ret): if ret is not None: self.timerentry_tags = ret self.timerentry_tagsset.setChoices([not ret and "None" or " ".join(ret)]) self["config"].invalidate(self.tagsSet)
from EPGRefreshConfiguration import EPGRefreshConfiguration from EPGRefreshService import EPGRefreshService _session = None # Plugins from Components.PluginComponent import plugins from Plugins.Plugin import PluginDescriptor # Calculate default begin/end from time import time, localtime, mktime #Configuration config.plugins.epgrefresh = ConfigSubsection() config.plugins.epgrefresh.enabled = ConfigYesNo(default = False) config.plugins.epgrefresh.begin = ConfigClock(default = ((20*60) + 15) * 60) config.plugins.epgrefresh.end = ConfigClock(default = ((6*60) + 30) * 60) config.plugins.epgrefresh.interval_seconds = ConfigNumber(default = 120) config.plugins.epgrefresh.delay_standby = ConfigNumber(default = 10) config.plugins.epgrefresh.inherit_autotimer = ConfigYesNo(default = False) config.plugins.epgrefresh.afterevent = ConfigYesNo(default = False) config.plugins.epgrefresh.force = ConfigYesNo(default = False) config.plugins.epgrefresh.enablemessage = ConfigYesNo(default = True) config.plugins.epgrefresh.wakeup = ConfigYesNo(default = False) config.plugins.epgrefresh.start_on_mainmenu = ConfigYesNo(default = False) config.plugins.epgrefresh.stop_on_mainmenu = ConfigYesNo(default = True) config.plugins.epgrefresh.lastscan = ConfigNumber(default = 0) config.plugins.epgrefresh.timeout_shutdown = ConfigInteger(default = 2, limits= (2, 30)) config.plugins.epgrefresh.parse_autotimer = ConfigYesNo(default = False) config.plugins.epgrefresh.erase = ConfigYesNo(default = False)
class TimerEntry(Screen, ConfigListScreen, HelpableScreen): def __init__(self, session, timer): Screen.__init__(self, session) HelpableScreen.__init__(self) self.setup_title = _("Timer entry") self.timer = timer self.entryDate = None self.entryService = None self["HelpWindow"] = Pixmap() self["HelpWindow"].hide() self["VKeyIcon"] = Pixmap() self["description"] = Label("") self["key_red"] = Label(_("Cancel")) self["key_green"] = Label(_("OK")) self["key_yellow"] = Label() self["key_blue"] = Label() self.createConfig() self["actions"] = HelpableNumberActionMap(self, ["SetupActions", "GlobalActions", "PiPSetupActions", "ColorActions"], { "ok": (self.keySelect, _("Save the timer and exit")), "save": (self.keyGo, "Save the timer and exit"), "cancel": (self.keyCancel, "Cancel creation of the timer and exit"), "volumeUp": (self.incrementStart, _("Increment start time")), "volumeDown": (self.decrementStart, _("Decrement start time")), "size+": (self.incrementEnd, _("Increment end time")), "size-": (self.decrementEnd, _("Decrement end time")) }, -2) self["VirtualKB"] = ActionMap(["VirtualKeyboardActions"], { "showVirtualKeyboard": self.KeyText, }, -2) self["VirtualKB"].setEnabled(False) self.onChangedEntry = [] self.list = [] ConfigListScreen.__init__(self, self.list, session=session) self.createSetup("config") self.onLayoutFinish.append(self.layoutFinished) if self.selectionChanged not in self["config"].onSelectionChanged: self["config"].onSelectionChanged.append(self.selectionChanged) self.selectionChanged() def createConfig(self): justplay = self.timer.justplay always_zap = self.timer.always_zap rename_repeat = self.timer.rename_repeat afterevent = { AFTEREVENT.NONE: "nothing", AFTEREVENT.DEEPSTANDBY: "deepstandby", AFTEREVENT.STANDBY: "standby", AFTEREVENT.AUTO: "auto" }[self.timer.afterEvent] if self.timer.record_ecm and self.timer.descramble: recordingtype = "descrambled+ecm" elif self.timer.record_ecm: recordingtype = "scrambled+ecm" elif self.timer.descramble: recordingtype = "normal" weekday_table = ("mon", "tue", "wed", "thu", "fri", "sat", "sun") # calculate default values day = [] weekday = 0 for x in (0, 1, 2, 3, 4, 5, 6): day.append(0) if self.timer.repeated: # repeated repeat_type = "repeated" if self.timer.repeated == 31: # Mon-Fri repeated = "weekdays" elif self.timer.repeated == 127: # daily repeated = "daily" else: flags = self.timer.repeated repeated = "user" count = 0 for x in (0, 1, 2, 3, 4, 5, 6): if flags == 1: # weekly # print "Set to weekday " + str(x) weekday = x if flags & 1 == 1: # set user defined flags day[x] = 1 count += 1 else: day[x] = 0 flags >>= 1 if count == 1: repeated = "weekly" else: # once repeat_type = "once" repeated = None weekday = int(strftime("%u", localtime(self.timer.begin))) - 1 day[weekday] = 1 self.timerentry_justplay = ConfigSelection( choices=[ ("zap", _("zap")), ("record", _("record")), ("zap+record", _("zap and record")) ], default={ 0: "record", 1: "zap", 2: "zap+record" }[justplay + 2 * always_zap] ) if SystemInfo["DeepstandbySupport"]: shutdownString = _("go to deep standby") else: shutdownString = _("shut down") self.timerentry_afterevent = ConfigSelection(choices=[ ("nothing", _("do nothing")), ("standby", _("go to standby")), ("deepstandby", shutdownString), ("auto", _("auto")) ], default=afterevent) self.timerentry_recordingtype = ConfigSelection(choices=[ ("normal", _("normal")), ("descrambled+ecm", _("descramble and record ecm")), ("scrambled+ecm", _("don't descramble, record ecm")) ], default=recordingtype) self.timerentry_type = ConfigSelection(choices=[ ("once", _("once")), ("repeated", _("repeated")) ], default=repeat_type) self.timerentry_name = ConfigText(default=self.timer.name.replace('\xc2\x86', '').replace('\xc2\x87', '').encode("utf-8"), visible_width=50, fixed_size=False) self.timerentry_description = ConfigText(default=self.timer.description, visible_width=50, fixed_size=False) self.timerentry_tags = self.timer.tags[:] # if no tags found, make name of event default tag set. if not self.timerentry_tags: tagname = self.timer.name.strip() if tagname: tagname = tagname[0].upper() + tagname[1:].replace(" ", "_") self.timerentry_tags.append(tagname) self.timerentry_tagsset = ConfigSelection(choices=[not self.timerentry_tags and "None" or " ".join(self.timerentry_tags)]) self.timerentry_repeated = ConfigSelection(choices=[ ("weekly", _("weekly")), ("daily", _("daily")), ("weekdays", _("Mon-Fri")), ("user", _("user defined")) ], default=repeated) self.timerentry_renamerepeat = ConfigYesNo(default=rename_repeat) self.timerentry_date = ConfigDateTime(default=self.timer.begin, formatstring=_("%d %B %Y"), increment=86400) self.timerentry_starttime = ConfigClock(default=self.timer.begin) self.timerentry_endtime = ConfigClock(default=self.timer.end) self.timerentry_showendtime = ConfigSelection(default=((self.timer.end - self.timer.begin) > 4), choices=[(True, _("yes")), (False, _("no"))]) default = self.timer.dirname or defaultMoviePath() tmp = config.movielist.videodirs.value if default not in tmp: tmp.append(default) self.timerentry_dirname = ConfigSelection(default=default, choices=tmp) self.timerentry_repeatedbegindate = ConfigDateTime(default=self.timer.repeatedbegindate, formatstring=_("%d.%B %Y"), increment=86400) self.timerentry_weekday = ConfigSelection(default=weekday_table[weekday], choices=[ ("mon", _("Monday")), ("tue", _("Tuesday")), ("wed", _("Wednesday")), ("thu", _("Thursday")), ("fri", _("Friday")), ("sat", _("Saturday")), ("sun", _("Sunday")) ]) self.timerentry_day = ConfigSubList() for x in (0, 1, 2, 3, 4, 5, 6): self.timerentry_day.append(ConfigYesNo(default=day[x])) # FIXME some service-chooser needed here servicename = "N/A" try: # no current service available? servicename = str(self.timer.service_ref.getServiceName()) except: pass self.timerentry_service_ref = self.timer.service_ref self.timerentry_service = ConfigSelection([servicename]) def createSetup(self, widget): self.list = [] self.entryName = getConfigListEntry(_("Name"), self.timerentry_name, _("The name the recording will get.")) self.list.append(self.entryName) self.entryDescription = getConfigListEntry(_("Description"), self.timerentry_description, _("The description of the recording.")) self.list.append(self.entryDescription) self.timerJustplayEntry = getConfigListEntry(_("Timer type"), self.timerentry_justplay, _("Choose between record and ZAP.")) self.list.append(self.timerJustplayEntry) self.timerTypeEntry = getConfigListEntry(_("Repeat type"), self.timerentry_type, _("A repeating timer or just once?")) self.list.append(self.timerTypeEntry) if self.timerentry_type.value == "once": self.frequencyEntry = None else: # repeated self.frequencyEntry = getConfigListEntry(_("Repeats"), self.timerentry_repeated, _("The type of repetition required: daily, weekly on a specified day, on weekdays (Mon-Fri), or regularly on specified days.")) self.list.append(self.frequencyEntry) self.repeatedbegindateEntry = getConfigListEntry(_("Starting on"), self.timerentry_repeatedbegindate, _("The timer becomes active (but doesn't necessarily run) on this date.")) self.list.append(self.repeatedbegindateEntry) if self.timerentry_repeated.value == "daily": pass if self.timerentry_repeated.value == "weekdays": pass if self.timerentry_repeated.value == "weekly": self.list.append(getConfigListEntry(_("Weekday"), self.timerentry_weekday, _("The day of the week the timer runs."))) if self.timerentry_repeated.value == "user": self.list.append(getConfigListEntry(_("Monday"), self.timerentry_day[0], _("Enable/disable the timer on Mondays."))) self.list.append(getConfigListEntry(_("Tuesday"), self.timerentry_day[1], _("Enable/disable the timer on Tuesdays."))) self.list.append(getConfigListEntry(_("Wednesday"), self.timerentry_day[2], _("Enable/disable the timer on Wednesdays."))) self.list.append(getConfigListEntry(_("Thursday"), self.timerentry_day[3], _("Enable/disable the timer on Thursdays."))) self.list.append(getConfigListEntry(_("Friday"), self.timerentry_day[4], _("Enable/disable the timer on Fridays."))) self.list.append(getConfigListEntry(_("Saturday"), self.timerentry_day[5], _("Enable/disable the timer on Saturdays."))) self.list.append(getConfigListEntry(_("Sunday"), self.timerentry_day[6], _("Enable/disable the timer on Sundays."))) if self.timerentry_justplay.value != "zap": self.list.append(getConfigListEntry(_("Generate name and description for new events"), self.timerentry_renamerepeat, _("Generate a new name and description from the EPG for each run of the timer."))) self.entryDate = getConfigListEntry(_("Date"), self.timerentry_date, _("The date the timer starts.")) if self.timerentry_type.value == "once": self.list.append(self.entryDate) self.entryStartTime = getConfigListEntry(_("Start time"), self.timerentry_starttime, _("The time the timer starts.")) self.list.append(self.entryStartTime) self.entryShowEndTime = getConfigListEntry(_("Set end time"), self.timerentry_showendtime, _("Set the time the ZAP timer completes and performs any \"After event\" action.")) if self.timerentry_justplay.value == "zap": self.list.append(self.entryShowEndTime) self.entryEndTime = getConfigListEntry(_("End time"), self.timerentry_endtime, _("The time the timer completes and the \"After event\" action is taken. If the end time is earlier than the start time of the timer, the completion action takes place at that time on the following day.")) if self.timerentry_justplay.value != "zap" or self.timerentry_showendtime.value: self.list.append(self.entryEndTime) self.channelEntry = getConfigListEntry(_("Channel"), self.timerentry_service, _("The channel for this timer.")) self.list.append(self.channelEntry) self.dirname = getConfigListEntry(_("Location"), self.timerentry_dirname, _("Where the recording will be saved.")) self.tagsSet = getConfigListEntry(_("Tags"), self.timerentry_tagsset, _("Choose a tag to make searching for the recording easier.")) if self.timerentry_justplay.value != "zap": if config.usage.setup_level.index >= 2: # expert+ self.list.append(self.dirname) if getPreferredTagEditor(): self.list.append(self.tagsSet) self.list.append(getConfigListEntry(_("After event"), self.timerentry_afterevent, _("Action taken on the completion of the timer. \"Auto\" lets your %s %s return to the state it was in when the timer started. \"Do nothing\", \"Go to standby\" and \"Go to deep standby\" do exactly that.") % (getMachineBrand(), getMachineName()))) self.list.append(getConfigListEntry(_("Recording type"), self.timerentry_recordingtype, _("\"Descramble & record ECM\" allows the recording to be descrambled later if descrambling while recording failed. \"Don't descramble, record ECM\" saves a scrambled recording that can be descrambled on playback. \"Normal\" means descramble while recording and don't record ECM."))) self[widget].list = self.list self[widget].l.setList(self.list) def selectionChanged(self): if self["config"].getCurrent(): if len(self["config"].getCurrent()) > 2 and self["config"].getCurrent()[2]: self["description"].setText(self["config"].getCurrent()[2]) def layoutFinished(self): self.setTitle(_(self.setup_title)) def createSummary(self): return SetupSummary # for summary: def changedEntry(self): for x in self.onChangedEntry: x() def getCurrentEntry(self): return self["config"].getCurrent() and self["config"].getCurrent()[0] or "" def getCurrentValue(self): return self["config"].getCurrent() and str(self["config"].getCurrent()[1].getText()) or "" def newConfig(self): if self["config"].getCurrent() in (self.timerTypeEntry, self.timerJustplayEntry, self.frequencyEntry, self.entryShowEndTime): self.createSetup("config") def showHelp(self): self.hideTextHelp() HelpableScreen.showHelp(self) def hideTextHelp(self): currConfig = self["config"].getCurrent() if isinstance(currConfig[1], ConfigText) and currConfig[1].help_window.instance is not None: currConfig[1].help_window.hide() def showTextHelp(self): currConfig = self["config"].getCurrent() if isinstance(currConfig[1], ConfigText) and currConfig[1].help_window.instance is not None: currConfig[1].help_window.show() def KeyText(self): self.hideTextHelp() currConfig = self["config"].getCurrent() if currConfig[0] in (_('Name'), _("Description")): self.session.openWithCallback(self.renameEntryCallback, VirtualKeyBoard, title=currConfig[2], text=currConfig[1].value) def keyLeft(self): cur = self["config"].getCurrent() if cur in (self.channelEntry, self.tagsSet): self.keySelect() elif cur in (self.entryName, self.entryDescription): self.renameEntry() else: ConfigListScreen.keyLeft(self) self.newConfig() def keyRight(self): cur = self["config"].getCurrent() if cur in (self.channelEntry, self.tagsSet): self.keySelect() elif cur in (self.entryName, self.entryDescription): self.renameEntry() else: ConfigListScreen.keyRight(self) self.newConfig() def renameEntry(self): cur = self["config"].getCurrent() if cur == self.entryName: title_text = _("Please enter new name:") old_text = self.timerentry_name.value else: title_text = _("Please enter new description:") old_text = self.timerentry_description.value self.hideTextHelp() self.session.openWithCallback(self.renameEntryCallback, VirtualKeyBoard, title=title_text, text=old_text) def renameEntryCallback(self, answer): self.showTextHelp() if answer: if self["config"].getCurrent() == self.entryName: self.timerentry_name.value = answer self["config"].invalidate(self.entryName) else: self.timerentry_description.value = answer self["config"].invalidate(self.entryDescription) def handleKeyFileCallback(self, answer): if self["config"].getCurrent() in (self.channelEntry, self.tagsSet): self.keySelect() else: ConfigListScreen.handleKeyFileCallback(self, answer) self.newConfig() def keySelect(self): cur = self["config"].getCurrent() if cur == self.channelEntry: self.session.openWithCallback( self.finishedChannelSelection, ChannelSelection.SimpleChannelSelection, _("Select channel to record from"), currentBouquet=True ) elif config.usage.setup_level.index >= 2 and cur == self.dirname: self.session.openWithCallback( self.pathSelected, MovieLocationBox, _("Select target folder"), self.timerentry_dirname.value, minFree=100 # We require at least 100MB free space ) elif getPreferredTagEditor() and cur == self.tagsSet: self.session.openWithCallback( self.tagEditFinished, getPreferredTagEditor(), self.timerentry_tags ) else: self.keyGo() def finishedChannelSelection(self, *args): if args: self.timerentry_service_ref = ServiceReference(args[0]) self.timerentry_service.setCurrentText(self.timerentry_service_ref.getServiceName()) self["config"].invalidate(self.channelEntry) def getTimestamp(self, date, mytime): d = localtime(date) dt = datetime(d.tm_year, d.tm_mon, d.tm_mday, mytime[0], mytime[1]) return int(mktime(dt.timetuple())) def getBeginEnd(self): date = self.timerentry_date.value endtime = self.timerentry_endtime.value starttime = self.timerentry_starttime.value begin = self.getTimestamp(date, starttime) end = self.getTimestamp(date, endtime) # if the endtime is less than the starttime, add 1 day. if end < begin: end += 86400 # if the timer type is a Zap and no end is set, set duration to 1 second so time is shown in EPG's. if self.timerentry_justplay.value == "zap": if not self.timerentry_showendtime.value: end = begin + (config.recording.margin_before.value * 60) + 1 return begin, end def selectChannelSelector(self, *args): self.session.openWithCallback( self.finishedChannelSelectionCorrection, ChannelSelection.SimpleChannelSelection, _("Select channel to record from") ) def finishedChannelSelectionCorrection(self, *args): if args: self.finishedChannelSelection(*args) self.keyGo() def keyGo(self, result=None): if not self.timerentry_service_ref.isRecordable(): self.session.openWithCallback(self.selectChannelSelector, MessageBox, _("You didn't select a channel to record from."), MessageBox.TYPE_ERROR) return self.timer.name = self.timerentry_name.value self.timer.description = self.timerentry_description.value self.timer.justplay = self.timerentry_justplay.value == "zap" self.timer.always_zap = self.timerentry_justplay.value == "zap+record" self.timer.rename_repeat = self.timerentry_renamerepeat.value if self.timerentry_justplay.value == "zap": if not self.timerentry_showendtime.value: self.timerentry_endtime.value = self.timerentry_starttime.value self.timer.resetRepeated() self.timer.afterEvent = { "nothing": AFTEREVENT.NONE, "deepstandby": AFTEREVENT.DEEPSTANDBY, "standby": AFTEREVENT.STANDBY, "auto": AFTEREVENT.AUTO }[self.timerentry_afterevent.value] self.timer.descramble = { "normal": True, "descrambled+ecm": True, "scrambled+ecm": False, }[self.timerentry_recordingtype.value] self.timer.record_ecm = { "normal": False, "descrambled+ecm": True, "scrambled+ecm": True, }[self.timerentry_recordingtype.value] self.timer.service_ref = self.timerentry_service_ref self.timer.tags = self.timerentry_tags if self.timer.dirname or self.timerentry_dirname.value != defaultMoviePath(): self.timer.dirname = self.timerentry_dirname.value config.movielist.last_timer_videodir.value = self.timer.dirname config.movielist.last_timer_videodir.save() if self.timerentry_type.value == "once": self.timer.begin, self.timer.end = self.getBeginEnd() if self.timerentry_type.value == "repeated": if self.timerentry_repeated.value == "daily": for x in (0, 1, 2, 3, 4, 5, 6): self.timer.setRepeated(x) if self.timerentry_repeated.value == "weekly": self.timer.setRepeated(self.timerentry_weekday.index) if self.timerentry_repeated.value == "weekdays": for x in (0, 1, 2, 3, 4): self.timer.setRepeated(x) if self.timerentry_repeated.value == "user": for x in (0, 1, 2, 3, 4, 5, 6): if self.timerentry_day[x].value: self.timer.setRepeated(x) self.timer.repeatedbegindate = self.getTimestamp(self.timerentry_repeatedbegindate.value, self.timerentry_starttime.value) if self.timer.repeated: self.timer.begin = self.getTimestamp(self.timerentry_repeatedbegindate.value, self.timerentry_starttime.value) self.timer.end = self.getTimestamp(self.timerentry_repeatedbegindate.value, self.timerentry_endtime.value) else: self.timer.begin = self.getTimestamp(time.time(), self.timerentry_starttime.value) self.timer.end = self.getTimestamp(time.time(), self.timerentry_endtime.value) # when a timer end is set before the start, add 1 day if self.timer.end < self.timer.begin: self.timer.end += 86400 if self.timer.eit is not None: event = eEPGCache.getInstance().lookupEventId(self.timer.service_ref.ref, self.timer.eit) if event: n = event.getNumOfLinkageServices() if n > 1: tlist = [] ref = self.session.nav.getCurrentlyPlayingServiceOrGroup() parent = self.timer.service_ref.ref selection = 0 for x in range(n): i = event.getLinkageService(parent, x) if i.toString() == ref.toString(): selection = x tlist.append((i.getName(), i)) self.session.openWithCallback(self.subserviceSelected, ChoiceBox, title=_("Please select a subservice to record..."), list=tlist, selection=selection) return elif n > 0: parent = self.timer.service_ref.ref self.timer.service_ref = ServiceReference(event.getLinkageService(parent, 0)) self.saveTimer() self.close((True, self.timer)) def changeTimerType(self): self.timerentry_justplay.selectNext() self["config"].invalidate(self.timerJustplayEntry) def incrementStart(self): self.timerentry_starttime.increment() self["config"].invalidate(self.entryStartTime) if self.timerentry_type.value == "once" and self.timerentry_starttime.value == [0, 0]: self.timerentry_date.value += 86400 self["config"].invalidate(self.entryDate) def decrementStart(self): self.timerentry_starttime.decrement() self["config"].invalidate(self.entryStartTime) if self.timerentry_type.value == "once" and self.timerentry_starttime.value == [23, 59]: self.timerentry_date.value -= 86400 self["config"].invalidate(self.entryDate) def incrementEnd(self): if self.entryEndTime is not None: self.timerentry_endtime.increment() self["config"].invalidate(self.entryEndTime) def decrementEnd(self): if self.entryEndTime is not None: self.timerentry_endtime.decrement() self["config"].invalidate(self.entryEndTime) def subserviceSelected(self, service): if service is not None: self.timer.service_ref = ServiceReference(service[1]) self.saveTimer() self.close((True, self.timer)) def saveTimer(self): self.session.nav.RecordTimer.saveTimer() def keyCancel(self): self.close((False,)) def pathSelected(self, res): if res is not None: if config.movielist.videodirs.value != self.timerentry_dirname.choices: self.timerentry_dirname.setChoices(config.movielist.videodirs.value, default=res) self.timerentry_dirname.value = res def tagEditFinished(self, ret): if ret is not None: self.timerentry_tags = ret self.timerentry_tagsset.setChoices([not ret and "None" or " ".join(ret)]) self["config"].invalidate(self.tagsSet)
config.plugins.ChannelsImporter = ConfigSubsection() config.plugins.ChannelsImporter.ip = ConfigIP(default=[0, 0, 0, 0]) config.plugins.ChannelsImporter.username = ConfigText(default="root", fixed_size=False) config.plugins.ChannelsImporter.password = ConfigText(default="", fixed_size=False) config.plugins.ChannelsImporter.port = ConfigInteger(21, (0, 65535)) config.plugins.ChannelsImporter.passive = ConfigYesNo(False) config.plugins.ChannelsImporter.importEPG = ConfigYesNo(False) config.plugins.ChannelsImporter.retrycount = NoSave(ConfigNumber(default=0)) config.plugins.ChannelsImporter.nextscheduletime = NoSave(ConfigNumber(default=0)) config.plugins.ChannelsImporter.importOnRestart = ConfigYesNo(False) config.plugins.ChannelsImporter.enableSchedule = ConfigYesNo(False) config.plugins.ChannelsImporter.extensions = ConfigYesNo(default=False) config.plugins.ChannelsImporter.setupFallback = ConfigYesNo(default=False) config.plugins.ChannelsImporter.scheduleRepeatInterval = ConfigSelection(default="daily", choices=[("2", _("Every 2 minutes (for testing)")), ("5", _("Every 5 minutes (for testing)")), ("60", _("Every hour")), ("120", _("Every 2 hours")), ("180", _("Every 3 hours")), ("360", _("Every 6 hours")), ("720", _("Every 12 hours")), ("daily", _("Daily"))]) config.plugins.ChannelsImporter.scheduletime = ConfigClock(default=0) # 1:00 config.plugins.ChannelsImporter.errorMessages = ConfigYesNo(False) def scheduleRepeatIntervalChanged(configElement): if config.plugins.ChannelsImporter.enableSchedule.value and config.plugins.ChannelsImporter.scheduleRepeatInterval.value == "daily": SystemInfo["ChannelsImporterRepeatDaily"] = True else: SystemInfo["ChannelsImporterRepeatDaily"] = False config.plugins.ChannelsImporter.enableSchedule.addNotifier(scheduleRepeatIntervalChanged, immediate_feedback=True, initial_call=True) config.plugins.ChannelsImporter.scheduleRepeatInterval.addNotifier(scheduleRepeatIntervalChanged, immediate_feedback=True, initial_call=True) class ChannelsImporterScreen(Setup):
pluginPrintname = "[Elektro]" debug = False # If set True, plugin will print(some additional status info to track logic flow) session = None ElektroWakeUpTime = -1 elektro_pluginversion = "3.4.6" elektrostarttime = 60 elektrosleeptime = 5 elektroTimerWakeupThreshold = 60 * 14 + 45 # any wakeup from sleep within 14.75 minutes around the wakeup time/a recording timer is regarded to be automatic (as opposed to manual) elektroShutdownThreshold = 60 * 20 # we only go to sleep if and only if we won't need to wake up for a timer within the next 20 minutes ############################################################################### #Configuration if debug: print(pluginPrintname, "Setting config defaults") config.plugins.elektro = ConfigSubsection() config.plugins.elektro.nextday = ConfigClock(default=((6 * 60 + 0) * 60)) config.plugins.elektro.nextday2 = ConfigClock(default=((6 * 60 + 0) * 60)) config.plugins.elektro.profile = ConfigSelection(choices=[("1", "Profile 1"), ("2", "Profile 2")], default="1") config.plugins.elektro.profileShift = ConfigYesNo(default=False) config.plugins.elektro.sleep = ConfigSubDict() for i in range(7): config.plugins.elektro.sleep[i] = ConfigClock(default=((1 * 60 + 0) * 60)) config.plugins.elektro.wakeup = ConfigSubDict() for i in range(7): config.plugins.elektro.wakeup[i] = ConfigClock(default=((9 * 60 + 0) * 60)) config.plugins.elektro.sleep2 = ConfigSubDict() for i in range(7): config.plugins.elektro.sleep2[i] = ConfigClock(default=((1 * 60 + 0) * 60))
config.autoshutdown.enableinactivity = ConfigEnableDisable(default=False) config.autoshutdown.inactivityaction = ConfigSelection( default="standby", choices=[("standby", _("Standby")), ("deepstandby", _("Deepstandby"))]) config.autoshutdown.inactivitymessage = ConfigYesNo(default=True) config.autoshutdown.messagetimeout = ConfigInteger(default=20, limits=(1, 99)) config.autoshutdown.epgrefresh = ConfigYesNo(default=True) config.autoshutdown.plugin = ConfigYesNo(default=False) config.autoshutdown.play_media = ConfigYesNo(default=False) config.autoshutdown.media_file = ConfigText(default="") config.autoshutdown.disable_at_ts = ConfigYesNo(default=False) config.autoshutdown.disable_net_device = ConfigYesNo(default=False) config.autoshutdown.disable_hdd = ConfigYesNo(default=False) config.autoshutdown.net_device = ConfigIP(default=[0, 0, 0, 0]) config.autoshutdown.exclude_time_in = ConfigYesNo(default=False) config.autoshutdown.exclude_time_in_begin = ConfigClock( default=calculateTime(20, 0)) config.autoshutdown.exclude_time_in_end = ConfigClock( default=calculateTime(0, 0)) config.autoshutdown.exclude_time_off = ConfigYesNo(default=False) config.autoshutdown.exclude_time_off_begin = ConfigClock( default=calculateTime(20, 0)) config.autoshutdown.exclude_time_off_end = ConfigClock( default=calculateTime(0, 0)) config.autoshutdown.fake_entry = NoSave(ConfigNothing()) def checkIP(ip_address): ip_address = "%s.%s.%s.%s" % (ip_address[0], ip_address[1], ip_address[2], ip_address[3]) ping_ret = system("ping -q -w1 -c1 " + ip_address) if ping_ret == 0:
import time import os import enigma from Plugins.Plugin import PluginDescriptor from Components.config import config, \ ConfigEnableDisable, ConfigSubsection, \ ConfigClock, ConfigOnOff, ConfigText #Set default configuration config.plugins.autobackup = ConfigSubsection() config.plugins.autobackup.wakeup = ConfigClock(default=((3 * 60) + 0) * 60) # 3:00 config.plugins.autobackup.enabled = ConfigEnableDisable(default=False) config.plugins.autobackup.autoinstall = ConfigOnOff(default=False) config.plugins.autobackup.where = ConfigText(default="/media/hdd") # Global variables autoStartTimer = None ################################## # Configuration GUI BACKUP_SCRIPT = "/usr/lib/enigma2/python/Plugins/Extensions/AutoBackup/settings-backup.sh" def backupCommand(): cmd = BACKUP_SCRIPT if config.plugins.autobackup.autoinstall.value: cmd += " -a" cmd += " " + config.plugins.autobackup.where.value return cmd
from Screens.MessageBox import MessageBox from Tools.Directories import resolveFilename, SCOPE_CURRENT_SKIN from RecordTimer import RecordTimerEntry, parseEvent, AFTEREVENT from ServiceReference import ServiceReference, isPlayableForCur from Tools.LoadPixmap import LoadPixmap from Tools.Alternatives import CompareWithAlternatives from Tools import Notifications from enigma import eEPGCache, eListbox, gFont, eListboxPythonMultiContent, RT_HALIGN_LEFT, RT_HALIGN_RIGHT, RT_HALIGN_CENTER,\ RT_VALIGN_CENTER, RT_WRAP, BT_SCALE, BT_KEEP_ASPECT_RATIO, eSize, eRect, eTimer, getBestPlayableServiceReference, loadPNG from GraphMultiEpgSetup import GraphMultiEpgSetup from time import localtime, time, strftime MAX_TIMELINES = 6 config.misc.graph_mepg = ConfigSubsection() config.misc.graph_mepg.prev_time = ConfigClock(default = time()) config.misc.graph_mepg.prev_time_period = ConfigInteger(default = 120, limits = (60, 300)) config.misc.graph_mepg.ev_fontsize = ConfigSelectionNumber(default = 0, stepwidth = 1, min = -8, max = 8, wraparound = True) config.misc.graph_mepg.items_per_page = ConfigSelectionNumber(min = 3, max = 40, stepwidth = 1, default = 6, wraparound = True) config.misc.graph_mepg.items_per_page_listscreen = ConfigSelectionNumber(min = 3, max = 60, stepwidth = 1, default = 12, wraparound = True) config.misc.graph_mepg.default_mode = ConfigYesNo(default = False) config.misc.graph_mepg.overjump = ConfigYesNo(default = True) config.misc.graph_mepg.center_timeline = ConfigYesNo(default = False) config.misc.graph_mepg.servicetitle_mode = ConfigSelection(default = "picon+servicename", choices = [ ("servicename", _("Service name")), ("picon", _("Picon")), ("picon+servicename", _("Picon and service name")) ]) config.misc.graph_mepg.roundTo = ConfigSelection(default = "900", choices = [("900", _("%d minutes") % 15), ("1800", _("%d minutes") % 30), ("3600", _("%d minutes") % 60)]) config.misc.graph_mepg.OKButton = ConfigSelection(default = "info", choices = [("info", _("Show detailed event info")), ("zap", _("Zap to selected channel"))]) possibleAlignmentChoices = [ ( str(RT_HALIGN_LEFT | RT_VALIGN_CENTER ) , _("left")),
class TimerEntry(Screen, ConfigListScreen): def __init__(self, session, timer): Screen.__init__(self, session) self.timer = timer self.entryDate = None self.entryService = None self['HelpWindow'] = Pixmap() self['HelpWindow'].hide() self['oktext'] = Label(_('OK')) self['canceltext'] = Label(_('Cancel')) self['ok'] = Pixmap() self['cancel'] = Pixmap() self['summary_description'] = StaticText('') self.createConfig() self['actions'] = NumberActionMap(['SetupActions', 'GlobalActions', 'PiPSetupActions'], {'ok': self.keySelect, 'save': self.keyGo, 'cancel': self.keyCancel, 'volumeUp': self.incrementStart, 'volumeDown': self.decrementStart, 'size+': self.incrementEnd, 'size-': self.decrementEnd, 'up': self.keyUp, 'down': self.keyDown}, -2) self.list = [] ConfigListScreen.__init__(self, self.list, session=session) self.setTitle(_('PowerManager entry')) self.createSetup('config') return def createConfig(self): afterevent = {AFTEREVENT.NONE: 'nothing', AFTEREVENT.WAKEUP: 'wakeup', AFTEREVENT.WAKEUPTOSTANDBY: 'wakeuptostandby', AFTEREVENT.STANDBY: 'standby', AFTEREVENT.DEEPSTANDBY: 'deepstandby'}[self.timer.afterEvent] 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.timer.timerType] weekday_table = ('mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun') time_table = [(1, '1'), (3, '3'), (5, '5'), (10, '10'), (15, '15'), (30, '30'), (45, '45'), (60, '60'), (75, '75'), (90, '90'), (105, '105'), (120, '120'), (135, '135'), (150, '150'), (165, '165'), (180, '180'), (195, '195'), (210, '210'), (225, '225'), (240, '240'), (255, '255'), (270, '270'), (285, '285'), (300, '300')] traffic_table = [(10, '10'), (50, '50'), (100, '100'), (500, '500'), (1000, '1000')] day = [] weekday = 0 for x in (0, 1, 2, 3, 4, 5, 6): day.append(0) if self.timer.repeated: type = 'repeated' if self.timer.repeated == 31: repeated = 'weekdays' elif self.timer.repeated == 127: repeated = 'daily' else: flags = self.timer.repeated repeated = 'user' count = 0 for x in (0, 1, 2, 3, 4, 5, 6): if flags == 1: print 'Set to weekday ' + str(x) weekday = x if flags & 1 == 1: day[x] = 1 count += 1 else: day[x] = 0 flags >>= 1 if count == 1: repeated = 'weekly' else: type = 'once' repeated = None weekday = int(strftime('%u', localtime(self.timer.begin))) - 1 day[weekday] = 1 if SystemInfo['DeepstandbySupport']: shutdownString = _('go to deep standby') else: shutdownString = _('shut down') self.timerentry_timertype = ConfigSelection(choices=[('nothing', _('do nothing')), ('wakeup', _('wakeup')), ('wakeuptostandby', _('wakeup to standby')), ('autostandby', _('auto standby')), ('autodeepstandby', _('auto deepstandby')), ('standby', _('go to standby')), ('deepstandby', shutdownString), ('reboot', _('reboot system')), ('restart', _('restart GUI'))], default=timertype) self.timerentry_afterevent = ConfigSelection(choices=[('nothing', _('do nothing')), ('wakeup', _('wakeup')), ('wakeuptostandby', _('wakeup to standby')), ('standby', _('go to standby')), ('deepstandby', shutdownString), ('nothing', _('do nothing'))], default=afterevent) self.timerentry_type = ConfigSelection(choices=[('once', _('once')), ('repeated', _('repeated'))], default=type) self.timerentry_repeated = ConfigSelection(default=repeated, choices=[('daily', _('daily')), ('weekly', _('weekly')), ('weekdays', _('Mon-Fri')), ('user', _('user defined'))]) self.timerrntry_autosleepdelay = ConfigSelection(choices=time_table, default=self.timer.autosleepdelay) self.timerentry_autosleeprepeat = ConfigSelection(choices=[('once', _('once')), ('repeated', _('repeated'))], default=self.timer.autosleeprepeat) self.timerrntry_autosleepinstandbyonly = ConfigSelection(choices=[('yes', _('Yes')), ('no', _('No'))], default=self.timer.autosleepinstandbyonly) self.timerrntry_autosleepwindow = ConfigSelection(choices=[('yes', _('Yes')), ('no', _('No'))], default=self.timer.autosleepwindow) self.timerrntry_autosleepbegin = ConfigClock(default=self.timer.autosleepbegin) self.timerrntry_autosleepend = ConfigClock(default=self.timer.autosleepend) self.timerentry_date = ConfigDateTime(default=self.timer.begin, formatstring=_('%d.%B %Y'), increment=86400) self.timerentry_starttime = ConfigClock(default=self.timer.begin) self.timerentry_endtime = ConfigClock(default=self.timer.end) self.timerentry_showendtime = ConfigSelection(default=(self.timer.end - self.timer.begin) / 60 > 4, choices=[(True, _('yes')), (False, _('no'))]) self.timerentry_repeatedbegindate = ConfigDateTime(default=self.timer.repeatedbegindate, formatstring=_('%d.%B %Y'), increment=86400) self.timerentry_weekday = ConfigSelection(default=weekday_table[weekday], choices=[('mon', _('Monday')), ('tue', _('Tuesday')), ('wed', _('Wednesday')), ('thu', _('Thursday')), ('fri', _('Friday')), ('sat', _('Saturday')), ('sun', _('Sunday'))]) self.timerentry_day = ConfigSubList() for x in (0, 1, 2, 3, 4, 5, 6): self.timerentry_day.append(ConfigYesNo(default=day[x])) self.timerrntry_showExtended = ConfigSelection(default=self.timer.nettraffic == 'yes' or self.timer.netip == 'yes', choices=[(True, _('yes')), (False, _('no'))]) self.timerrntry_nettraffic = ConfigSelection(choices=[('yes', _('Yes')), ('no', _('No'))], default=self.timer.nettraffic) self.timerrntry_trafficlimit = ConfigSelection(choices=traffic_table, default=self.timer.trafficlimit) self.timerrntry_netip = ConfigSelection(choices=[('yes', _('Yes')), ('no', _('No'))], default=self.timer.netip) self.timerrntry_ipadress = self.timer.ipadress.split(',') self.ipcount = ConfigSelectionNumber(default=len(self.timerrntry_ipadress), stepwidth=1, min=1, max=5) self.ipadressEntry = ConfigSubList() for x in (0, 1, 2, 3, 4, 5): try: self.ipadressEntry.append(ConfigIP(default=[ int(n) for n in self.timerrntry_ipadress[x].split('.') ] or [0, 0, 0, 0])) except: self.ipadressEntry.append(ConfigIP(default=[0, 0, 0, 0])) return def createSetup(self, widget): self.list = [] self.timerType = getConfigListEntry(_('Timer type'), self.timerentry_timertype) self.list.append(self.timerType) self.timerTypeEntry = getConfigListEntry(_('Repeat type'), self.timerentry_type) self.entryStartTime = getConfigListEntry(_('Start time'), self.timerentry_starttime) self.entryShowEndTime = getConfigListEntry(_('Set end time'), self.timerentry_showendtime) self.entryEndTime = getConfigListEntry(_('End time'), self.timerentry_endtime) self.frequencyEntry = getConfigListEntry(_('Repeats'), self.timerentry_repeated) self.entryDate = getConfigListEntry(_('Date'), self.timerentry_date) self.repeatedbegindateEntry = getConfigListEntry(_('Starting on'), self.timerentry_repeatedbegindate) self.autosleepwindowEntry = getConfigListEntry(_('Restrict the active time range'), self.timerrntry_autosleepwindow) self.netExtendedEntry = getConfigListEntry(_('Show advanced settings'), self.timerrntry_showExtended) self.nettrafficEntry = getConfigListEntry(_('Enable Network Traffic check'), self.timerrntry_nettraffic) self.netipEntry = getConfigListEntry(_('Enable Network IP address check'), self.timerrntry_netip) self.ipcountEntry = getConfigListEntry(_('Select of the number'), self.ipcount) if self.timerentry_timertype.value == 'autostandby' or self.timerentry_timertype.value == 'autodeepstandby': if self.timerentry_timertype.value == 'autodeepstandby': self.list.append(getConfigListEntry(_('Only active when in standby'), self.timerrntry_autosleepinstandbyonly)) self.list.append(getConfigListEntry(_('Sleep delay'), self.timerrntry_autosleepdelay)) self.list.append(getConfigListEntry(_('Repeat type'), self.timerentry_autosleeprepeat)) self.list.append(self.autosleepwindowEntry) if self.timerrntry_autosleepwindow.value == 'yes': self.list.append(getConfigListEntry(_('Start time'), self.timerrntry_autosleepbegin)) self.list.append(getConfigListEntry(_('End time'), self.timerrntry_autosleepend)) if self.timerentry_timertype.value == 'autodeepstandby': self.list.append(self.netExtendedEntry) if self.timerrntry_showExtended.value: self.list.append(self.nettrafficEntry) if self.timerrntry_nettraffic.value == 'yes': self.list.append(getConfigListEntry(_('Lower limit in kilobits per seconds [kbit/s]'), self.timerrntry_trafficlimit)) self.list.append(self.netipEntry) if self.timerrntry_netip.value == 'yes': self.list.append(self.ipcountEntry) for x in range(0, self.ipcount.value): self.list.append(getConfigListEntry(('%d. ' + _('IP address')) % (x + 1), self.ipadressEntry[x])) else: self.list.append(self.timerTypeEntry) if self.timerentry_type.value == 'once': self.frequencyEntry = None else: self.list.append(self.frequencyEntry) self.list.append(self.repeatedbegindateEntry) if self.timerentry_repeated.value == 'daily': pass if self.timerentry_repeated.value == 'weekdays': pass if self.timerentry_repeated.value == 'weekly': self.list.append(getConfigListEntry(_('Weekday'), self.timerentry_weekday)) if self.timerentry_repeated.value == 'user': self.list.append(getConfigListEntry(_('Monday'), self.timerentry_day[0])) self.list.append(getConfigListEntry(_('Tuesday'), self.timerentry_day[1])) self.list.append(getConfigListEntry(_('Wednesday'), self.timerentry_day[2])) self.list.append(getConfigListEntry(_('Thursday'), self.timerentry_day[3])) self.list.append(getConfigListEntry(_('Friday'), self.timerentry_day[4])) self.list.append(getConfigListEntry(_('Saturday'), self.timerentry_day[5])) self.list.append(getConfigListEntry(_('Sunday'), self.timerentry_day[6])) if self.timerentry_type.value == 'once': self.list.append(self.entryDate) self.list.append(self.entryStartTime) self.list.append(self.entryShowEndTime) if self.timerentry_showendtime.value: self.list.append(self.entryEndTime) self.list.append(getConfigListEntry(_('After event'), self.timerentry_afterevent)) self[widget].list = self.list self[widget].l.setList(self.list) self.checkSummary() return def createSummary(self): pass def checkSummary(self): self['summary_description'].text = self['config'].getCurrent()[0] def newConfig(self): if self['config'].getCurrent() in (self.timerType, self.timerTypeEntry, self.frequencyEntry, self.entryShowEndTime, self.autosleepwindowEntry, self.netExtendedEntry, self.nettrafficEntry, self.netipEntry, self.ipcountEntry): self.createSetup('config') def keyLeft(self): ConfigListScreen.keyLeft(self) self.newConfig() def keyRight(self): ConfigListScreen.keyRight(self) self.newConfig() def keySelect(self): cur = self['config'].getCurrent() self.keyGo() def keyUp(self): self['config'].moveUp() self.checkSummary() def keyDown(self): self['config'].moveDown() self.checkSummary() def getTimestamp(self, date, mytime): d = localtime(date) dt = datetime(d.tm_year, d.tm_mon, d.tm_mday, mytime[0], mytime[1]) return int(mktime(dt.timetuple())) def getBeginEnd(self): date = self.timerentry_date.value endtime = self.timerentry_endtime.value starttime = self.timerentry_starttime.value begin = self.getTimestamp(date, starttime) end = self.getTimestamp(date, endtime) if end < begin: end += 86400 return (begin, end) def keyGo(self, result = None): if not self.timerentry_showendtime.value: self.timerentry_endtime.value = self.timerentry_starttime.value self.timer.resetRepeated() if self.timerentry_type.value == 'once': self.timer.begin, self.timer.end = self.getBeginEnd() if self.timerentry_timertype.value == 'autostandby' or self.timerentry_timertype.value == 'autodeepstandby': self.timer.begin = int(time()) + 10 self.timer.end = self.timer.begin self.timer.autosleepinstandbyonly = self.timerrntry_autosleepinstandbyonly.value self.timer.autosleepdelay = self.timerrntry_autosleepdelay.value self.timer.autosleeprepeat = self.timerentry_autosleeprepeat.value self.timerentry_showendtime.value = False if self.timerentry_type.value == 'repeated': if self.timerentry_repeated.value == 'daily': for x in (0, 1, 2, 3, 4, 5, 6): self.timer.setRepeated(x) if self.timerentry_repeated.value == 'weekly': self.timer.setRepeated(self.timerentry_weekday.index) if self.timerentry_repeated.value == 'weekdays': for x in (0, 1, 2, 3, 4): self.timer.setRepeated(x) if self.timerentry_repeated.value == 'user': for x in (0, 1, 2, 3, 4, 5, 6): if self.timerentry_day[x].value: self.timer.setRepeated(x) self.timer.repeatedbegindate = self.getTimestamp(self.timerentry_repeatedbegindate.value, self.timerentry_starttime.value) if self.timer.repeated: self.timer.begin = self.getTimestamp(self.timerentry_repeatedbegindate.value, self.timerentry_starttime.value) self.timer.end = self.getTimestamp(self.timerentry_repeatedbegindate.value, self.timerentry_endtime.value) else: self.timer.begin = self.getTimestamp(time(), self.timerentry_starttime.value) self.timer.end = self.getTimestamp(time(), self.timerentry_endtime.value) if self.timer.end < self.timer.begin: self.timer.end += 86400 endaction = self.timerentry_showendtime.value if (self.timer.end - self.timer.begin) / 60 < 5 or self.timerentry_showendtime.value is False: self.timerentry_afterevent.value = 'nothing' self.timer.end = self.timer.begin if endaction: self.session.open(MessageBox, _('Difference between timer begin and end must be equal or greater than %d minutes.\nEnd Action was disabled !') % 5, MessageBox.TYPE_INFO, timeout=30) self.timer.timerType = {'nothing': TIMERTYPE.NONE, 'wakeup': TIMERTYPE.WAKEUP, 'wakeuptostandby': TIMERTYPE.WAKEUPTOSTANDBY, 'autostandby': TIMERTYPE.AUTOSTANDBY, 'autodeepstandby': TIMERTYPE.AUTODEEPSTANDBY, 'standby': TIMERTYPE.STANDBY, 'deepstandby': TIMERTYPE.DEEPSTANDBY, 'reboot': TIMERTYPE.REBOOT, 'restart': TIMERTYPE.RESTART}[self.timerentry_timertype.value] self.timer.afterEvent = {'nothing': AFTEREVENT.NONE, 'wakeup': AFTEREVENT.WAKEUP, 'wakeuptostandby': AFTEREVENT.WAKEUPTOSTANDBY, 'standby': AFTEREVENT.STANDBY, 'deepstandby': AFTEREVENT.DEEPSTANDBY}[self.timerentry_afterevent.value] self.timer.autosleepwindow = self.timerrntry_autosleepwindow.value self.timer.autosleepbegin = self.getTimestamp(time(), self.timerrntry_autosleepbegin.value) self.timer.autosleepend = self.getTimestamp(time(), self.timerrntry_autosleepend.value) self.timer.nettraffic = self.timerrntry_nettraffic.value self.timer.trafficlimit = self.timerrntry_trafficlimit.value self.timer.netip = self.timerrntry_netip.value self.timer.ipadress = '%d.%d.%d.%d' % (self.ipadressEntry[0].value[0], self.ipadressEntry[0].value[1], self.ipadressEntry[0].value[2], self.ipadressEntry[0].value[3]) for x in range(1, self.ipcount.value): self.timer.ipadress += ',%d.%d.%d.%d' % (self.ipadressEntry[x].value[0], self.ipadressEntry[x].value[1], self.ipadressEntry[x].value[2], self.ipadressEntry[x].value[3]) self.saveTimer() self.close((True, self.timer)) def incrementStart(self): self.timerentry_starttime.increment() self['config'].invalidate(self.entryStartTime) if self.timerentry_type.value == 'once' and self.timerentry_starttime.value == [0, 0]: self.timerentry_date.value += 86400 self['config'].invalidate(self.entryDate) def decrementStart(self): self.timerentry_starttime.decrement() self['config'].invalidate(self.entryStartTime) if self.timerentry_type.value == 'once' and self.timerentry_starttime.value == [23, 59]: self.timerentry_date.value -= 86400 self['config'].invalidate(self.entryDate) def incrementEnd(self): if self.entryEndTime is not None: self.timerentry_endtime.increment() self['config'].invalidate(self.entryEndTime) return def decrementEnd(self): if self.entryEndTime is not None: self.timerentry_endtime.decrement() self['config'].invalidate(self.entryEndTime) return def saveTimer(self): self.session.nav.PowerTimer.saveTimer() def keyCancel(self): self.close((False,))
from . import _ from Components.config import config, ConfigSubsection, getConfigListEntry, ConfigSelection, ConfigClock, ConfigYesNo from Components.ConfigList import ConfigListScreen from Components.Sources.StaticText import StaticText from Components.ActionMap import ActionMap from Components.Label import Label from Screens.Screen import Screen from Tools.Directories import fileExists from enigma import getDesktop size_width = getDesktop(0).size().width() plugin_version = "1.4" config.plugins.PrimeTimeManager = ConfigSubsection() config.plugins.PrimeTimeManager.Time1 = ConfigClock(default = 69300) # 20:15 config.plugins.PrimeTimeManager.Time2 = ConfigClock(default = 75600) # 22:00 config.plugins.PrimeTimeManager.DurationOrEndTime = ConfigSelection(default = "duration", choices = [ ("duration", _("Duration")), ("endtime", _("End time")) ]) config.plugins.PrimeTimeManager.RemoveFavorite = ConfigYesNo() config.plugins.PrimeTimeManager.ViewLive = ConfigYesNo(default = False) config.plugins.PrimeTimeManager.ViewLiveType = ConfigSelection(default = "zap", choices = [ ("zap", _("Zap")), ("zaprec", _("Zap + Record")) ]) config.plugins.PrimeTimeManager.CheckConflictOnExit = ConfigYesNo(default = False) config.plugins.PrimeTimeManager.CheckConflictOnAccept = ConfigYesNo(default = True) config.plugins.PrimeTimeManager.TimerEditKeyMenu = ConfigYesNo(default = True) config.plugins.PrimeTimeManager.ExtMenu = ConfigYesNo(default = False)
class TimerEntry(Screen, ConfigListScreen): def __init__(self, session, timer): Screen.__init__(self, session) self.timer = timer self.entryDate = None self.entryService = None self["oktext"] = Label(_("OK")) self["canceltext"] = Label(_("Cancel")) self["ok"] = Pixmap() self["cancel"] = Pixmap() self.createConfig() self["actions"] = NumberActionMap(["SetupActions", "GlobalActions", "PiPSetupActions"], { "ok": self.keySelect, "save": self.keyGo, "cancel": self.keyCancel, "volumeUp": self.incrementStart, "volumeDown": self.decrementStart, "size+": self.incrementEnd, "size-": self.decrementEnd }, -2) self.list = [] ConfigListScreen.__init__(self, self.list, session = session) self.createSetup("config") def createConfig(self): justplay = self.timer.justplay afterevent = { AFTEREVENT.NONE: "nothing", AFTEREVENT.DEEPSTANDBY: "deepstandby", AFTEREVENT.STANDBY: "standby", AFTEREVENT.AUTO: "auto" }[self.timer.afterEvent] weekday_table = ("mon", "tue", "wed", "thu", "fri", "sat", "sun") # calculate default values day = [] weekday = 0 for x in (0, 1, 2, 3, 4, 5, 6): day.append(0) if self.timer.repeated: # repeated type = "repeated" if (self.timer.repeated == 31): # Mon-Fri repeated = "weekdays" elif (self.timer.repeated == 127): # daily repeated = "daily" else: flags = self.timer.repeated repeated = "user" count = 0 for x in (0, 1, 2, 3, 4, 5, 6): if flags == 1: # weekly print "Set to weekday " + str(x) weekday = x if flags & 1 == 1: # set user defined flags day[x] = 1 count += 1 else: day[x] = 0 flags = flags >> 1 if count == 1: repeated = "weekly" else: # once type = "once" repeated = None weekday = (int(strftime("%w", 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_afterevent = ConfigSelection(choices = [("nothing", _("do nothing")), ("standby", _("go to standby")), ("deepstandby", _("go to deep standby")), ("auto", _("auto"))], default = afterevent) self.timerentry_type = ConfigSelection(choices = [("once",_("once")), ("repeated", _("repeated"))], default = type) self.timerentry_name = ConfigText(default = self.timer.name, visible_width = 50, fixed_size = False) self.timerentry_description = ConfigText(default = self.timer.description, visible_width = 50, fixed_size = False) self.timerentry_tags = self.timer.tags[:] self.timerentry_tagsset = ConfigSelection(choices = [not self.timerentry_tags and "None" or " ".join(self.timerentry_tags)]) self.timerentry_repeated = ConfigSelection(default = repeated, choices = [("daily", _("daily")), ("weekly", _("weekly")), ("weekdays", _("Mon-Fri")), ("user", _("user defined"))]) self.timerentry_date = ConfigDateTime(default = self.timer.begin, formatstring = _("%d.%B %Y"), increment = 86400) self.timerentry_starttime = ConfigClock(default = self.timer.begin) self.timerentry_endtime = ConfigClock(default = self.timer.end) default = self.timer.dirname or resolveFilename(SCOPE_HDD) tmp = config.movielist.videodirs.value if default not in tmp: tmp.append(default) self.timerentry_dirname = ConfigSelection(default = default, choices = tmp) self.timerentry_repeatedbegindate = ConfigDateTime(default = self.timer.repeatedbegindate, formatstring = _("%d.%B %Y"), increment = 86400) self.timerentry_weekday = ConfigSelection(default = weekday_table[weekday], choices = [("mon",_("Monday")), ("tue", _("Tuesday")), ("wed",_("Wednesday")), ("thu", _("Thursday")), ("fri", _("Friday")), ("sat", _("Saturday")), ("sun", _("Sunday"))]) self.timerentry_day = ConfigSubList() for x in (0, 1, 2, 3, 4, 5, 6): self.timerentry_day.append(ConfigYesNo(default = day[x])) # FIXME some service-chooser needed here servicename = "N/A" try: # no current service available? servicename = str(self.timer.service_ref.getServiceName()) except: pass self.timerentry_service_ref = self.timer.service_ref self.timerentry_service = ConfigSelection([servicename]) def createSetup(self, widget): 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.list.append(self.timerJustplayEntry) self.timerTypeEntry = getConfigListEntry(_("Repeat Type"), self.timerentry_type) self.list.append(self.timerTypeEntry) if self.timerentry_type.value == "once": self.frequencyEntry = None else: # repeated self.frequencyEntry = getConfigListEntry(_("Repeats"), self.timerentry_repeated) self.list.append(self.frequencyEntry) self.repeatedbegindateEntry = getConfigListEntry(_("Starting on"), self.timerentry_repeatedbegindate) self.list.append(self.repeatedbegindateEntry) if self.timerentry_repeated.value == "daily": pass if self.timerentry_repeated.value == "weekdays": pass if self.timerentry_repeated.value == "weekly": self.list.append(getConfigListEntry(_("Weekday"), self.timerentry_weekday)) if self.timerentry_repeated.value == "user": self.list.append(getConfigListEntry(_("Monday"), self.timerentry_day[0])) self.list.append(getConfigListEntry(_("Tuesday"), self.timerentry_day[1])) self.list.append(getConfigListEntry(_("Wednesday"), self.timerentry_day[2])) self.list.append(getConfigListEntry(_("Thursday"), self.timerentry_day[3])) self.list.append(getConfigListEntry(_("Friday"), self.timerentry_day[4])) self.list.append(getConfigListEntry(_("Saturday"), self.timerentry_day[5])) self.list.append(getConfigListEntry(_("Sunday"), self.timerentry_day[6])) self.entryDate = getConfigListEntry(_("Date"), self.timerentry_date) if self.timerentry_type.value == "once": self.list.append(self.entryDate) self.entryStartTime = getConfigListEntry(_("StartTime"), self.timerentry_starttime) self.list.append(self.entryStartTime) if self.timerentry_justplay.value != "zap": self.entryEndTime = getConfigListEntry(_("EndTime"), self.timerentry_endtime) self.list.append(self.entryEndTime) else: self.entryEndTime = None self.channelEntry = getConfigListEntry(_("Channel"), self.timerentry_service) self.list.append(self.channelEntry) self.dirname = getConfigListEntry(_("Location"), self.timerentry_dirname) self.tagsSet = getConfigListEntry(_("Tags"), self.timerentry_tagsset) if self.timerentry_justplay.value != "zap": if config.usage.setup_level.index >= 2: # expert+ self.list.append(self.dirname) if getPreferredTagEditor(): self.list.append(self.tagsSet) self.list.append(getConfigListEntry(_("After event"), self.timerentry_afterevent)) self[widget].list = self.list self[widget].l.setList(self.list) def newConfig(self): print "newConfig", self["config"].getCurrent() if self["config"].getCurrent() == self.timerTypeEntry: self.createSetup("config") if self["config"].getCurrent() == self.timerJustplayEntry: self.createSetup("config") if self["config"].getCurrent() == self.frequencyEntry: self.createSetup("config") def keyLeft(self): if self["config"].getCurrent() in (self.channelEntry, self.tagsSet): self.keySelect() else: ConfigListScreen.keyLeft(self) self.newConfig() def keyRight(self): if self["config"].getCurrent() in (self.channelEntry, self.tagsSet): self.keySelect() else: ConfigListScreen.keyRight(self) self.newConfig() def keySelect(self): cur = self["config"].getCurrent() if cur == self.channelEntry: self.session.openWithCallback( self.finishedChannelSelection, ChannelSelection.SimpleChannelSelection, _("Select channel to record from") ) elif config.usage.setup_level.index >= 2 and cur == self.dirname: self.session.openWithCallback( self.pathSelected, MovieLocationBox, _("Choose target folder"), self.timerentry_dirname.value, minFree = 100 # We require at least 100MB free space ) elif getPreferredTagEditor() and cur == self.tagsSet: self.session.openWithCallback( self.tagEditFinished, getPreferredTagEditor(), self.timerentry_tags ) else: self.keyGo() def finishedChannelSelection(self, *args): if args: self.timerentry_service_ref = ServiceReference(args[0]) self.timerentry_service.setCurrentText(self.timerentry_service_ref.getServiceName()) self["config"].invalidate(self.channelEntry) def getTimestamp(self, date, mytime): d = localtime(date) dt = datetime(d.tm_year, d.tm_mon, d.tm_mday, mytime[0], mytime[1]) return int(mktime(dt.timetuple())) def getBeginEnd(self): date = self.timerentry_date.value endtime = self.timerentry_endtime.value starttime = self.timerentry_starttime.value begin = self.getTimestamp(date, starttime) end = self.getTimestamp(date, endtime) # if the endtime is less than the starttime, add 1 day. if 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.resetRepeated() self.timer.afterEvent = { "nothing": AFTEREVENT.NONE, "deepstandby": AFTEREVENT.DEEPSTANDBY, "standby": AFTEREVENT.STANDBY, "auto": AFTEREVENT.AUTO }[self.timerentry_afterevent.value] self.timer.service_ref = self.timerentry_service_ref self.timer.tags = self.timerentry_tags self.timer.dirname = self.timerentry_dirname.value config.movielist.last_timer_videodir.value = self.timer.dirname config.movielist.last_timer_videodir.save() if self.timerentry_type.value == "once": self.timer.begin, self.timer.end = self.getBeginEnd() if self.timerentry_type.value == "repeated": if self.timerentry_repeated.value == "daily": for x in (0, 1, 2, 3, 4, 5, 6): self.timer.setRepeated(x) if self.timerentry_repeated.value == "weekly": self.timer.setRepeated(self.timerentry_weekday.index) if self.timerentry_repeated.value == "weekdays": for x in (0, 1, 2, 3, 4): self.timer.setRepeated(x) if self.timerentry_repeated.value == "user": for x in (0, 1, 2, 3, 4, 5, 6): if self.timerentry_day[x].value: self.timer.setRepeated(x) self.timer.repeatedbegindate = self.getTimestamp(self.timerentry_repeatedbegindate.value, self.timerentry_starttime.value) if self.timer.repeated: self.timer.begin = self.getTimestamp(self.timerentry_repeatedbegindate.value, self.timerentry_starttime.value) self.timer.end = self.getTimestamp(self.timerentry_repeatedbegindate.value, self.timerentry_endtime.value) else: self.timer.begin = self.getTimestamp(time.time(), self.timerentry_starttime.value) self.timer.end = self.getTimestamp(time.time(), self.timerentry_endtime.value) # when a timer end is set before the start, add 1 day if self.timer.end < self.timer.begin: self.timer.end += 86400 if self.timer.eit is not None: event = eEPGCache.getInstance().lookupEventId(self.timer.service_ref.ref, self.timer.eit) if event: n = event.getNumOfLinkageServices() if n > 1: tlist = [] ref = self.session.nav.getCurrentlyPlayingServiceReference() parent = self.timer.service_ref.ref selection = 0 for x in range(n): i = event.getLinkageService(parent, x) if i.toString() == ref.toString(): selection = x tlist.append((i.getName(), i)) self.session.openWithCallback(self.subserviceSelected, ChoiceBox, title=_("Please select a subservice to record..."), list = tlist, selection = selection) return elif n > 0: parent = self.timer.service_ref.ref self.timer.service_ref = ServiceReference(event.getLinkageService(parent, 0)) self.saveTimer() self.close((True, self.timer)) def incrementStart(self): self.timerentry_starttime.increment() self["config"].invalidate(self.entryStartTime) def decrementStart(self): self.timerentry_starttime.decrement() self["config"].invalidate(self.entryStartTime) def incrementEnd(self): if self.entryEndTime is not None: self.timerentry_endtime.increment() self["config"].invalidate(self.entryEndTime) def decrementEnd(self): if self.entryEndTime is not None: self.timerentry_endtime.decrement() self["config"].invalidate(self.entryEndTime) def subserviceSelected(self, service): if not service is None: self.timer.service_ref = ServiceReference(service[1]) self.saveTimer() self.close((True, self.timer)) def saveTimer(self): self.session.nav.RecordTimer.saveTimer() def keyCancel(self): self.close((False,)) def pathSelected(self, res): if res is not None: if config.movielist.videodirs.value != self.timerentry_dirname.choices: self.timerentry_dirname.setChoices(config.movielist.videodirs.value, default=res) self.timerentry_dirname.value = res def tagEditFinished(self, ret): if ret is not None: self.timerentry_tags = ret self.timerentry_tagsset.setChoices([not ret and "None" or " ".join(ret)]) self["config"].invalidate(self.tagsSet)
class TimerEntry(Screen, ConfigListScreen): def __init__(self, session, timer): Screen.__init__(self, session) self.timer = timer self.entryDate = None self.entryService = None self["oktext"] = Label(_("OK")) self["canceltext"] = Label(_("Cancel")) self["ok"] = Pixmap() self["cancel"] = Pixmap() self.createConfig() self["actions"] = NumberActionMap( ["SetupActions", "GlobalActions", "PiPSetupActions"], { "ok": self.keySelect, "save": self.keyGo, "cancel": self.keyCancel, "volumeUp": self.incrementStart, "volumeDown": self.decrementStart, "size+": self.incrementEnd, "size-": self.decrementEnd }, -2) self.list = [] ConfigListScreen.__init__(self, self.list, session=session) self.setTitle(_("Timer entry")) self.createSetup("config") def createConfig(self): justplay = self.timer.justplay afterevent = { AFTEREVENT.NONE: "nothing", AFTEREVENT.DEEPSTANDBY: "deepstandby", AFTEREVENT.STANDBY: "standby", AFTEREVENT.AUTO: "auto" }[self.timer.afterEvent] if self.timer.record_ecm and self.timer.descramble: recordingtype = "descrambled+ecm" elif self.timer.record_ecm: recordingtype = "scrambled+ecm" elif self.timer.descramble: recordingtype = "normal" weekday_table = ("mon", "tue", "wed", "thu", "fri", "sat", "sun") # calculate default values day = [] weekday = 0 for x in (0, 1, 2, 3, 4, 5, 6): day.append(0) if self.timer.repeated: # repeated type = "repeated" if (self.timer.repeated == 31): # Mon-Fri repeated = "weekdays" elif (self.timer.repeated == 127): # daily repeated = "daily" else: flags = self.timer.repeated repeated = "user" count = 0 for x in (0, 1, 2, 3, 4, 5, 6): if flags == 1: # weekly print "Set to weekday " + str(x) weekday = x if flags & 1 == 1: # set user defined flags day[x] = 1 count += 1 else: day[x] = 0 flags = flags >> 1 if count == 1: repeated = "weekly" else: # once type = "once" repeated = None weekday = (int(strftime("%w", localtime(self.timer.begin))) - 1) % 7 day[weekday] = 1 self.timerentry_justplay = ConfigSelection(choices=[("zap", _("zap")), ("record", _("record"))], default={ 0: "record", 1: "zap" }[justplay]) if SystemInfo["DeepstandbySupport"]: shutdownString = _("go to deep standby") else: shutdownString = _("shut down") self.timerentry_afterevent = ConfigSelection(choices=[ ("nothing", _("do nothing")), ("standby", _("go to standby")), ("deepstandby", shutdownString), ("auto", _("auto")) ], default=afterevent) self.timerentry_recordingtype = ConfigSelection(choices=[ ("normal", _("normal")), ("descrambled+ecm", _("descramble and record ecm")), ("scrambled+ecm", _("don't descramble, record ecm")) ], default=recordingtype) self.timerentry_type = ConfigSelection(choices=[("once", _("once")), ("repeated", _("repeated"))], default=type) self.timerentry_name = ConfigText(default=self.timer.name, visible_width=50, fixed_size=False) self.timerentry_description = ConfigText( default=self.timer.description, visible_width=50, fixed_size=False) self.timerentry_tags = self.timer.tags[:] self.timerentry_tagsset = ConfigSelection(choices=[ not self.timerentry_tags and "None" or " ".join(self.timerentry_tags) ]) self.timerentry_repeated = ConfigSelection( default=repeated, choices=[("daily", _("daily")), ("weekly", _("weekly")), ("weekdays", _("Mon-Fri")), ("user", _("user defined"))]) self.timerentry_date = ConfigDateTime(default=self.timer.begin, formatstring=_("%d.%B %Y"), increment=86400) self.timerentry_starttime = ConfigClock(default=self.timer.begin) self.timerentry_endtime = ConfigClock(default=self.timer.end) self.timerentry_showendtime = ConfigSelection( default=((self.timer.end - self.timer.begin) > 4), choices=[(True, _("yes")), (False, _("no"))]) default = self.timer.dirname or defaultMoviePath() tmp = config.movielist.videodirs.value if default not in tmp: tmp.append(default) self.timerentry_dirname = ConfigSelection(default=default, choices=tmp) self.timerentry_repeatedbegindate = ConfigDateTime( default=self.timer.repeatedbegindate, formatstring=_("%d.%B %Y"), increment=86400) self.timerentry_weekday = ConfigSelection( default=weekday_table[weekday], choices=[("mon", _("Monday")), ("tue", _("Tuesday")), ("wed", _("Wednesday")), ("thu", _("Thursday")), ("fri", _("Friday")), ("sat", _("Saturday")), ("sun", _("Sunday"))]) self.timerentry_day = ConfigSubList() for x in (0, 1, 2, 3, 4, 5, 6): self.timerentry_day.append(ConfigYesNo(default=day[x])) # FIXME some service-chooser needed here servicename = "N/A" try: # no current service available? servicename = str(self.timer.service_ref.getServiceName()) except: pass self.timerentry_service_ref = self.timer.service_ref self.timerentry_service = ConfigSelection([servicename]) def createSetup(self, widget): 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.list.append(self.timerJustplayEntry) self.timerTypeEntry = getConfigListEntry(_("Repeat Type"), self.timerentry_type) self.list.append(self.timerTypeEntry) if self.timerentry_type.value == "once": self.frequencyEntry = None else: # repeated self.frequencyEntry = getConfigListEntry(_("Repeats"), self.timerentry_repeated) self.list.append(self.frequencyEntry) self.repeatedbegindateEntry = getConfigListEntry( _("Starting on"), self.timerentry_repeatedbegindate) self.list.append(self.repeatedbegindateEntry) if self.timerentry_repeated.value == "daily": pass if self.timerentry_repeated.value == "weekdays": pass if self.timerentry_repeated.value == "weekly": self.list.append( getConfigListEntry(_("Weekday"), self.timerentry_weekday)) if self.timerentry_repeated.value == "user": self.list.append( getConfigListEntry(_("Monday"), self.timerentry_day[0])) self.list.append( getConfigListEntry(_("Tuesday"), self.timerentry_day[1])) self.list.append( getConfigListEntry(_("Wednesday"), self.timerentry_day[2])) self.list.append( getConfigListEntry(_("Thursday"), self.timerentry_day[3])) self.list.append( getConfigListEntry(_("Friday"), self.timerentry_day[4])) self.list.append( getConfigListEntry(_("Saturday"), self.timerentry_day[5])) self.list.append( getConfigListEntry(_("Sunday"), self.timerentry_day[6])) self.entryDate = getConfigListEntry(_("Date"), self.timerentry_date) if self.timerentry_type.value == "once": self.list.append(self.entryDate) self.entryStartTime = getConfigListEntry(_("StartTime"), self.timerentry_starttime) self.list.append(self.entryStartTime) self.entryShowEndTime = getConfigListEntry(_("Set End Time"), self.timerentry_showendtime) if self.timerentry_justplay.value == "zap": self.list.append(self.entryShowEndTime) self.entryEndTime = getConfigListEntry(_("EndTime"), self.timerentry_endtime) if self.timerentry_justplay.value != "zap" or self.timerentry_showendtime.value: self.list.append(self.entryEndTime) self.channelEntry = getConfigListEntry(_("Channel"), self.timerentry_service) self.list.append(self.channelEntry) self.dirname = getConfigListEntry(_("Location"), self.timerentry_dirname) self.tagsSet = getConfigListEntry(_("Tags"), self.timerentry_tagsset) if self.timerentry_justplay.value != "zap": if config.usage.setup_level.index >= 2: # expert+ self.list.append(self.dirname) if getPreferredTagEditor(): self.list.append(self.tagsSet) self.list.append( getConfigListEntry(_("After event"), self.timerentry_afterevent)) self.list.append( getConfigListEntry(_("Recording type"), self.timerentry_recordingtype)) self[widget].list = self.list self[widget].l.setList(self.list) def newConfig(self): print "newConfig", self["config"].getCurrent() if self["config"].getCurrent() in (self.timerTypeEntry, self.timerJustplayEntry, self.frequencyEntry, self.entryShowEndTime): self.createSetup("config") def keyLeft(self): if self["config"].getCurrent() in (self.channelEntry, self.tagsSet): self.keySelect() else: ConfigListScreen.keyLeft(self) self.newConfig() def keyRight(self): if self["config"].getCurrent() in (self.channelEntry, self.tagsSet): self.keySelect() else: ConfigListScreen.keyRight(self) self.newConfig() def keySelect(self): cur = self["config"].getCurrent() if cur == self.channelEntry: self.session.openWithCallback( self.finishedChannelSelection, ChannelSelection.SimpleChannelSelection, _("Select channel to record from")) elif config.usage.setup_level.index >= 2 and cur == self.dirname: self.session.openWithCallback( self.pathSelected, MovieLocationBox, _("Choose target folder"), self.timerentry_dirname.value, minFree=100 # We require at least 100MB free space ) elif getPreferredTagEditor() and cur == self.tagsSet: self.session.openWithCallback(self.tagEditFinished, getPreferredTagEditor(), self.timerentry_tags) else: self.keyGo() def finishedChannelSelection(self, *args): if args: self.timerentry_service_ref = ServiceReference(args[0]) self.timerentry_service.setCurrentText( self.timerentry_service_ref.getServiceName()) self["config"].invalidate(self.channelEntry) def getTimestamp(self, date, mytime): d = localtime(date) dt = datetime(d.tm_year, d.tm_mon, d.tm_mday, mytime[0], mytime[1]) return int(mktime(dt.timetuple())) def getBeginEnd(self): date = self.timerentry_date.value endtime = self.timerentry_endtime.value starttime = self.timerentry_starttime.value begin = self.getTimestamp(date, starttime) end = self.getTimestamp(date, endtime) # if the endtime is less than the starttime, add 1 day. if end < begin: end += 86400 return begin, end def selectChannelSelector(self, *args): self.session.openWithCallback(self.finishedChannelSelectionCorrection, ChannelSelection.SimpleChannelSelection, _("Select channel to record from")) def finishedChannelSelectionCorrection(self, *args): if args: self.finishedChannelSelection(*args) self.keyGo() def keyGo(self, result=None): if not self.timerentry_service_ref.isRecordable(): self.session.openWithCallback( self.selectChannelSelector, MessageBox, _("You didn't select a channel to record from."), MessageBox.TYPE_ERROR) return self.timer.name = self.timerentry_name.value self.timer.description = self.timerentry_description.value self.timer.justplay = self.timerentry_justplay.value == "zap" if self.timerentry_justplay.value == "zap": if not self.timerentry_showendtime.value: self.timerentry_endtime.value = self.timerentry_starttime.value self.timer.resetRepeated() self.timer.afterEvent = { "nothing": AFTEREVENT.NONE, "deepstandby": AFTEREVENT.DEEPSTANDBY, "standby": AFTEREVENT.STANDBY, "auto": AFTEREVENT.AUTO }[self.timerentry_afterevent.value] self.timer.descramble = { "normal": True, "descrambled+ecm": True, "scrambled+ecm": False, }[self.timerentry_recordingtype.value] self.timer.record_ecm = { "normal": False, "descrambled+ecm": True, "scrambled+ecm": True, }[self.timerentry_recordingtype.value] self.timer.service_ref = self.timerentry_service_ref self.timer.tags = self.timerentry_tags if self.timer.dirname or self.timerentry_dirname.value != defaultMoviePath( ): self.timer.dirname = self.timerentry_dirname.value config.movielist.last_timer_videodir.value = self.timer.dirname config.movielist.last_timer_videodir.save() if self.timerentry_type.value == "once": self.timer.begin, self.timer.end = self.getBeginEnd() if self.timerentry_type.value == "repeated": if self.timerentry_repeated.value == "daily": for x in (0, 1, 2, 3, 4, 5, 6): self.timer.setRepeated(x) if self.timerentry_repeated.value == "weekly": self.timer.setRepeated(self.timerentry_weekday.index) if self.timerentry_repeated.value == "weekdays": for x in (0, 1, 2, 3, 4): self.timer.setRepeated(x) if self.timerentry_repeated.value == "user": for x in (0, 1, 2, 3, 4, 5, 6): if self.timerentry_day[x].value: self.timer.setRepeated(x) self.timer.repeatedbegindate = self.getTimestamp( self.timerentry_repeatedbegindate.value, self.timerentry_starttime.value) if self.timer.repeated: self.timer.begin = self.getTimestamp( self.timerentry_repeatedbegindate.value, self.timerentry_starttime.value) self.timer.end = self.getTimestamp( self.timerentry_repeatedbegindate.value, self.timerentry_endtime.value) else: self.timer.begin = self.getTimestamp( time.time(), self.timerentry_starttime.value) self.timer.end = self.getTimestamp( time.time(), self.timerentry_endtime.value) # when a timer end is set before the start, add 1 day if self.timer.end < self.timer.begin: self.timer.end += 86400 if self.timer.eit is not None: event = eEPGCache.getInstance().lookupEventId( self.timer.service_ref.ref, self.timer.eit) if event: n = event.getNumOfLinkageServices() if n > 1: tlist = [] ref = self.session.nav.getCurrentlyPlayingServiceReference( ) parent = self.timer.service_ref.ref selection = 0 for x in range(n): i = event.getLinkageService(parent, x) if i.toString() == ref.toString(): selection = x tlist.append((i.getName(), i)) self.session.openWithCallback( self.subserviceSelected, ChoiceBox, title=_("Please select a subservice to record..."), list=tlist, selection=selection) return elif n > 0: parent = self.timer.service_ref.ref self.timer.service_ref = ServiceReference( event.getLinkageService(parent, 0)) self.saveTimer() self.close((True, self.timer)) def incrementStart(self): self.timerentry_starttime.increment() self["config"].invalidate(self.entryStartTime) def decrementStart(self): self.timerentry_starttime.decrement() self["config"].invalidate(self.entryStartTime) def incrementEnd(self): if self.entryEndTime is not None: self.timerentry_endtime.increment() self["config"].invalidate(self.entryEndTime) def decrementEnd(self): if self.entryEndTime is not None: self.timerentry_endtime.decrement() self["config"].invalidate(self.entryEndTime) def subserviceSelected(self, service): if not service is None: self.timer.service_ref = ServiceReference(service[1]) self.saveTimer() self.close((True, self.timer)) def saveTimer(self): self.session.nav.RecordTimer.saveTimer() def keyCancel(self): self.close((False, )) def pathSelected(self, res): if res is not None: if config.movielist.videodirs.value != self.timerentry_dirname.choices: self.timerentry_dirname.setChoices( config.movielist.videodirs.value, default=res) self.timerentry_dirname.value = res def tagEditFinished(self, ret): if ret is not None: self.timerentry_tags = ret self.timerentry_tagsset.setChoices( [not ret and "None" or " ".join(ret)]) self["config"].invalidate(self.tagsSet)
def createConfig(self): justplay = self.timer.justplay always_zap = self.timer.always_zap rename_repeat = self.timer.rename_repeat afterevent = {AFTEREVENT.NONE: 'nothing', AFTEREVENT.DEEPSTANDBY: 'deepstandby', AFTEREVENT.STANDBY: 'standby', AFTEREVENT.AUTO: 'auto'}[self.timer.afterEvent] if self.timer.record_ecm and self.timer.descramble: recordingtype = 'descrambled+ecm' elif self.timer.record_ecm: recordingtype = 'scrambled+ecm' elif self.timer.descramble: recordingtype = 'normal' weekday_table = ('mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun') day = [] weekday = 0 for x in (0, 1, 2, 3, 4, 5, 6): day.append(0) if self.timer.repeated: type = 'repeated' if self.timer.repeated == 31: repeated = 'weekdays' elif self.timer.repeated == 127: repeated = 'daily' else: flags = self.timer.repeated repeated = 'user' count = 0 for x in (0, 1, 2, 3, 4, 5, 6): if flags == 1: weekday = x if flags & 1 == 1: day[x] = 1 count += 1 else: day[x] = 0 flags >>= 1 if count == 1: repeated = 'weekly' else: type = 'once' repeated = None weekday = int(strftime('%u', localtime(self.timer.begin))) - 1 day[weekday] = 1 self.timerentry_justplay = ConfigSelection(choices=[('zap', _('zap')), ('record', _('record')), ('zap+record', _('zap and record'))], default={0: 'record', 1: 'zap', 2: 'zap+record'}[justplay + 2 * always_zap]) if SystemInfo['DeepstandbySupport']: shutdownString = _('go to deep standby') else: shutdownString = _('shut down') self.timerentry_afterevent = ConfigSelection(choices=[('nothing', _('do nothing')), ('standby', _('go to standby')), ('deepstandby', shutdownString), ('auto', _('auto'))], default=afterevent) self.timerentry_recordingtype = ConfigSelection(choices=[('normal', _('normal')), ('descrambled+ecm', _('descramble and record ecm')), ('scrambled+ecm', _("don't descramble, record ecm"))], default=recordingtype) self.timerentry_type = ConfigSelection(choices=[('once', _('once')), ('repeated', _('repeated'))], default=type) self.timerentry_name = ConfigText(default=self.timer.name.replace('\xc2\x86', '').replace('\xc2\x87', '').encode('utf-8'), visible_width=50, fixed_size=False) self.timerentry_description = ConfigText(default=self.timer.description, visible_width=50, fixed_size=False) self.timerentry_tags = self.timer.tags[:] if not self.timerentry_tags: tagname = self.timer.name.strip() if tagname: tagname = tagname[0].upper() + tagname[1:].replace(' ', '_') self.timerentry_tags.append(tagname) self.timerentry_tagsset = ConfigSelection(choices=[not self.timerentry_tags and 'None' or ' '.join(self.timerentry_tags)]) self.timerentry_repeated = ConfigSelection(default=repeated, choices=[('weekly', _('weekly')), ('daily', _('daily')), ('weekdays', _('Mon-Fri')), ('user', _('user defined'))]) self.timerentry_renamerepeat = ConfigYesNo(default=rename_repeat) self.timerentry_date = ConfigDateTime(default=self.timer.begin, formatstring=_('%d %B %Y'), increment=86400) self.timerentry_starttime = ConfigClock(default=self.timer.begin) self.timerentry_endtime = ConfigClock(default=self.timer.end) self.timerentry_showendtime = ConfigSelection(default=self.timer.end > self.timer.begin + 3 and self.timer.justplay, choices=[(True, _('yes')), (False, _('no'))]) default = self.timer.dirname or defaultMoviePath() tmp = config.movielist.videodirs.value if default not in tmp: tmp.append(default) self.timerentry_dirname = ConfigSelection(default=default, choices=tmp) self.timerentry_repeatedbegindate = ConfigDateTime(default=self.timer.repeatedbegindate, formatstring=_('%d.%B %Y'), increment=86400) self.timerentry_weekday = ConfigSelection(default=weekday_table[weekday], choices=[('mon', _('Monday')), ('tue', _('Tuesday')), ('wed', _('Wednesday')), ('thu', _('Thursday')), ('fri', _('Friday')), ('sat', _('Saturday')), ('sun', _('Sunday'))]) self.timerentry_day = ConfigSubList() for x in (0, 1, 2, 3, 4, 5, 6): self.timerentry_day.append(ConfigYesNo(default=day[x])) servicename = 'N/A' try: servicename = str(self.timer.service_ref.getServiceName()) except: pass self.timerentry_service_ref = self.timer.service_ref self.timerentry_service = ConfigSelection([servicename]) return
def createConfig(self, currlocation=None, locations=[]): justplay = self.timer.justplay always_zap = self.timer.always_zap zap_wakeup = self.timer.zap_wakeup pipzap = self.timer.pipzap rename_repeat = self.timer.rename_repeat conflict_detection = self.timer.conflict_detection afterevent = { AFTEREVENT.NONE: "nothing", AFTEREVENT.DEEPSTANDBY: "deepstandby", AFTEREVENT.STANDBY: "standby", AFTEREVENT.AUTO: "auto" }[self.timer.afterEvent] if self.timer.record_ecm and self.timer.descramble: recordingtype = "descrambled+ecm" elif self.timer.record_ecm: recordingtype = "scrambled+ecm" elif self.timer.descramble: recordingtype = "normal" weekday_table = ("mon", "tue", "wed", "thu", "fri", "sat", "sun") day = list([int(x) for x in reversed('{0:07b}'.format(self.timer.repeated))]) weekday = 0 if self.timer.repeated: # repeated type = "repeated" if (self.timer.repeated == 31): # Mon-Fri repeated = "weekdays" elif (self.timer.repeated == 127): # daily repeated = "daily" else: repeated = "user" if day.count(1) == 1: repeated = "weekly" weekday = day.index(1) else: # once type = "once" repeated = None weekday = int(strftime("%u", localtime(self.timer.begin))) - 1 day[weekday] = 1 self.timerentry_fallback = ConfigYesNo(default=self.timer.external_prev or config.usage.remote_fallback_external_timer.value and config.usage.remote_fallback.value and not nimmanager.somethingConnected()) self.timerentry_justplay = ConfigSelection(choices = [ ("zap", _("zap")), ("record", _("record")), ("zap+record", _("zap and record"))], default = {0: "record", 1: "zap", 2: "zap+record"}[justplay + 2*always_zap]) if SystemInfo["DeepstandbySupport"]: shutdownString = _("go to deep standby") choicelist = [("always", _("always")), ("from_standby", _("only from standby")), ("from_deep_standby", _("only from deep standby")), ("never", _("never"))] else: shutdownString = _("shut down") choicelist = [("always", _("always")), ("never", _("never"))] self.timerentry_zapwakeup = ConfigSelection(choices = choicelist, default = zap_wakeup) self.timerentry_afterevent = ConfigSelection(choices = [("nothing", _("do nothing")), ("standby", _("go to standby")), ("deepstandby", shutdownString), ("auto", _("auto"))], default = afterevent) self.timerentry_recordingtype = ConfigSelection(choices = [("normal", _("normal")), ("descrambled+ecm", _("descramble and record ecm")), ("scrambled+ecm", _("don't descramble, record ecm"))], default = recordingtype) self.timerentry_type = ConfigSelection(choices = [("once",_("once")), ("repeated", _("repeated"))], default = type) self.timerentry_name = ConfigText(default = self.timer.name, visible_width = 50, fixed_size = False) self.timerentry_description = ConfigText(default = self.timer.description, visible_width = 50, fixed_size = False) self.timerentry_tags = self.timer.tags[:] self.timerentry_tagsset = ConfigSelection(choices = [not self.timerentry_tags and "None" or " ".join(self.timerentry_tags)]) self.timerentry_repeated = ConfigSelection(default = repeated, choices = [("weekly", _("weekly")), ("daily", _("daily")), ("weekdays", _("Mon-Fri")), ("user", _("user defined"))]) self.timerentry_renamerepeat = ConfigYesNo(default = rename_repeat) self.timerentry_pipzap = ConfigYesNo(default = pipzap) self.timerentry_conflictdetection = ConfigYesNo(default = conflict_detection) self.timerentry_date = ConfigDateTime(default = self.timer.begin, formatstring = _("%d.%B %Y"), increment = 86400) self.timerentry_starttime = ConfigClock(default = self.timer.begin) self.timerentry_endtime = ConfigClock(default = self.timer.end) self.timerentry_showendtime = ConfigSelection(default = ((self.timer.end - self.timer.begin) > 4), choices = [(True, _("yes")), (False, _("no"))]) default = not self.timer.external_prev and self.timer.dirname or defaultMoviePath() tmp = config.movielist.videodirs.value if default not in tmp: tmp.append(default) self.timerentry_dirname = ConfigSelection(default = default, choices = tmp) default = self.timer.external_prev and self.timer.dirname or currlocation if default not in locations: locations.append(default) self.timerentry_fallbackdirname = ConfigSelection(default=default, choices=locations) self.timerentry_repeatedbegindate = ConfigDateTime(default = self.timer.repeatedbegindate, formatstring = _("%d.%B %Y"), increment = 86400) self.timerentry_weekday = ConfigSelection(default = weekday_table[weekday], choices = [("mon",_("Monday")), ("tue", _("Tuesday")), ("wed",_("Wednesday")), ("thu", _("Thursday")), ("fri", _("Friday")), ("sat", _("Saturday")), ("sun", _("Sunday"))]) self.timerentry_day = ConfigSubList() for x in (0, 1, 2, 3, 4, 5, 6): self.timerentry_day.append(ConfigYesNo(default = day[x])) # FIXME some service-chooser needed here servicename = "N/A" try: # no current service available? servicename = str(self.timer.service_ref.getServiceName()) except: pass self.timerentry_service_ref = self.timer.service_ref self.timerentry_service = ConfigSelection([servicename]) self.createSetup("config")
def createConfig(self): justplay = self.timer.justplay afterevent = { AFTEREVENT.NONE: "nothing", AFTEREVENT.DEEPSTANDBY: "deepstandby", AFTEREVENT.STANDBY: "standby", AFTEREVENT.AUTO: "auto" }[self.timer.afterEvent] weekday_table = ("mon", "tue", "wed", "thu", "fri", "sat", "sun") # calculate default values day = [] weekday = 0 for x in (0, 1, 2, 3, 4, 5, 6): day.append(0) if self.timer.repeated: # repeated type = "repeated" if (self.timer.repeated == 31): # Mon-Fri repeated = "weekdays" elif (self.timer.repeated == 127): # daily repeated = "daily" else: flags = self.timer.repeated repeated = "user" count = 0 for x in (0, 1, 2, 3, 4, 5, 6): if flags == 1: # weekly print "Set to weekday " + str(x) weekday = x if flags & 1 == 1: # set user defined flags day[x] = 1 count += 1 else: day[x] = 0 flags = flags >> 1 if count == 1: repeated = "weekly" else: # once type = "once" repeated = None weekday = (int(strftime("%w", localtime(self.timer.begin))) - 1) % 7 day[weekday] = 1 if not config.misc.recording_allowed.value: self.timerentry_justplay = ConfigSelection(choices = [("zap", _("zap"))], default = "zap") else: tmp_dir = self.timer.dirname or defaultMoviePath() if not harddiskmanager.inside_mountpoint(tmp_dir): justplay = 1 justplay_default = {0: "record", 1: "zap"}[justplay] self.timerentry_justplay = ConfigSelection(choices = [("zap", _("zap")), ("record", _("record"))], default = justplay_default) if SystemInfo["DeepstandbySupport"]: shutdownString = _("go to standby") else: shutdownString = _("shut down") self.timerentry_afterevent = ConfigSelection(choices = [("nothing", _("do nothing")), ("standby", _("go to idle mode")), ("deepstandby", shutdownString), ("auto", _("auto"))], default = afterevent) self.timerentry_type = ConfigSelection(choices = [("once",_("once")), ("repeated", _("repeated"))], default = type) self.timerentry_name = ConfigText(default = self.timer.name, visible_width = 50, fixed_size = False) self.timerentry_description = ConfigText(default = self.timer.description, visible_width = 50, fixed_size = False) self.timerentry_tags = self.timer.tags[:] self.timerentry_tagsset = ConfigSelection(choices = [not self.timerentry_tags and "None" or " ".join(self.timerentry_tags)]) self.timerentry_repeated = ConfigSelection(default = repeated, choices = [("daily", _("daily")), ("weekly", _("weekly")), ("weekdays", _("Mon-Fri")), ("user", _("user defined"))]) self.timerentry_date = ConfigDateTime(default = self.timer.begin, formatstring = _("%d.%B %Y"), increment = 86400) self.timerentry_starttime = ConfigClock(default = self.timer.begin) self.timerentry_endtime = ConfigClock(default = self.timer.end) self.timerentry_showendtime = ConfigSelection(default = ((self.timer.end - self.timer.begin) > 4), choices = [(True, _("yes")), (False, _("no"))]) default = self.timer.dirname or defaultMoviePath() tmp = config.movielist.videodirs.value if default not in tmp: tmp.append(default) self.timerentry_dirname = ConfigSelection(default = default, choices = tmp) self.timerentry_repeatedbegindate = ConfigDateTime(default = self.timer.repeatedbegindate, formatstring = _("%d.%B %Y"), increment = 86400) self.timerentry_weekday = ConfigSelection(default = weekday_table[weekday], choices = [("mon",_("Monday")), ("tue", _("Tuesday")), ("wed",_("Wednesday")), ("thu", _("Thursday")), ("fri", _("Friday")), ("sat", _("Saturday")), ("sun", _("Sunday"))]) self.timerentry_day = ConfigSubList() for x in (0, 1, 2, 3, 4, 5, 6): self.timerentry_day.append(ConfigYesNo(default = day[x])) try: # no current service available? servicename = str(self.timer.service_ref.getServiceName()) except: pass servicename = servicename or "N/A" self.timerentry_service_ref = self.timer.service_ref self.timerentry_service = ConfigSelection([servicename]) self.timerentry_plugins = {} if config.usage.setup_level.index >= 2: from Plugins.Plugin import PluginDescriptor from Components.PluginComponent import plugins missing = self.timer.plugins.keys() for p in plugins.getPlugins(PluginDescriptor.WHERE_TIMEREDIT): if p.__call__.has_key("setupFnc"): setupFnc = p.__call__["setupFnc"] if setupFnc is not None: if p.__call__.has_key("configListEntry"): entry = p.__call__["configListEntry"]() pdata = None if p.name in self.timer.plugins: pval = self.timer.plugins[p.name][0] pdata = self.timer.plugins[p.name][1] try: if isinstance(entry[1].value, bool): entry[1].value = (pval == "True") elif isinstance(entry[1].value, str): entry[1].value = str(pval) elif isinstance(entry[1].value, int): entry[1].value = int(pval) except ValueError: print "could not get config_val", pval, type(pval), "for WHERE_TIMEREDIT plugin:", p.name break self.timerentry_plugins[entry] = [p.name, setupFnc, pdata] # [plugin name, function call for plugin setup, plugin private data] if p.name in missing: missing.remove(p.name) if len(missing): print "could not setup WHERE_TIMEREDIT plugin(s):", missing
# ENIGMA IMPORTS from Components.config import config, ConfigSubsection, ConfigText, ConfigSelection, ConfigYesNo, NoSave, ConfigClock, ConfigInteger from Components.PluginComponent import plugins from Plugins.Plugin import PluginDescriptor # for localized messages from . import _ config.plugins.birthdayreminder = ConfigSubsection() config.plugins.birthdayreminder.file = ConfigText(default="/etc/enigma2/birthdayreminder") config.plugins.birthdayreminder.dateFormat = ConfigSelection(default="ddmmyyyy", choices=[("ddmmyyyy", "DD.MM.YYYY"), ("mmddyyyy", "MM/DD/YYYY")]) config.plugins.birthdayreminder.broadcasts = ConfigYesNo(default=True) config.plugins.birthdayreminder.preremind = ConfigSelection(default="7", choices=[("-1", _("Disabled")), ("1", _("1 day")), ("3", _("3 days")), ("7", _("1 week"))]) config.plugins.birthdayreminder.preremindChanged = NoSave(ConfigYesNo(default=False)) config.plugins.birthdayreminder.notificationTime = ConfigClock(default=64800) # 19:00 config.plugins.birthdayreminder.notificationTimeChanged = NoSave(ConfigYesNo(default=False)) config.plugins.birthdayreminder.sortby = ConfigSelection(default="1", choices=[ ("1", _("Name")), ("2", _("Next birthday")), ("3", _("Age")) ]) config.plugins.birthdayreminder.showInExtensions = ConfigYesNo(default=False) config.plugins.birthdayreminder.broadcastPort = ConfigInteger(default=7374, limits=(1024, 49151)) birthdaytimer = BirthdayTimer() def settings(session, **kwargs): session.open(BirthdayReminderSettings, birthdaytimer)
class TimerEntry(Screen, ConfigListScreen): def __init__(self, session, timer): Screen.__init__(self, session) self.timer = timer self.entryDate = None self.entryService = None self["HelpWindow"] = Pixmap() self["HelpWindow"].hide() self["oktext"] = Label(_("OK")) self["canceltext"] = Label(_("Cancel")) self["ok"] = Pixmap() self["cancel"] = Pixmap() # self["summary_description"] = StaticText("") self["description"] = Label("") self.createConfig() self["actions"] = NumberActionMap( ["SetupActions", "GlobalActions", "PiPSetupActions"], { "ok": self.keySelect, "save": self.keyGo, "cancel": self.keyCancel, "volumeUp": self.incrementStart, "volumeDown": self.decrementStart, "size+": self.incrementEnd, "size-": self.decrementEnd, "up": self.keyUp, "down": self.keyDown, }, -2, ) self.list = [] ConfigListScreen.__init__(self, self.list, session=session) self.setTitle(_("PowerManager entry")) self.createSetup("config") def createConfig(self): afterevent = { AFTEREVENT.NONE: "nothing", AFTEREVENT.WAKEUP: "wakeup", AFTEREVENT.WAKEUPTOSTANDBY: "wakeuptostandby", AFTEREVENT.STANDBY: "standby", AFTEREVENT.DEEPSTANDBY: "deepstandby", }[self.timer.afterEvent] 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.timer.timerType] weekday_table = ("mon", "tue", "wed", "thu", "fri", "sat", "sun") time_table = [ (1, "1"), (3, "3"), (5, "5"), (10, "10"), (15, "15"), (30, "30"), (45, "45"), (60, "60"), (75, "75"), (90, "90"), (105, "105"), (120, "120"), (135, "135"), (150, "150"), (165, "165"), (180, "180"), (195, "195"), (210, "210"), (225, "225"), (240, "240"), (255, "255"), (270, "270"), (285, "285"), (300, "300"), ] traffic_table = [(10, "10"), (50, "50"), (100, "100"), (500, "500"), (1000, "1000")] # calculate default values day = [] weekday = 0 for x in (0, 1, 2, 3, 4, 5, 6): day.append(0) if self.timer.repeated: # repeated type = "repeated" if self.timer.repeated == 31: # Mon-Fri repeated = "weekdays" elif self.timer.repeated == 127: # daily repeated = "daily" else: flags = self.timer.repeated repeated = "user" count = 0 for x in (0, 1, 2, 3, 4, 5, 6): if flags == 1: # weekly print "Set to weekday " + str(x) weekday = x if flags & 1 == 1: # set user defined flags day[x] = 1 count += 1 else: day[x] = 0 flags >>= 1 if count == 1: repeated = "weekly" else: # once type = "once" repeated = None weekday = int(strftime("%u", localtime(self.timer.begin))) - 1 day[weekday] = 1 if SystemInfo["DeepstandbySupport"]: shutdownString = _("go to deep standby") else: shutdownString = _("shut down") self.timerentry_timertype = ConfigSelection( choices=[ ("nothing", _("do nothing")), ("wakeup", _("wakeup")), ("wakeuptostandby", _("wakeup to standby")), ("autostandby", _("auto standby")), ("autodeepstandby", _("auto deepstandby")), ("standby", _("go to standby")), ("deepstandby", shutdownString), ("reboot", _("reboot system")), ("restart", _("restart GUI")), ], default=timertype, ) self.timerentry_afterevent = ConfigSelection( choices=[ ("nothing", _("do nothing")), ("wakeup", _("wakeup")), ("wakeuptostandby", _("wakeup to standby")), ("standby", _("go to standby")), ("deepstandby", shutdownString), ("nothing", _("do nothing")), ], default=afterevent, ) self.timerentry_type = ConfigSelection(choices=[("once", _("once")), ("repeated", _("repeated"))], default=type) self.timerentry_repeated = ConfigSelection( default=repeated, choices=[ ("daily", _("daily")), ("weekly", _("weekly")), ("weekdays", _("Mon-Fri")), ("user", _("user defined")), ], ) self.timerrntry_autosleepdelay = ConfigSelection(choices=time_table, default=self.timer.autosleepdelay) self.timerentry_autosleeprepeat = ConfigSelection( choices=[("once", _("once")), ("repeated", _("repeated"))], default=self.timer.autosleeprepeat ) self.timerrntry_autosleepinstandbyonly = ConfigSelection( choices=[("yes", _("only in Standby")), ("no", _("Standard (always)")), ("noquery", _("without Query"))], default=self.timer.autosleepinstandbyonly, ) self.timerrntry_autosleepwindow = ConfigSelection( choices=[("yes", _("Yes")), ("no", _("No"))], default=self.timer.autosleepwindow ) self.timerrntry_autosleepbegin = ConfigClock(default=self.timer.autosleepbegin) self.timerrntry_autosleepend = ConfigClock(default=self.timer.autosleepend) self.timerentry_date = ConfigDateTime(default=self.timer.begin, formatstring=_("%d.%B %Y"), increment=86400) self.timerentry_starttime = ConfigClock(default=self.timer.begin) self.timerentry_endtime = ConfigClock(default=self.timer.end) self.timerentry_showendtime = ConfigSelection( default=(((self.timer.end - self.timer.begin) / 60) > 4), choices=[(True, _("yes")), (False, _("no"))] ) self.timerentry_repeatedbegindate = ConfigDateTime( default=self.timer.repeatedbegindate, formatstring=_("%d.%B %Y"), increment=86400 ) self.timerentry_weekday = ConfigSelection( default=weekday_table[weekday], choices=[ ("mon", _("Monday")), ("tue", _("Tuesday")), ("wed", _("Wednesday")), ("thu", _("Thursday")), ("fri", _("Friday")), ("sat", _("Saturday")), ("sun", _("Sunday")), ], ) self.timerentry_day = ConfigSubList() for x in (0, 1, 2, 3, 4, 5, 6): self.timerentry_day.append(ConfigYesNo(default=day[x])) self.timerrntry_showExtended = ConfigSelection( default=(self.timer.nettraffic == "yes" or self.timer.netip == "yes"), choices=[(True, _("yes")), (False, _("no"))], ) self.timerrntry_nettraffic = ConfigSelection( choices=[("yes", _("Yes")), ("no", _("No"))], default=self.timer.nettraffic ) self.timerrntry_trafficlimit = ConfigSelection(choices=traffic_table, default=self.timer.trafficlimit) self.timerrntry_netip = ConfigSelection(choices=[("yes", _("Yes")), ("no", _("No"))], default=self.timer.netip) self.timerrntry_ipadress = self.timer.ipadress.split(",") self.ipcount = ConfigSelectionNumber(default=len(self.timerrntry_ipadress), stepwidth=1, min=1, max=5) self.ipadressEntry = ConfigSubList() for x in (0, 1, 2, 3, 4, 5): try: self.ipadressEntry.append( ConfigIP(default=[int(n) for n in self.timerrntry_ipadress[x].split(".")] or [0, 0, 0, 0]) ) except: self.ipadressEntry.append(ConfigIP(default=[0, 0, 0, 0])) def createSetup(self, widget): self.list = [] self.timerType = getConfigListEntry(_("Timer type"), self.timerentry_timertype) self.list.append(self.timerType) self.timerTypeEntry = getConfigListEntry(_("Repeat type"), self.timerentry_type) self.entryStartTime = getConfigListEntry(_("Start time"), self.timerentry_starttime) self.entryShowEndTime = getConfigListEntry(_("Set end time"), self.timerentry_showendtime) self.entryEndTime = getConfigListEntry(_("End time"), self.timerentry_endtime) self.frequencyEntry = getConfigListEntry(_("Repeats"), self.timerentry_repeated) self.entryDate = getConfigListEntry(_("Date"), self.timerentry_date) self.repeatedbegindateEntry = getConfigListEntry(_("Starting on"), self.timerentry_repeatedbegindate) self.autosleepwindowEntry = getConfigListEntry( _("Restrict the active time range"), self.timerrntry_autosleepwindow ) self.netExtendedEntry = getConfigListEntry(_("Show advanced settings"), self.timerrntry_showExtended) self.nettrafficEntry = getConfigListEntry(_("Enable Network Traffic check"), self.timerrntry_nettraffic) self.netipEntry = getConfigListEntry(_("Enable Network IP address check"), self.timerrntry_netip) self.ipcountEntry = getConfigListEntry(_("Select of the number"), self.ipcount) if self.timerentry_timertype.value == "autostandby" or self.timerentry_timertype.value == "autodeepstandby": if self.timerentry_timertype.value == "autodeepstandby": self.list.append( getConfigListEntry( _("Execution condition"), self.timerrntry_autosleepinstandbyonly, _( "The setting 'without query' is the same as 'standard' without additional confirmation query. All other dependencies (e.g. recordings, time range) stay persist." ), ) ) self.list.append(getConfigListEntry(_("Sleep delay"), self.timerrntry_autosleepdelay)) self.list.append(getConfigListEntry(_("Repeat type"), self.timerentry_autosleeprepeat)) self.list.append(self.autosleepwindowEntry) if self.timerrntry_autosleepwindow.value == "yes": self.list.append(getConfigListEntry(_("Start time"), self.timerrntry_autosleepbegin)) self.list.append(getConfigListEntry(_("End time"), self.timerrntry_autosleepend)) if self.timerentry_timertype.value == "autodeepstandby": self.list.append(self.netExtendedEntry) if self.timerrntry_showExtended.value: self.list.append(self.nettrafficEntry) if self.timerrntry_nettraffic.value == "yes": self.list.append( getConfigListEntry( _("Lower limit in kilobits per seconds [kbit/s]"), self.timerrntry_trafficlimit ) ) self.list.append(self.netipEntry) if self.timerrntry_netip.value == "yes": self.list.append(self.ipcountEntry) for x in range(0, self.ipcount.value): self.list.append( getConfigListEntry(("%d. " + _("IP address")) % (x + 1), self.ipadressEntry[x]) ) else: self.list.append(self.timerTypeEntry) if self.timerentry_type.value == "once": self.frequencyEntry = None else: # repeated self.list.append(self.frequencyEntry) self.list.append(self.repeatedbegindateEntry) if self.timerentry_repeated.value == "daily": pass if self.timerentry_repeated.value == "weekdays": pass if self.timerentry_repeated.value == "weekly": self.list.append(getConfigListEntry(_("Weekday"), self.timerentry_weekday)) if self.timerentry_repeated.value == "user": self.list.append(getConfigListEntry(_("Monday"), self.timerentry_day[0])) self.list.append(getConfigListEntry(_("Tuesday"), self.timerentry_day[1])) self.list.append(getConfigListEntry(_("Wednesday"), self.timerentry_day[2])) self.list.append(getConfigListEntry(_("Thursday"), self.timerentry_day[3])) self.list.append(getConfigListEntry(_("Friday"), self.timerentry_day[4])) self.list.append(getConfigListEntry(_("Saturday"), self.timerentry_day[5])) self.list.append(getConfigListEntry(_("Sunday"), self.timerentry_day[6])) if self.timerentry_type.value == "once": self.list.append(self.entryDate) self.list.append(self.entryStartTime) self.list.append(self.entryShowEndTime) if self.timerentry_showendtime.value: self.list.append(self.entryEndTime) self.list.append(getConfigListEntry(_("After event"), self.timerentry_afterevent)) self[widget].list = self.list self[widget].l.setList(self.list) self.checkSummary() def createSummary(self): pass def checkSummary(self): # self["summary_description"].text = self["config"].getCurrent()[0] if len(self["config"].getCurrent()) > 2 and self["config"].getCurrent()[2]: self["description"].setText(self["config"].getCurrent()[2]) else: self["description"].setText("") def newConfig(self): if self["config"].getCurrent() in ( self.timerType, self.timerTypeEntry, self.frequencyEntry, self.entryShowEndTime, self.autosleepwindowEntry, self.netExtendedEntry, self.nettrafficEntry, self.netipEntry, self.ipcountEntry, ): self.createSetup("config") def keyLeft(self): ConfigListScreen.keyLeft(self) self.newConfig() def keyRight(self): ConfigListScreen.keyRight(self) self.newConfig() def keySelect(self): cur = self["config"].getCurrent() self.keyGo() def keyUp(self): self["config"].moveUp() self.checkSummary() def keyDown(self): self["config"].moveDown() self.checkSummary() def getTimestamp(self, date, mytime): d = localtime(date) dt = datetime(d.tm_year, d.tm_mon, d.tm_mday, mytime[0], mytime[1]) return int(mktime(dt.timetuple())) def getBeginEnd(self): date = self.timerentry_date.value endtime = self.timerentry_endtime.value starttime = self.timerentry_starttime.value begin = self.getTimestamp(date, starttime) end = self.getTimestamp(date, endtime) # if the endtime is less than the starttime, add 1 day. if end < begin: end += 86400 return begin, end def keyGo(self, result=None): if not self.timerentry_showendtime.value: self.timerentry_endtime.value = self.timerentry_starttime.value self.timer.resetRepeated() if self.timerentry_type.value == "once": self.timer.begin, self.timer.end = self.getBeginEnd() if self.timerentry_timertype.value == "autostandby" or self.timerentry_timertype.value == "autodeepstandby": self.timer.begin = int(time()) + 10 self.timer.end = self.timer.begin self.timer.autosleepinstandbyonly = self.timerrntry_autosleepinstandbyonly.value self.timer.autosleepdelay = self.timerrntry_autosleepdelay.value self.timer.autosleeprepeat = self.timerentry_autosleeprepeat.value self.timerentry_showendtime.value = False if self.timerentry_type.value == "repeated": if self.timerentry_repeated.value == "daily": for x in (0, 1, 2, 3, 4, 5, 6): self.timer.setRepeated(x) if self.timerentry_repeated.value == "weekly": self.timer.setRepeated(self.timerentry_weekday.index) if self.timerentry_repeated.value == "weekdays": for x in (0, 1, 2, 3, 4): self.timer.setRepeated(x) if self.timerentry_repeated.value == "user": for x in (0, 1, 2, 3, 4, 5, 6): if self.timerentry_day[x].value: self.timer.setRepeated(x) self.timer.repeatedbegindate = self.getTimestamp( self.timerentry_repeatedbegindate.value, self.timerentry_starttime.value ) if self.timer.repeated: self.timer.begin = self.getTimestamp( self.timerentry_repeatedbegindate.value, self.timerentry_starttime.value ) self.timer.end = self.getTimestamp( self.timerentry_repeatedbegindate.value, self.timerentry_endtime.value ) else: self.timer.begin = self.getTimestamp(time(), self.timerentry_starttime.value) self.timer.end = self.getTimestamp(time(), self.timerentry_endtime.value) # when a timer end is set before the start, add 1 day if self.timer.end < self.timer.begin: self.timer.end += 86400 endaction = self.timerentry_showendtime.value if (self.timer.end - self.timer.begin) / 60 < 5 or self.timerentry_showendtime.value is False: self.timerentry_afterevent.value = "nothing" self.timer.end = self.timer.begin if endaction: self.session.open( MessageBox, _( "Difference between timer begin and end must be equal or greater than %d minutes.\nEnd Action was disabled !" ) % 5, MessageBox.TYPE_INFO, timeout=30, ) self.timer.timerType = { "nothing": TIMERTYPE.NONE, "wakeup": TIMERTYPE.WAKEUP, "wakeuptostandby": TIMERTYPE.WAKEUPTOSTANDBY, "autostandby": TIMERTYPE.AUTOSTANDBY, "autodeepstandby": TIMERTYPE.AUTODEEPSTANDBY, "standby": TIMERTYPE.STANDBY, "deepstandby": TIMERTYPE.DEEPSTANDBY, "reboot": TIMERTYPE.REBOOT, "restart": TIMERTYPE.RESTART, }[self.timerentry_timertype.value] self.timer.afterEvent = { "nothing": AFTEREVENT.NONE, "wakeup": AFTEREVENT.WAKEUP, "wakeuptostandby": AFTEREVENT.WAKEUPTOSTANDBY, "standby": AFTEREVENT.STANDBY, "deepstandby": AFTEREVENT.DEEPSTANDBY, }[self.timerentry_afterevent.value] self.timer.autosleepwindow = self.timerrntry_autosleepwindow.value self.timer.autosleepbegin = self.getTimestamp(time(), self.timerrntry_autosleepbegin.value) self.timer.autosleepend = self.getTimestamp(time(), self.timerrntry_autosleepend.value) self.timer.nettraffic = self.timerrntry_nettraffic.value self.timer.trafficlimit = self.timerrntry_trafficlimit.value self.timer.netip = self.timerrntry_netip.value self.timer.ipadress = "%d.%d.%d.%d" % ( self.ipadressEntry[0].value[0], self.ipadressEntry[0].value[1], self.ipadressEntry[0].value[2], self.ipadressEntry[0].value[3], ) for x in range(1, self.ipcount.value): self.timer.ipadress += ",%d.%d.%d.%d" % ( self.ipadressEntry[x].value[0], self.ipadressEntry[x].value[1], self.ipadressEntry[x].value[2], self.ipadressEntry[x].value[3], ) self.saveTimer() self.close((True, self.timer)) def incrementStart(self): self.timerentry_starttime.increment() self["config"].invalidate(self.entryStartTime) if self.timerentry_type.value == "once" and self.timerentry_starttime.value == [0, 0]: self.timerentry_date.value += 86400 self["config"].invalidate(self.entryDate) def decrementStart(self): self.timerentry_starttime.decrement() self["config"].invalidate(self.entryStartTime) if self.timerentry_type.value == "once" and self.timerentry_starttime.value == [23, 59]: self.timerentry_date.value -= 86400 self["config"].invalidate(self.entryDate) def incrementEnd(self): if self.entryEndTime is not None: self.timerentry_endtime.increment() self["config"].invalidate(self.entryEndTime) def decrementEnd(self): if self.entryEndTime is not None: self.timerentry_endtime.decrement() self["config"].invalidate(self.entryEndTime) def saveTimer(self): self.session.nav.PowerTimer.saveTimer() def keyCancel(self): self.close((False,))
"temp": _("HDD Temperature") } timsetlist = { "none": _("None"), "off": _("Fan - Off"), "on": _("Fan - On"), "auto": _("Fan - Auto") } syswatchlist = {"off": _("Off"), "on": _("On")} config.plugins.FanSetup = ConfigSubsection() config.plugins.FanSetup.mode = ConfigSelection(choices=modelist, default="auto") config.plugins.FanSetup.timeset = ConfigSelection(choices=timsetlist, default="none") config.plugins.FanSetup.timestartoff = ConfigClock(default=((21 * 60 + 30) * 60)) config.plugins.FanSetup.timeendoff = ConfigClock(default=((7 * 60 + 0) * 60)) config.plugins.FanSetup.hddwatch = ConfigSelection(choices=hddwatchlist, default="none") config.plugins.FanSetup.hdddevice = ConfigText(default="all") config.plugins.FanSetup.hddsleep = ConfigBoolean(default=False) config.plugins.FanSetup.hddtemp = ConfigInteger(0, limits=(0, 80)) config.plugins.FanSetup.menuhdd = ConfigYesNo(default=False) config.plugins.FanSetup.fanspeed = ConfigSlider(default=127, increment=8, limits=(0, 255)) config.plugins.FanSetup.systemtemp = ConfigInteger(40, limits=(15, 80)) config.plugins.FanSetup.systempwatch = ConfigSelection(choices=syswatchlist, default="off")
gPushService = None # Config options config.pushservice = ConfigSubsection() config.pushservice.about = ConfigNothing() config.pushservice.enable = ConfigEnableDisable(default=True) config.pushservice.boxname = ConfigText(default="Enigma2", fixed_size=False) config.pushservice.xmlpath = ConfigText(default="/etc/enigma2/pushservice.xml", fixed_size=False) config.pushservice.runonboot = ConfigEnableDisable(default=True) config.pushservice.bootdelay = ConfigSelectionNumber(5, 1000, 5, default=10) config.pushservice.time = ConfigClock(default=0) config.pushservice.period = ConfigSelectionNumber(0, 1000, 1, default=24) ####################################################### # Plugin configuration def setup(session, **kwargs): try: ### For testing only from six.moves import reload_module from . import ConfigScreen reload_module(ConfigScreen) ### session.open(ConfigScreen.ConfigScreen) except Exception as e: print(_("PushService setup exception ") + str(e))
SKINLIST = [ # order is important (HD_BORDER, XD_BORDER, SD, HD, XD)! (resolveFilename(SCOPE_PLUGIN, ''.join([SKINDIR, "HD_border.xml"])), "HD_border.xml"), (resolveFilename(SCOPE_PLUGIN, ''.join([SKINDIR, "XD_border.xml"])), "XD_border.xml"), (resolveFilename(SCOPE_PLUGIN, ''.join([SKINDIR, "SD_default.xml"])), "SD_default.xml"), (resolveFilename(SCOPE_PLUGIN, ''.join([SKINDIR, "HD_default.xml"])), "HD_default.xml"), (resolveFilename(SCOPE_PLUGIN, ''.join([SKINDIR, "XD_default.xml"])), "XD_default.xml") ] config.plugins.merlinEpgCenter = ConfigSubsection() config.plugins.merlinEpgCenter.primeTime = ConfigClock(default=69300) config.plugins.merlinEpgCenter.showListNumbers = ConfigYesNo(True) config.plugins.merlinEpgCenter.showPicons = ConfigYesNo(False) config.plugins.merlinEpgCenter.showServiceName = ConfigYesNo(True) config.plugins.merlinEpgCenter.lastUsedTab = ConfigInteger(0) config.plugins.merlinEpgCenter.showEventInfo = ConfigYesNo(True) config.plugins.merlinEpgCenter.showVideoPicture = ConfigYesNo(True) config.plugins.merlinEpgCenter.rememberLastTab = ConfigYesNo(True) config.plugins.merlinEpgCenter.selectRunningService = ConfigYesNo(True) config.plugins.merlinEpgCenter.replaceInfobarEpg = ConfigYesNo(False) config.plugins.merlinEpgCenter.epgPaths = ConfigSelection( default=eEnv.resolve('${datadir}/enigma2/picon_50x30/'), choices=[ (eEnv.resolve('${datadir}/enigma2/picon_50x30/'), eEnv.resolve('${datadir}/enigma2/picon_50x30')), ('/media/cf/picon_50x30/', '/media/cf/picon_50x30'),
def createConfig(self): justplay = self.timer.justplay always_zap = self.timer.always_zap pipzap = self.timer.pipzap rename_repeat = self.timer.rename_repeat conflict_detection = self.timer.conflict_detection afterevent = { AFTEREVENT.NONE: "nothing", AFTEREVENT.DEEPSTANDBY: "deepstandby", AFTEREVENT.STANDBY: "standby", AFTEREVENT.AUTO: "auto" }[self.timer.afterEvent] if self.timer.record_ecm and self.timer.descramble: recordingtype = "descrambled+ecm" elif self.timer.record_ecm: recordingtype = "scrambled+ecm" elif self.timer.descramble: recordingtype = "normal" weekday_table = ("mon", "tue", "wed", "thu", "fri", "sat", "sun") # calculate default values day = [] weekday = 0 for x in (0, 1, 2, 3, 4, 5, 6): day.append(0) if self.timer.repeated: # repeated type = "repeated" if self.timer.repeated == 31: # Mon-Fri repeated = "weekdays" elif self.timer.repeated == 127: # daily repeated = "daily" else: flags = self.timer.repeated repeated = "user" count = 0 for x in (0, 1, 2, 3, 4, 5, 6): if flags == 1: # weekly # print "Set to weekday " + str(x) weekday = x if flags & 1 == 1: # set user defined flags day[x] = 1 count += 1 else: day[x] = 0 flags >>= 1 if count == 1: repeated = "weekly" else: # once type = "once" repeated = None weekday = int(strftime("%u", localtime(self.timer.begin))) - 1 day[weekday] = 1 self.timerentry_justplay = ConfigSelection(choices = [ ("zap", _("zap")), ("record", _("record")), ("zap+record", _("zap and record"))], default = {0: "record", 1: "zap", 2: "zap+record"}[justplay + 2*always_zap]) if SystemInfo["DeepstandbySupport"]: shutdownString = _("go to deep standby") else: shutdownString = _("shut down") self.timerentry_afterevent = ConfigSelection(choices = [("nothing", _("do nothing")), ("standby", _("go to standby")), ("deepstandby", shutdownString), ("auto", _("auto"))], default = afterevent) self.timerentry_recordingtype = ConfigSelection(choices = [("normal", _("normal")), ("descrambled+ecm", _("descramble and record ecm")), ("scrambled+ecm", _("don't descramble, record ecm"))], default = recordingtype) self.timerentry_type = ConfigSelection(choices = [("once",_("once")), ("repeated", _("repeated"))], default = type) self.timerentry_name = ConfigText(default = self.timer.name.replace('\xc2\x86', '').replace('\xc2\x87', '').encode("utf-8"), visible_width = 50, fixed_size = False) self.timerentry_description = ConfigText(default = self.timer.description, visible_width = 50, fixed_size = False) self.timerentry_tags = self.timer.tags[:] # if no tags found, make name of event default tag set. if not self.timerentry_tags: tagname = self.timer.name.strip() if tagname: tagname = tagname[0].upper() + tagname[1:].replace(" ", "_") self.timerentry_tags.append(tagname) self.timerentry_tagsset = ConfigSelection(choices = [not self.timerentry_tags and "None" or " ".join(self.timerentry_tags)]) self.timerentry_repeated = ConfigSelection(default = repeated, choices = [("weekly", _("weekly")), ("daily", _("daily")), ("weekdays", _("Mon-Fri")), ("user", _("user defined"))]) self.timerentry_renamerepeat = ConfigYesNo(default = rename_repeat) self.timerentry_pipzap = ConfigYesNo(default = pipzap) self.timerentry_conflictdetection = ConfigYesNo(default = conflict_detection) self.timerentry_date = ConfigDateTime(default = self.timer.begin, formatstring = config.usage.date.full.value, increment = 86400) self.timerentry_starttime = ConfigClock(default = self.timer.begin) self.timerentry_endtime = ConfigClock(default = self.timer.end) self.timerentry_showendtime = ConfigSelection(default = False, choices = [(True, _("yes")), (False, _("no"))]) default = self.timer.dirname or defaultMoviePath() tmp = config.movielist.videodirs.value if default not in tmp: tmp.append(default) self.timerentry_dirname = ConfigSelection(default = default, choices = tmp) self.timerentry_repeatedbegindate = ConfigDateTime(default = self.timer.repeatedbegindate, formatstring = config.usage.date.full.value, increment = 86400) self.timerentry_weekday = ConfigSelection(default = weekday_table[weekday], choices = [("mon",_("Monday")), ("tue", _("Tuesday")), ("wed",_("Wednesday")), ("thu", _("Thursday")), ("fri", _("Friday")), ("sat", _("Saturday")), ("sun", _("Sunday"))]) self.timerentry_day = ConfigSubList() for x in (0, 1, 2, 3, 4, 5, 6): self.timerentry_day.append(ConfigYesNo(default = day[x])) # FIXME some service-chooser needed here servicename = "N/A" try: # no current service available? servicename = str(self.timer.service_ref.getServiceName()) except: pass self.timerentry_service_ref = self.timer.service_ref self.timerentry_service = ConfigSelection([servicename])
arealist.append(("4101 0d", "Tyne HD")) arealist.append(("4097 0d", "Tyne SD")) arealist.append(("4101 19", "West Anglia HD")) arealist.append(("4097 19", "West Anglia SD")) arealist.append(("4103 43", "West Dorset HD")) arealist.append(("4099 43", "West Dorset SD")) arealist.append(("4101 06", "Westcountry HD")) arealist.append(("4097 06", "Westcountry SD")) from Components.config import config, configfile, ConfigSubsection, ConfigYesNo, ConfigSelection, ConfigText, ConfigNumber, NoSave, ConfigClock, getConfigListEntry config.autobouquets = ConfigSubsection() config.autobouquets.area = ConfigSelection(default=None, choices=arealist) config.autobouquets.hdasfirst = ConfigYesNo(default=False) config.autobouquets.schedule = ConfigYesNo(default=False) config.autobouquets.scheduletime = ConfigClock(default=0) # 1:00 config.autobouquets.repeattype = ConfigSelection(default="daily", choices=[ ("daily", _("Daily")), ("weekly", _("Weekly")), ("monthly", _("30 Days")) ]) config.autobouquets.retry = ConfigNumber(default=30) config.autobouquets.retrycount = NoSave(ConfigNumber(default=0)) config.autobouquets.nextscheduletime = NoSave(ConfigNumber(default=0)) config.autobouquets.lastlog = ConfigText(default=' ', fixed_size=False) autoAutoBouquetsTimer = None def AutoBouquetsautostart(reason, session=None, **kwargs):
class TimerEntry(Screen, ConfigListScreen): def __init__(self, session, timer): Screen.__init__(self, session) self.setup_title = _("Timer entry") self.timer = timer self.entryDate = None self.entryService = None self["HelpWindow"] = Pixmap() self["HelpWindow"].hide() self["VKeyIcon"] = Boolean(False) self["locationdescription"] = Label("") self["locationfreespace"] = Label("") self["description"] = Label("") self["oktext"] = Label(_("OK")) self["canceltext"] = Label(_("Cancel")) self["ok"] = Pixmap() self["cancel"] = Pixmap() self["summary_description"] = StaticText("") self["description"] = Label("") self.createConfig() self["actions"] = NumberActionMap( ["SetupActions", "GlobalActions", "PiPSetupActions"], { "ok": self.keySelect, "save": self.keyGo, "cancel": self.keyCancel, "volumeUp": self.incrementStart, "volumeDown": self.decrementStart, "size+": self.incrementEnd, "size-": self.decrementEnd, "up": self.keyUp, "down": self.keyDown }, -2) self.list = [] ConfigListScreen.__init__(self, self.list, session=session) self.setTitle(_("PowerManager entry")) self.createSetup("config") def createConfig(self): afterevent = { AFTEREVENT.NONE: "nothing", AFTEREVENT.WAKEUP: "wakeup", AFTEREVENT.WAKEUPTOSTANDBY: "wakeuptostandby", AFTEREVENT.STANDBY: "standby", AFTEREVENT.DEEPSTANDBY: "deepstandby" }[self.timer.afterEvent] 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.timer.timerType] weekday_table = ("mon", "tue", "wed", "thu", "fri", "sat", "sun") time_table = [(1, "1"), (3, "3"), (5, "5"), (10, "10"), (15, "15"), (30, "30"), (45, "45"), (60, "60"), (75, "75"), (90, "90"), (105, "105"), (120, "120"), (135, "135"), (150, "150"), (165, "165"), (180, "180"), (195, "195"), (210, "210"), (225, "225"), (240, "240"), (255, "255"), (270, "270"), (285, "285"), (300, "300")] traffic_table = [(10, "10"), (50, "50"), (100, "100"), (500, "500"), (1000, "1000")] # calculate default values day = [] weekday = 0 for x in (0, 1, 2, 3, 4, 5, 6): day.append(0) if self.timer.repeated: # repeated type = "repeated" if self.timer.repeated == 31: # Mon-Fri repeated = "weekdays" elif self.timer.repeated == 127: # daily repeated = "daily" else: flags = self.timer.repeated repeated = "user" count = 0 for x in (0, 1, 2, 3, 4, 5, 6): if flags == 1: # weekly print "Set to weekday " + str(x) weekday = x if flags & 1 == 1: # set user defined flags day[x] = 1 count += 1 else: day[x] = 0 flags >>= 1 if count == 1: repeated = "weekly" else: # once type = "once" repeated = None weekday = int(strftime("%u", localtime(self.timer.begin))) - 1 day[weekday] = 1 if SystemInfo["DeepstandbySupport"]: shutdownString = _("go to deep standby") else: shutdownString = _("shut down") self.timerentry_timertype = ConfigSelection(choices=[ ("nothing", _("do nothing")), ("wakeup", _("wakeup")), ("wakeuptostandby", _("wakeup to standby")), ("autostandby", _("auto standby")), ("autodeepstandby", _("auto deepstandby")), ("standby", _("go to standby")), ("deepstandby", shutdownString), ("reboot", _("reboot system")), ("restart", _("restart GUI")) ], default=timertype) self.timerentry_afterevent = ConfigSelection(choices=[ ("nothing", _("do nothing")), ("wakeup", _("wakeup")), ("wakeuptostandby", _("wakeup to standby")), ("standby", _("go to standby")), ("deepstandby", shutdownString), ("nothing", _("do nothing")) ], default=afterevent) self.timerentry_type = ConfigSelection(choices=[("once", _("once")), ("repeated", _("repeated"))], default=type) self.timerentry_repeated = ConfigSelection( default=repeated, choices=[("daily", _("daily")), ("weekly", _("weekly")), ("weekdays", _("Mon-Fri")), ("user", _("user defined"))]) self.timerrntry_autosleepdelay = ConfigSelection( choices=time_table, default=self.timer.autosleepdelay) self.timerentry_autosleeprepeat = ConfigSelection( choices=[("once", _("once")), ("repeated", _("repeated"))], default=self.timer.autosleeprepeat) self.timerrntry_autosleepinstandbyonly = ConfigSelection( choices=[("yes", _("only in Standby")), ("no", _("Standard (always)")), ("noquery", _("without Query"))], default=self.timer.autosleepinstandbyonly) self.timerrntry_autosleepwindow = ConfigSelection( choices=[("yes", _("Yes")), ("no", _("No"))], default=self.timer.autosleepwindow) self.timerrntry_autosleepbegin = ConfigClock( default=self.timer.autosleepbegin) self.timerrntry_autosleepend = ConfigClock( default=self.timer.autosleepend) self.timerentry_date = ConfigDateTime(default=self.timer.begin, formatstring=_("%d.%B %Y"), increment=86400) self.timerentry_starttime = ConfigClock(default=self.timer.begin) self.timerentry_endtime = ConfigClock(default=self.timer.end) self.timerentry_showendtime = ConfigSelection( default=(((self.timer.end - self.timer.begin) / 60) > 4), choices=[(True, _("yes")), (False, _("no"))]) self.timerentry_repeatedbegindate = ConfigDateTime( default=self.timer.repeatedbegindate, formatstring=_("%d.%B %Y"), increment=86400) self.timerentry_weekday = ConfigSelection( default=weekday_table[weekday], choices=[("mon", _("Monday")), ("tue", _("Tuesday")), ("wed", _("Wednesday")), ("thu", _("Thursday")), ("fri", _("Friday")), ("sat", _("Saturday")), ("sun", _("Sunday"))]) self.timerentry_day = ConfigSubList() for x in (0, 1, 2, 3, 4, 5, 6): self.timerentry_day.append(ConfigYesNo(default=day[x])) self.timerrntry_showExtended = ConfigSelection( default=(self.timer.nettraffic == "yes" or self.timer.netip == "yes"), choices=[(True, _("yes")), (False, _("no"))]) self.timerrntry_nettraffic = ConfigSelection( choices=[("yes", _("Yes")), ("no", _("No"))], default=self.timer.nettraffic) self.timerrntry_trafficlimit = ConfigSelection( choices=traffic_table, default=self.timer.trafficlimit) self.timerrntry_netip = ConfigSelection(choices=[("yes", _("Yes")), ("no", _("No"))], default=self.timer.netip) self.timerrntry_ipadress = self.timer.ipadress.split(',') self.ipcount = ConfigSelectionNumber(default=len( self.timerrntry_ipadress), stepwidth=1, min=1, max=5) self.ipadressEntry = ConfigSubList() for x in (0, 1, 2, 3, 4, 5): try: self.ipadressEntry.append( ConfigIP(default=[ int(n) for n in self.timerrntry_ipadress[x].split('.') ] or [0, 0, 0, 0])) except: self.ipadressEntry.append(ConfigIP(default=[0, 0, 0, 0])) def createSetup(self, widget): self.list = [] self.timerType = getConfigListEntry(_("Timer type"), self.timerentry_timertype) self.list.append(self.timerType) self.timerTypeEntry = getConfigListEntry(_("Repeat type"), self.timerentry_type) self.entryStartTime = getConfigListEntry(_("Start time"), self.timerentry_starttime) self.entryShowEndTime = getConfigListEntry(_("Set end time"), self.timerentry_showendtime) self.entryEndTime = getConfigListEntry(_("End time"), self.timerentry_endtime) self.frequencyEntry = getConfigListEntry(_("Repeats"), self.timerentry_repeated) self.entryDate = getConfigListEntry(_("Date"), self.timerentry_date) self.repeatedbegindateEntry = getConfigListEntry( _("Starting on"), self.timerentry_repeatedbegindate) self.autosleepwindowEntry = getConfigListEntry( _("Restrict the active time range"), self.timerrntry_autosleepwindow) self.netExtendedEntry = getConfigListEntry( _("Show advanced settings"), self.timerrntry_showExtended) self.nettrafficEntry = getConfigListEntry( _("Enable Network Traffic check"), self.timerrntry_nettraffic) self.netipEntry = getConfigListEntry( _("Enable Network IP address check"), self.timerrntry_netip) self.ipcountEntry = getConfigListEntry(_("Select of the number"), self.ipcount) if self.timerentry_timertype.value == "autostandby" or self.timerentry_timertype.value == "autodeepstandby": if self.timerentry_timertype.value == "autodeepstandby": self.list.append( getConfigListEntry( _("Execution condition"), self.timerrntry_autosleepinstandbyonly, _("The setting 'without query' is the same as 'standard' without additional confirmation query. All other dependencies (e.g. recordings, time range) stay persist." ))) self.list.append( getConfigListEntry(_("Sleep delay"), self.timerrntry_autosleepdelay)) self.list.append( getConfigListEntry(_("Repeat type"), self.timerentry_autosleeprepeat)) self.list.append(self.autosleepwindowEntry) if self.timerrntry_autosleepwindow.value == "yes": self.list.append( getConfigListEntry(_("Start time"), self.timerrntry_autosleepbegin)) self.list.append( getConfigListEntry(_("End time"), self.timerrntry_autosleepend)) if self.timerentry_timertype.value == "autodeepstandby": self.list.append(self.netExtendedEntry) if self.timerrntry_showExtended.value: self.list.append(self.nettrafficEntry) if self.timerrntry_nettraffic.value == "yes": self.list.append( getConfigListEntry( _("Lower limit in kilobits per seconds [kbit/s]" ), self.timerrntry_trafficlimit)) self.list.append(self.netipEntry) if self.timerrntry_netip.value == "yes": self.list.append(self.ipcountEntry) for x in range(0, self.ipcount.value): self.list.append( getConfigListEntry( ("%d. " + _("IP address")) % (x + 1), self.ipadressEntry[x])) else: self.list.append(self.timerTypeEntry) if self.timerentry_type.value == "once": self.frequencyEntry = None else: # repeated self.list.append(self.frequencyEntry) self.list.append(self.repeatedbegindateEntry) if self.timerentry_repeated.value == "daily": pass if self.timerentry_repeated.value == "weekdays": pass if self.timerentry_repeated.value == "weekly": self.list.append( getConfigListEntry(_("Weekday"), self.timerentry_weekday)) if self.timerentry_repeated.value == "user": self.list.append( getConfigListEntry(_("Monday"), self.timerentry_day[0])) self.list.append( getConfigListEntry(_("Tuesday"), self.timerentry_day[1])) self.list.append( getConfigListEntry(_("Wednesday"), self.timerentry_day[2])) self.list.append( getConfigListEntry(_("Thursday"), self.timerentry_day[3])) self.list.append( getConfigListEntry(_("Friday"), self.timerentry_day[4])) self.list.append( getConfigListEntry(_("Saturday"), self.timerentry_day[5])) self.list.append( getConfigListEntry(_("Sunday"), self.timerentry_day[6])) if self.timerentry_type.value == "once": self.list.append(self.entryDate) self.list.append(self.entryStartTime) self.list.append(self.entryShowEndTime) if self.timerentry_showendtime.value: self.list.append(self.entryEndTime) self.list.append( getConfigListEntry(_("After event"), self.timerentry_afterevent)) self[widget].list = self.list self[widget].l.setList(self.list) def layoutFinished(self): self.setTitle(_(self.setup_title)) def createSummary(self): return SetupSummary # for summary: def changedEntry(self): for x in self.onChangedEntry: x() def getCurrentEntry(self): return self["config"].getCurrent() and self["config"].getCurrent( )[0] or "" def getCurrentValue(self): return self["config"].getCurrent() and str( self["config"].getCurrent()[1].getText()) or "" def newConfig(self): if self["config"].getCurrent() in (self.timerType, self.timerTypeEntry, self.frequencyEntry, self.entryShowEndTime, self.autosleepwindowEntry, self.netExtendedEntry, self.nettrafficEntry, self.netipEntry, self.ipcountEntry): self.createSetup("config") def keyLeft(self): ConfigListScreen.keyLeft(self) self.newConfig() def keyRight(self): ConfigListScreen.keyRight(self) self.newConfig() def keySelect(self): cur = self["config"].getCurrent() self.keyGo() def keyUp(self): self["config"].moveUp() def keyDown(self): self["config"].moveDown() def getTimestamp(self, date, mytime): d = localtime(date) dt = datetime(d.tm_year, d.tm_mon, d.tm_mday, mytime[0], mytime[1]) return int(mktime(dt.timetuple())) def getBeginEnd(self): date = self.timerentry_date.value endtime = self.timerentry_endtime.value starttime = self.timerentry_starttime.value begin = self.getTimestamp(date, starttime) end = self.getTimestamp(date, endtime) # if the endtime is less than the starttime, add 1 day. if end < begin: end += 86400 return begin, end def keyGo(self, result=None): if not self.timerentry_showendtime.value: self.timerentry_endtime.value = self.timerentry_starttime.value self.timer.resetRepeated() if self.timerentry_type.value == "once": self.timer.begin, self.timer.end = self.getBeginEnd() if self.timerentry_timertype.value == "autostandby" or self.timerentry_timertype.value == "autodeepstandby": self.timer.begin = int(time()) + 10 self.timer.end = self.timer.begin self.timer.autosleepinstandbyonly = self.timerrntry_autosleepinstandbyonly.value self.timer.autosleepdelay = self.timerrntry_autosleepdelay.value self.timer.autosleeprepeat = self.timerentry_autosleeprepeat.value self.timerentry_showendtime.value = False if self.timerentry_type.value == "repeated": if self.timerentry_repeated.value == "daily": for x in (0, 1, 2, 3, 4, 5, 6): self.timer.setRepeated(x) if self.timerentry_repeated.value == "weekly": self.timer.setRepeated(self.timerentry_weekday.index) if self.timerentry_repeated.value == "weekdays": for x in (0, 1, 2, 3, 4): self.timer.setRepeated(x) if self.timerentry_repeated.value == "user": for x in (0, 1, 2, 3, 4, 5, 6): if self.timerentry_day[x].value: self.timer.setRepeated(x) self.timer.repeatedbegindate = self.getTimestamp( self.timerentry_repeatedbegindate.value, self.timerentry_starttime.value) if self.timer.repeated: self.timer.begin = self.getTimestamp( self.timerentry_repeatedbegindate.value, self.timerentry_starttime.value) self.timer.end = self.getTimestamp( self.timerentry_repeatedbegindate.value, self.timerentry_endtime.value) else: self.timer.begin = self.getTimestamp( time(), self.timerentry_starttime.value) self.timer.end = self.getTimestamp( time(), self.timerentry_endtime.value) # when a timer end is set before the start, add 1 day if self.timer.end < self.timer.begin: self.timer.end += 86400 endaction = self.timerentry_showendtime.value if (self.timer.end - self.timer.begin ) / 60 < 5 or self.timerentry_showendtime.value is False: self.timerentry_afterevent.value = "nothing" self.timer.end = self.timer.begin if endaction: self.session.open( MessageBox, _("Difference between timer begin and end must be equal or greater than %d minutes.\nEnd Action was disabled !" ) % 5, MessageBox.TYPE_INFO, timeout=30) self.timer.timerType = { "nothing": TIMERTYPE.NONE, "wakeup": TIMERTYPE.WAKEUP, "wakeuptostandby": TIMERTYPE.WAKEUPTOSTANDBY, "autostandby": TIMERTYPE.AUTOSTANDBY, "autodeepstandby": TIMERTYPE.AUTODEEPSTANDBY, "standby": TIMERTYPE.STANDBY, "deepstandby": TIMERTYPE.DEEPSTANDBY, "reboot": TIMERTYPE.REBOOT, "restart": TIMERTYPE.RESTART }[self.timerentry_timertype.value] self.timer.afterEvent = { "nothing": AFTEREVENT.NONE, "wakeup": AFTEREVENT.WAKEUP, "wakeuptostandby": AFTEREVENT.WAKEUPTOSTANDBY, "standby": AFTEREVENT.STANDBY, "deepstandby": AFTEREVENT.DEEPSTANDBY }[self.timerentry_afterevent.value] self.timer.autosleepwindow = self.timerrntry_autosleepwindow.value self.timer.autosleepbegin = self.getTimestamp( time(), self.timerrntry_autosleepbegin.value) self.timer.autosleepend = self.getTimestamp( time(), self.timerrntry_autosleepend.value) self.timer.nettraffic = self.timerrntry_nettraffic.value self.timer.trafficlimit = self.timerrntry_trafficlimit.value self.timer.netip = self.timerrntry_netip.value self.timer.ipadress = "%d.%d.%d.%d" % ( self.ipadressEntry[0].value[0], self.ipadressEntry[0].value[1], self.ipadressEntry[0].value[2], self.ipadressEntry[0].value[3]) for x in range(1, self.ipcount.value): self.timer.ipadress += ",%d.%d.%d.%d" % ( self.ipadressEntry[x].value[0], self.ipadressEntry[x].value[1], self.ipadressEntry[x].value[2], self.ipadressEntry[x].value[3]) self.saveTimer() self.close((True, self.timer)) def incrementStart(self): self.timerentry_starttime.increment() self["config"].invalidate(self.entryStartTime) if self.timerentry_type.value == "once" and self.timerentry_starttime.value == [ 0, 0 ]: self.timerentry_date.value += 86400 self["config"].invalidate(self.entryDate) def decrementStart(self): self.timerentry_starttime.decrement() self["config"].invalidate(self.entryStartTime) if self.timerentry_type.value == "once" and self.timerentry_starttime.value == [ 23, 59 ]: self.timerentry_date.value -= 86400 self["config"].invalidate(self.entryDate) def incrementEnd(self): if self.entryEndTime is not None: self.timerentry_endtime.increment() self["config"].invalidate(self.entryEndTime) def decrementEnd(self): if self.entryEndTime is not None: self.timerentry_endtime.decrement() self["config"].invalidate(self.entryEndTime) def saveTimer(self): self.session.nav.PowerTimer.saveTimer() def keyCancel(self): self.close((False, ))
def makeList(self): self.list = [] if getDistro() != "ViX" or getDistro() != "AAF" or getDistro( ) != "openMips": device_default = None i = 0 for mountpoint in self.mountpoint: if mountpoint == self.config.db_root: device_default = self.mountdescription[i] i += 1 ## default device is really important... if miss a default we force it on first entry and update now the main config if device_default == None: self.config.db_root = self.mountpoint[0] device_default = self.mountdescription[0] lamedb_default = _("main lamedb") if self.config.lamedb != "lamedb": lamedb_default = self.config.lamedb.replace("lamedb.", "").replace(".", " ") scheduled_default = None if self.config.download_standby_enabled: scheduled_default = _("every hour (only in standby)") elif self.config.download_daily_enabled: scheduled_default = _("once a day") else: scheduled_default = _("disabled") if getDistro() != "ViX" or getDistro() != "AAF" or getDistro( ) != "openMips": self.list.append((_("Storage device"), ConfigSelection(self.mountdescription, device_default))) if len(self.lamedbs_desc) > 1: self.list.append((_("Preferred lamedb"), ConfigSelection(self.lamedbs_desc, lamedb_default))) self.list.append((_("Enable csv import"), ConfigYesNo(self.config.csv_import_enabled > 0))) self.list.append((_("Force epg reload on boot"), ConfigYesNo(self.config.force_load_on_boot > 0))) self.list.append((_("Download on tune"), ConfigYesNo(self.config.download_tune_enabled > 0))) self.list.append((_("Scheduled download"), ConfigSelection(self.automatictype, scheduled_default))) if self.config.download_daily_enabled: ttime = localtime() ltime = (ttime[0], ttime[1], ttime[2], self.config.download_daily_hours, self.config.download_daily_minutes, ttime[5], ttime[6], ttime[7], ttime[8]) self.list.append( (_("Scheduled download at"), ConfigClock(mktime(ltime)))) if not self.fastpatch: self.list.append( (_("Reboot after a scheduled download"), ConfigYesNo(self.config.download_daily_reboot > 0))) self.list.append( (_("Reboot after a manual download"), ConfigYesNo(self.config.download_manual_reboot > 0))) self.list.append( (_("Show as plugin"), ConfigYesNo(self.config.show_plugin > 0))) self.list.append((_("Show as extension"), ConfigYesNo(self.config.show_extension > 0))) self.list.append( (_("Show 'Force reload' as plugin"), ConfigYesNo(self.config.show_force_reload_as_plugin > 0))) self["config"].setList(self.list) self.setInfo()
def info(self): mysel = self['list'].getCurrent() if mysel: myline = mysel[1] self.session.open(MessageBox, _(myline), MessageBox.TYPE_INFO) def closeRecursive(self): self.close(True) config.crontimers = ConfigSubsection() config.crontimers.commandtype = NoSave( ConfigSelection(choices=[('custom', _("Custom")), ('predefined', _("Predefined"))])) config.crontimers.cmdtime = NoSave(ConfigClock(default=0)) config.crontimers.cmdtime.value, mytmpt = ([0, 0], [0, 0]) config.crontimers.user_command = NoSave(ConfigText(fixed_size=False)) config.crontimers.runwhen = NoSave( ConfigSelection(default='Daily', choices=[('Hourly', _("Hourly")), ('Daily', _("Daily")), ('Weekly', _("Weekly")), ('Monthly', _("Monthly"))])) config.crontimers.dayofweek = NoSave( ConfigSelection(default='Monday', choices=[('Monday', _("Monday")), ('Tuesday', _("Tuesday")), ('Wednesday', _("Wednesday")), ('Thursday', _("Thursday")), ('Friday', _("Friday")), ('Saturday', _("Saturday")),
from time import gmtime, strftime, localtime, sleep from datetime import date, datetime from boxbranding import getBoxType, getMachineBrand, getMachineName, getImageDistro import shutil boxtype = getBoxType() distro = getImageDistro() START = time() dt1 = strftime("%Y%m%d_%H%M", localtime(START)) config.plugins.configurationbackup = ConfigSubsection() config.plugins.configurationbackup.enabled = ConfigEnableDisable(default=False) config.plugins.configurationbackup.maxbackup = ConfigInteger(default=99, limits=(0, 99)) config.plugins.configurationbackup.backuplocation = ConfigText( default='/media/hdd/', visible_width=50, fixed_size=False) config.plugins.configurationbackup.wakeup = ConfigClock( default=((3 * 60) + 0) * 60) # 3:00 config.plugins.configurationbackup.backupdirs = ConfigLocations(default=[ eEnv.resolve('${sysconfdir}/enigma2/'), '/etc/network/interfaces', '/etc/wpa_supplicant.conf', '/etc/wpa_supplicant.ath0.conf', '/etc/wpa_supplicant.wlan0.conf', '/etc/resolv.conf', '/etc/default_gw', '/etc/hostname' ]) dirsbackup = config.plugins.configurationbackup.backuplocation.value + 'channellist_' + dt1 def getBackupPathChannel(): backuppath = config.plugins.configurationbackup.backuplocation.value if backuppath.endswith('/'): return backuppath + 'backup_channellist' else: return backuppath + '/backup_channellist'
def createConfig(self): afterevent = {AFTEREVENT.NONE: 'nothing', AFTEREVENT.WAKEUP: 'wakeup', AFTEREVENT.WAKEUPTOSTANDBY: 'wakeuptostandby', AFTEREVENT.STANDBY: 'standby', AFTEREVENT.DEEPSTANDBY: 'deepstandby'}[self.timer.afterEvent] 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.timer.timerType] weekday_table = ('mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun') time_table = [(1, '1'), (3, '3'), (5, '5'), (10, '10'), (15, '15'), (30, '30'), (45, '45'), (60, '60'), (75, '75'), (90, '90'), (105, '105'), (120, '120'), (135, '135'), (150, '150'), (165, '165'), (180, '180'), (195, '195'), (210, '210'), (225, '225'), (240, '240'), (255, '255'), (270, '270'), (285, '285'), (300, '300')] traffic_table = [(10, '10'), (50, '50'), (100, '100'), (500, '500'), (1000, '1000')] day = [] weekday = 0 for x in (0, 1, 2, 3, 4, 5, 6): day.append(0) if self.timer.repeated: type = 'repeated' if self.timer.repeated == 31: repeated = 'weekdays' elif self.timer.repeated == 127: repeated = 'daily' else: flags = self.timer.repeated repeated = 'user' count = 0 for x in (0, 1, 2, 3, 4, 5, 6): if flags == 1: print 'Set to weekday ' + str(x) weekday = x if flags & 1 == 1: day[x] = 1 count += 1 else: day[x] = 0 flags >>= 1 if count == 1: repeated = 'weekly' else: type = 'once' repeated = None weekday = int(strftime('%u', localtime(self.timer.begin))) - 1 day[weekday] = 1 if SystemInfo['DeepstandbySupport']: shutdownString = _('go to deep standby') else: shutdownString = _('shut down') self.timerentry_timertype = ConfigSelection(choices=[('nothing', _('do nothing')), ('wakeup', _('wakeup')), ('wakeuptostandby', _('wakeup to standby')), ('autostandby', _('auto standby')), ('autodeepstandby', _('auto deepstandby')), ('standby', _('go to standby')), ('deepstandby', shutdownString), ('reboot', _('reboot system')), ('restart', _('restart GUI'))], default=timertype) self.timerentry_afterevent = ConfigSelection(choices=[('nothing', _('do nothing')), ('wakeup', _('wakeup')), ('wakeuptostandby', _('wakeup to standby')), ('standby', _('go to standby')), ('deepstandby', shutdownString), ('nothing', _('do nothing'))], default=afterevent) self.timerentry_type = ConfigSelection(choices=[('once', _('once')), ('repeated', _('repeated'))], default=type) self.timerentry_repeated = ConfigSelection(default=repeated, choices=[('daily', _('daily')), ('weekly', _('weekly')), ('weekdays', _('Mon-Fri')), ('user', _('user defined'))]) self.timerrntry_autosleepdelay = ConfigSelection(choices=time_table, default=self.timer.autosleepdelay) self.timerentry_autosleeprepeat = ConfigSelection(choices=[('once', _('once')), ('repeated', _('repeated'))], default=self.timer.autosleeprepeat) self.timerrntry_autosleepinstandbyonly = ConfigSelection(choices=[('yes', _('Yes')), ('no', _('No'))], default=self.timer.autosleepinstandbyonly) self.timerrntry_autosleepwindow = ConfigSelection(choices=[('yes', _('Yes')), ('no', _('No'))], default=self.timer.autosleepwindow) self.timerrntry_autosleepbegin = ConfigClock(default=self.timer.autosleepbegin) self.timerrntry_autosleepend = ConfigClock(default=self.timer.autosleepend) self.timerentry_date = ConfigDateTime(default=self.timer.begin, formatstring=_('%d.%B %Y'), increment=86400) self.timerentry_starttime = ConfigClock(default=self.timer.begin) self.timerentry_endtime = ConfigClock(default=self.timer.end) self.timerentry_showendtime = ConfigSelection(default=(self.timer.end - self.timer.begin) / 60 > 4, choices=[(True, _('yes')), (False, _('no'))]) self.timerentry_repeatedbegindate = ConfigDateTime(default=self.timer.repeatedbegindate, formatstring=_('%d.%B %Y'), increment=86400) self.timerentry_weekday = ConfigSelection(default=weekday_table[weekday], choices=[('mon', _('Monday')), ('tue', _('Tuesday')), ('wed', _('Wednesday')), ('thu', _('Thursday')), ('fri', _('Friday')), ('sat', _('Saturday')), ('sun', _('Sunday'))]) self.timerentry_day = ConfigSubList() for x in (0, 1, 2, 3, 4, 5, 6): self.timerentry_day.append(ConfigYesNo(default=day[x])) self.timerrntry_showExtended = ConfigSelection(default=self.timer.nettraffic == 'yes' or self.timer.netip == 'yes', choices=[(True, _('yes')), (False, _('no'))]) self.timerrntry_nettraffic = ConfigSelection(choices=[('yes', _('Yes')), ('no', _('No'))], default=self.timer.nettraffic) self.timerrntry_trafficlimit = ConfigSelection(choices=traffic_table, default=self.timer.trafficlimit) self.timerrntry_netip = ConfigSelection(choices=[('yes', _('Yes')), ('no', _('No'))], default=self.timer.netip) self.timerrntry_ipadress = self.timer.ipadress.split(',') self.ipcount = ConfigSelectionNumber(default=len(self.timerrntry_ipadress), stepwidth=1, min=1, max=5) self.ipadressEntry = ConfigSubList() for x in (0, 1, 2, 3, 4, 5): try: self.ipadressEntry.append(ConfigIP(default=[ int(n) for n in self.timerrntry_ipadress[x].split('.') ] or [0, 0, 0, 0])) except: self.ipadressEntry.append(ConfigIP(default=[0, 0, 0, 0])) return
class TimerEntry(Screen, ConfigListScreen): def __init__(self, session, timer): Screen.__init__(self, session) Screen.setTitle(self, _("PowerManager entry")) self.skinName = "PowerTimerEntry" self.timer = timer self.entryDate = None self.entryService = None self["key_green"] = self["oktext"] = Label(_("OK")) self["key_red"] = self["canceltext"] = Label(_("Cancel")) self["ok"] = Pixmap() self["cancel"] = Pixmap() self.createConfig() self["actions"] = NumberActionMap( ["SetupActions", "GlobalActions", "PiPSetupActions"], { "ok": self.keySelect, "save": self.keyGo, "cancel": self.keyCancel, "volumeUp": self.incrementStart, "volumeDown": self.decrementStart, "size+": self.incrementEnd, "size-": self.decrementEnd }, -2) self.list = [] ConfigListScreen.__init__(self, self.list, session=session) self.createSetup("config") def createConfig(self): afterevent = { AFTEREVENT.NONE: "nothing", AFTEREVENT.WAKEUPTOSTANDBY: "wakeuptostandby", AFTEREVENT.STANDBY: "standby", AFTEREVENT.DEEPSTANDBY: "deepstandby" }[self.timer.afterEvent] 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.timer.timerType] weekday_table = ("mon", "tue", "wed", "thu", "fri", "sat", "sun") day = [] weekday = 0 for x in (0, 1, 2, 3, 4, 5, 6): day.append(0) if self.timer.repeated: type = "repeated" if self.timer.repeated == 31: repeated = "weekdays" elif self.timer.repeated == 127: repeated = "daily" else: flags = self.timer.repeated repeated = "user" count = 0 for x in (0, 1, 2, 3, 4, 5, 6): if flags == 1: print("[PowerTimerEntry] Set to weekday " + str(x)) weekday = x if flags & 1 == 1: day[x] = 1 count += 1 else: day[x] = 0 flags >>= 1 if count == 1: repeated = "weekly" else: type = "once" repeated = None weekday = int(strftime("%u", localtime(self.timer.begin))) - 1 day[weekday] = 1 autosleepinstandbyonly = self.timer.autosleepinstandbyonly autosleepdelay = self.timer.autosleepdelay autosleeprepeat = self.timer.autosleeprepeat if SystemInfo["DeepstandbySupport"]: shutdownString = _("go to deep standby") else: shutdownString = _("shut down") self.timerentry_timertype = ConfigSelection(choices=[ ("wakeup", _("wakeup")), ("wakeuptostandby", _("wakeup to standby")), ("autostandby", _("auto standby")), ("autodeepstandby", _("auto deepstandby")), ("standby", _("go to standby")), ("deepstandby", shutdownString), ("reboot", _("reboot system")), ("restart", _("restart GUI")) ], default=timertype) self.timerentry_afterevent = ConfigSelection(choices=[ ("nothing", _("do nothing")), ("wakeuptostandby", _("wakeup to standby")), ("standby", _("go to standby")), ("deepstandby", shutdownString), ("nothing", _("do nothing")) ], default=afterevent) self.timerentry_type = ConfigSelection(choices=[("once", _("once")), ("repeated", _("repeated"))], default=type) self.timerentry_repeated = ConfigSelection( default=repeated, choices=[("daily", _("daily")), ("weekly", _("weekly")), ("weekdays", _("Mon-Fri")), ("user", _("user defined"))]) self.timerentry_autosleepdelay = ConfigInteger(default=autosleepdelay, limits=(10, 300)) self.timerentry_autosleeprepeat = ConfigSelection( choices=[("once", _("once")), ("repeated", _("repeated"))], default=autosleeprepeat) self.timerentry_autosleepinstandbyonly = ConfigSelection( choices=[("yes", _("Yes")), ("no", _("No"))], default=autosleepinstandbyonly) self.timerentry_date = ConfigDateTime( default=self.timer.begin, formatstring=config.usage.date.full.value, increment=86400) self.timerentry_starttime = ConfigClock(default=self.timer.begin) self.timerentry_endtime = ConfigClock(default=self.timer.end) self.timerentry_showendtime = ConfigSelection( default=(((self.timer.end - self.timer.begin) / 60) > 1), choices=[(True, _("yes")), (False, _("no"))]) self.timerentry_repeatedbegindate = ConfigDateTime( default=self.timer.repeatedbegindate, formatstring=config.usage.date.full.value, increment=86400) self.timerentry_weekday = ConfigSelection( default=weekday_table[weekday], choices=[("mon", _("Monday")), ("tue", _("Tuesday")), ("wed", _("Wednesday")), ("thu", _("Thursday")), ("fri", _("Friday")), ("sat", _("Saturday")), ("sun", _("Sunday"))]) self.timerentry_day = ConfigSubList() for x in (0, 1, 2, 3, 4, 5, 6): self.timerentry_day.append(ConfigYesNo(default=day[x])) def createSetup(self, widget): self.list = [] self.timerType = getConfigListEntry(_("Timer type"), self.timerentry_timertype) self.list.append(self.timerType) if self.timerentry_timertype.value == "autostandby" or self.timerentry_timertype.value == "autodeepstandby": if self.timerentry_timertype.value == "autodeepstandby": self.list.append( getConfigListEntry(_("Only active when in standby"), self.timerentry_autosleepinstandbyonly)) self.list.append( getConfigListEntry(_("Sleep delay"), self.timerentry_autosleepdelay)) self.list.append( getConfigListEntry(_("Repeat type"), self.timerentry_autosleeprepeat)) self.timerTypeEntry = getConfigListEntry(_("Repeat type"), self.timerentry_type) self.entryShowEndTime = getConfigListEntry( _("Set end time"), self.timerentry_showendtime) self.frequencyEntry = getConfigListEntry(_("Repeats"), self.timerentry_repeated) else: self.timerTypeEntry = getConfigListEntry(_("Repeat type"), self.timerentry_type) self.list.append(self.timerTypeEntry) if self.timerentry_type.value == "once": self.frequencyEntry = None else: self.frequencyEntry = getConfigListEntry( _("Repeats"), self.timerentry_repeated) self.list.append(self.frequencyEntry) self.repeatedbegindateEntry = getConfigListEntry( _("Starting on"), self.timerentry_repeatedbegindate) self.list.append(self.repeatedbegindateEntry) if self.timerentry_repeated.value == "daily": pass if self.timerentry_repeated.value == "weekdays": pass if self.timerentry_repeated.value == "weekly": self.list.append( getConfigListEntry(_("Weekday"), self.timerentry_weekday)) if self.timerentry_repeated.value == "user": self.list.append( getConfigListEntry(_("Monday"), self.timerentry_day[0])) self.list.append( getConfigListEntry(_("Tuesday"), self.timerentry_day[1])) self.list.append( getConfigListEntry(_("Wednesday"), self.timerentry_day[2])) self.list.append( getConfigListEntry(_("Thursday"), self.timerentry_day[3])) self.list.append( getConfigListEntry(_("Friday"), self.timerentry_day[4])) self.list.append( getConfigListEntry(_("Saturday"), self.timerentry_day[5])) self.list.append( getConfigListEntry(_("Sunday"), self.timerentry_day[6])) self.entryDate = getConfigListEntry(_("Date"), self.timerentry_date) if self.timerentry_type.value == "once": self.list.append(self.entryDate) self.entryStartTime = getConfigListEntry(_("Start time"), self.timerentry_starttime) self.list.append(self.entryStartTime) self.entryShowEndTime = getConfigListEntry( _("Set end time"), self.timerentry_showendtime) self.list.append(self.entryShowEndTime) self.entryEndTime = getConfigListEntry(_("End time"), self.timerentry_endtime) if self.timerentry_showendtime.value: self.list.append(self.entryEndTime) self.list.append( getConfigListEntry(_("After event"), self.timerentry_afterevent)) self[widget].list = self.list self[widget].l.setList(self.list) def newConfig(self): if self["config"].getCurrent() in (self.timerType, self.timerTypeEntry, self.frequencyEntry, self.entryShowEndTime): self.createSetup("config") def keyLeft(self): ConfigListScreen.keyLeft(self) self.newConfig() def keyRight(self): ConfigListScreen.keyRight(self) self.newConfig() def keySelect(self): cur = self["config"].getCurrent() self.keyGo() def getTimestamp(self, date, mytime): d = localtime(date) dt = datetime(d.tm_year, d.tm_mon, d.tm_mday, mytime[0], mytime[1]) return int(mktime(dt.timetuple())) def getBeginEnd(self): date = self.timerentry_date.value endtime = self.timerentry_endtime.value starttime = self.timerentry_starttime.value begin = self.getTimestamp(date, starttime) end = self.getTimestamp(date, endtime) if end < begin: end += 86400 return begin, end def keyGo(self, result=None): if not self.timerentry_showendtime.value: self.timerentry_endtime.value = self.timerentry_starttime.value self.timer.resetRepeated() self.timer.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 }[self.timerentry_timertype.value] self.timer.afterEvent = { "nothing": AFTEREVENT.NONE, "wakeuptostandby": AFTEREVENT.WAKEUPTOSTANDBY, "standby": AFTEREVENT.STANDBY, "deepstandby": AFTEREVENT.DEEPSTANDBY }[self.timerentry_afterevent.value] if self.timerentry_type.value == "once": self.timer.begin, self.timer.end = self.getBeginEnd() if self.timerentry_timertype.value == "autostandby" or self.timerentry_timertype.value == "autodeepstandby": self.timer.begin = int(time()) + 10 self.timer.end = self.timer.begin self.timer.autosleepinstandbyonly = self.timerentry_autosleepinstandbyonly.value self.timer.autosleepdelay = self.timerentry_autosleepdelay.value self.timer.autosleeprepeat = self.timerentry_autosleeprepeat.value if self.timerentry_type.value == "repeated": self.timer.resetRepeated() self.timerentry_type.value = "once" if self.timerentry_type.value == "repeated": if self.timerentry_repeated.value == "daily": for x in (0, 1, 2, 3, 4, 5, 6): self.timer.setRepeated(x) if self.timerentry_repeated.value == "weekly": self.timer.setRepeated(self.timerentry_weekday.index) if self.timerentry_repeated.value == "weekdays": for x in (0, 1, 2, 3, 4): self.timer.setRepeated(x) if self.timerentry_repeated.value == "user": for x in (0, 1, 2, 3, 4, 5, 6): if self.timerentry_day[x].value: self.timer.setRepeated(x) self.timer.repeatedbegindate = self.getTimestamp( self.timerentry_repeatedbegindate.value, self.timerentry_starttime.value) if self.timer.repeated: self.timer.begin = self.getTimestamp( self.timerentry_repeatedbegindate.value, self.timerentry_starttime.value) self.timer.end = self.getTimestamp( self.timerentry_repeatedbegindate.value, self.timerentry_endtime.value) else: self.timer.begin = self.getTimestamp( time.time(), self.timerentry_starttime.value) self.timer.end = self.getTimestamp( time.time(), self.timerentry_endtime.value) if self.timer.end < self.timer.begin: self.timer.end += 86400 self.saveTimer() self.close((True, self.timer)) def incrementStart(self): if not hasattr(self, "entryStartTime"): return self.timerentry_starttime.increment() self["config"].invalidate(self.entryStartTime) if self.timerentry_type.value == "once" and self.timerentry_starttime.value == [ 0, 0 ]: self.timerentry_date.value += 86400 self["config"].invalidate(self.entryDate) def decrementStart(self): if not hasattr(self, "entryStartTime"): return self.timerentry_starttime.decrement() self["config"].invalidate(self.entryStartTime) if self.timerentry_type.value == "once" and self.timerentry_starttime.value == [ 23, 59 ]: self.timerentry_date.value -= 86400 self["config"].invalidate(self.entryDate) def incrementEnd(self): if not hasattr(self, "entryEndTime"): return if self.entryEndTime is not None: self.timerentry_endtime.increment() self["config"].invalidate(self.entryEndTime) def decrementEnd(self): if not hasattr(self, "entryEndTime"): return if self.entryEndTime is not None: self.timerentry_endtime.decrement() self["config"].invalidate(self.entryEndTime) def saveTimer(self): self.session.nav.PowerTimer.saveTimer() def keyCancel(self): self.close((False, ))
def createConfig(self): justplay = self.timer.justplay afterevent = { AFTEREVENT.NONE: "nothing", AFTEREVENT.DEEPSTANDBY: "deepstandby", AFTEREVENT.STANDBY: "standby", AFTEREVENT.AUTO: "auto" }[self.timer.afterEvent] weekday_table = ("mon", "tue", "wed", "thu", "fri", "sat", "sun") # calculate default values day = [] weekday = 0 for x in (0, 1, 2, 3, 4, 5, 6): day.append(0) if self.timer.repeated: # repeated type = "repeated" if (self.timer.repeated == 31): # Mon-Fri repeated = "weekdays" elif (self.timer.repeated == 127): # daily repeated = "daily" else: flags = self.timer.repeated repeated = "user" count = 0 for x in (0, 1, 2, 3, 4, 5, 6): if flags == 1: # weekly print "Set to weekday " + str(x) weekday = x if flags & 1 == 1: # set user defined flags day[x] = 1 count += 1 else: day[x] = 0 flags = flags >> 1 if count == 1: repeated = "weekly" else: # once type = "once" repeated = None weekday = (int(strftime("%w", 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_afterevent = ConfigSelection(choices = [("nothing", _("do nothing")), ("standby", _("go to standby")), ("deepstandby", _("go to deep standby")), ("auto", _("auto"))], default = afterevent) self.timerentry_type = ConfigSelection(choices = [("once",_("once")), ("repeated", _("repeated"))], default = type) self.timerentry_name = ConfigText(default = self.timer.name, visible_width = 50, fixed_size = False) self.timerentry_description = ConfigText(default = self.timer.description, visible_width = 50, fixed_size = False) self.timerentry_tags = self.timer.tags[:] self.timerentry_tagsset = ConfigSelection(choices = [not self.timerentry_tags and "None" or " ".join(self.timerentry_tags)]) self.timerentry_repeated = ConfigSelection(default = repeated, choices = [("daily", _("daily")), ("weekly", _("weekly")), ("weekdays", _("Mon-Fri")), ("user", _("user defined"))]) self.timerentry_date = ConfigDateTime(default = self.timer.begin, formatstring = _("%d.%B %Y"), increment = 86400) self.timerentry_starttime = ConfigClock(default = self.timer.begin) self.timerentry_endtime = ConfigClock(default = self.timer.end) default = self.timer.dirname or resolveFilename(SCOPE_HDD) tmp = config.movielist.videodirs.value if default not in tmp: tmp.append(default) self.timerentry_dirname = ConfigSelection(default = default, choices = tmp) self.timerentry_repeatedbegindate = ConfigDateTime(default = self.timer.repeatedbegindate, formatstring = _("%d.%B %Y"), increment = 86400) self.timerentry_weekday = ConfigSelection(default = weekday_table[weekday], choices = [("mon",_("Monday")), ("tue", _("Tuesday")), ("wed",_("Wednesday")), ("thu", _("Thursday")), ("fri", _("Friday")), ("sat", _("Saturday")), ("sun", _("Sunday"))]) self.timerentry_day = ConfigSubList() for x in (0, 1, 2, 3, 4, 5, 6): self.timerentry_day.append(ConfigYesNo(default = day[x])) # FIXME some service-chooser needed here servicename = "N/A" try: # no current service available? servicename = str(self.timer.service_ref.getServiceName()) except: pass self.timerentry_service_ref = self.timer.service_ref self.timerentry_service = ConfigSelection([servicename])
def createConfig(self): afterevent = { AFTEREVENT.NONE: "nothing", AFTEREVENT.WAKEUPTOSTANDBY: "wakeuptostandby", AFTEREVENT.STANDBY: "standby", AFTEREVENT.DEEPSTANDBY: "deepstandby" }[self.timer.afterEvent] 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.timer.timerType] weekday_table = ("mon", "tue", "wed", "thu", "fri", "sat", "sun") day = [] weekday = 0 for x in (0, 1, 2, 3, 4, 5, 6): day.append(0) if self.timer.repeated: type = "repeated" if self.timer.repeated == 31: repeated = "weekdays" elif self.timer.repeated == 127: repeated = "daily" else: flags = self.timer.repeated repeated = "user" count = 0 for x in (0, 1, 2, 3, 4, 5, 6): if flags == 1: print("[PowerTimerEntry] Set to weekday " + str(x)) weekday = x if flags & 1 == 1: day[x] = 1 count += 1 else: day[x] = 0 flags >>= 1 if count == 1: repeated = "weekly" else: type = "once" repeated = None weekday = int(strftime("%u", localtime(self.timer.begin))) - 1 day[weekday] = 1 autosleepinstandbyonly = self.timer.autosleepinstandbyonly autosleepdelay = self.timer.autosleepdelay autosleeprepeat = self.timer.autosleeprepeat if SystemInfo["DeepstandbySupport"]: shutdownString = _("go to deep standby") else: shutdownString = _("shut down") self.timerentry_timertype = ConfigSelection(choices=[ ("wakeup", _("wakeup")), ("wakeuptostandby", _("wakeup to standby")), ("autostandby", _("auto standby")), ("autodeepstandby", _("auto deepstandby")), ("standby", _("go to standby")), ("deepstandby", shutdownString), ("reboot", _("reboot system")), ("restart", _("restart GUI")) ], default=timertype) self.timerentry_afterevent = ConfigSelection(choices=[ ("nothing", _("do nothing")), ("wakeuptostandby", _("wakeup to standby")), ("standby", _("go to standby")), ("deepstandby", shutdownString), ("nothing", _("do nothing")) ], default=afterevent) self.timerentry_type = ConfigSelection(choices=[("once", _("once")), ("repeated", _("repeated"))], default=type) self.timerentry_repeated = ConfigSelection( default=repeated, choices=[("daily", _("daily")), ("weekly", _("weekly")), ("weekdays", _("Mon-Fri")), ("user", _("user defined"))]) self.timerentry_autosleepdelay = ConfigInteger(default=autosleepdelay, limits=(10, 300)) self.timerentry_autosleeprepeat = ConfigSelection( choices=[("once", _("once")), ("repeated", _("repeated"))], default=autosleeprepeat) self.timerentry_autosleepinstandbyonly = ConfigSelection( choices=[("yes", _("Yes")), ("no", _("No"))], default=autosleepinstandbyonly) self.timerentry_date = ConfigDateTime( default=self.timer.begin, formatstring=config.usage.date.full.value, increment=86400) self.timerentry_starttime = ConfigClock(default=self.timer.begin) self.timerentry_endtime = ConfigClock(default=self.timer.end) self.timerentry_showendtime = ConfigSelection( default=(((self.timer.end - self.timer.begin) / 60) > 1), choices=[(True, _("yes")), (False, _("no"))]) self.timerentry_repeatedbegindate = ConfigDateTime( default=self.timer.repeatedbegindate, formatstring=config.usage.date.full.value, increment=86400) self.timerentry_weekday = ConfigSelection( default=weekday_table[weekday], choices=[("mon", _("Monday")), ("tue", _("Tuesday")), ("wed", _("Wednesday")), ("thu", _("Thursday")), ("fri", _("Friday")), ("sat", _("Saturday")), ("sun", _("Sunday"))]) self.timerentry_day = ConfigSubList() for x in (0, 1, 2, 3, 4, 5, 6): self.timerentry_day.append(ConfigYesNo(default=day[x]))
class TimerEntry(Screen, ConfigListScreen): def __init__(self, session, timer): Screen.__init__(self, session) self.setup_title = _('Timer entry') self.timer = timer self.entryDate = None self.entryService = None self['HelpWindow'] = Pixmap() self['HelpWindow'].hide() self['VKeyIcon'] = Boolean(False) self['description'] = Label('') self['oktext'] = Label(_('OK')) self['canceltext'] = Label(_('Cancel')) self['ok'] = Pixmap() self['cancel'] = Pixmap() self.createConfig() self['actions'] = NumberActionMap(['SetupActions', 'GlobalActions', 'PiPSetupActions', 'ColorActions'], {'ok': self.keySelect, 'save': self.keyGo, 'cancel': self.keyCancel, 'volumeUp': self.incrementStart, 'volumeDown': self.decrementStart, 'size+': self.incrementEnd, 'size-': self.decrementEnd}, -2) self['VirtualKB'] = ActionMap(['VirtualKeyboardActions'], {'showVirtualKeyboard': self.KeyText}, -2) self['VirtualKB'].setEnabled(False) self.onChangedEntry = [] self.list = [] ConfigListScreen.__init__(self, self.list, session=session) self.createSetup('config') self.onLayoutFinish.append(self.layoutFinished) if self.selectionChanged not in self['config'].onSelectionChanged: self['config'].onSelectionChanged.append(self.selectionChanged) self.selectionChanged() return def createConfig(self): justplay = self.timer.justplay always_zap = self.timer.always_zap rename_repeat = self.timer.rename_repeat afterevent = {AFTEREVENT.NONE: 'nothing', AFTEREVENT.DEEPSTANDBY: 'deepstandby', AFTEREVENT.STANDBY: 'standby', AFTEREVENT.AUTO: 'auto'}[self.timer.afterEvent] if self.timer.record_ecm and self.timer.descramble: recordingtype = 'descrambled+ecm' elif self.timer.record_ecm: recordingtype = 'scrambled+ecm' elif self.timer.descramble: recordingtype = 'normal' weekday_table = ('mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun') day = [] weekday = 0 for x in (0, 1, 2, 3, 4, 5, 6): day.append(0) if self.timer.repeated: type = 'repeated' if self.timer.repeated == 31: repeated = 'weekdays' elif self.timer.repeated == 127: repeated = 'daily' else: flags = self.timer.repeated repeated = 'user' count = 0 for x in (0, 1, 2, 3, 4, 5, 6): if flags == 1: weekday = x if flags & 1 == 1: day[x] = 1 count += 1 else: day[x] = 0 flags >>= 1 if count == 1: repeated = 'weekly' else: type = 'once' repeated = None weekday = int(strftime('%u', localtime(self.timer.begin))) - 1 day[weekday] = 1 self.timerentry_justplay = ConfigSelection(choices=[('zap', _('zap')), ('record', _('record')), ('zap+record', _('zap and record'))], default={0: 'record', 1: 'zap', 2: 'zap+record'}[justplay + 2 * always_zap]) if SystemInfo['DeepstandbySupport']: shutdownString = _('go to deep standby') else: shutdownString = _('shut down') self.timerentry_afterevent = ConfigSelection(choices=[('nothing', _('do nothing')), ('standby', _('go to standby')), ('deepstandby', shutdownString), ('auto', _('auto'))], default=afterevent) self.timerentry_recordingtype = ConfigSelection(choices=[('normal', _('normal')), ('descrambled+ecm', _('descramble and record ecm')), ('scrambled+ecm', _("don't descramble, record ecm"))], default=recordingtype) self.timerentry_type = ConfigSelection(choices=[('once', _('once')), ('repeated', _('repeated'))], default=type) self.timerentry_name = ConfigText(default=self.timer.name.replace('\xc2\x86', '').replace('\xc2\x87', '').encode('utf-8'), visible_width=50, fixed_size=False) self.timerentry_description = ConfigText(default=self.timer.description, visible_width=50, fixed_size=False) self.timerentry_tags = self.timer.tags[:] if not self.timerentry_tags: tagname = self.timer.name.strip() if tagname: tagname = tagname[0].upper() + tagname[1:].replace(' ', '_') self.timerentry_tags.append(tagname) self.timerentry_tagsset = ConfigSelection(choices=[not self.timerentry_tags and 'None' or ' '.join(self.timerentry_tags)]) self.timerentry_repeated = ConfigSelection(default=repeated, choices=[('weekly', _('weekly')), ('daily', _('daily')), ('weekdays', _('Mon-Fri')), ('user', _('user defined'))]) self.timerentry_renamerepeat = ConfigYesNo(default=rename_repeat) self.timerentry_date = ConfigDateTime(default=self.timer.begin, formatstring=_('%d %B %Y'), increment=86400) self.timerentry_starttime = ConfigClock(default=self.timer.begin) self.timerentry_endtime = ConfigClock(default=self.timer.end) self.timerentry_showendtime = ConfigSelection(default=self.timer.end > self.timer.begin + 3 and self.timer.justplay, choices=[(True, _('yes')), (False, _('no'))]) default = self.timer.dirname or defaultMoviePath() tmp = config.movielist.videodirs.value if default not in tmp: tmp.append(default) self.timerentry_dirname = ConfigSelection(default=default, choices=tmp) self.timerentry_repeatedbegindate = ConfigDateTime(default=self.timer.repeatedbegindate, formatstring=_('%d.%B %Y'), increment=86400) self.timerentry_weekday = ConfigSelection(default=weekday_table[weekday], choices=[('mon', _('Monday')), ('tue', _('Tuesday')), ('wed', _('Wednesday')), ('thu', _('Thursday')), ('fri', _('Friday')), ('sat', _('Saturday')), ('sun', _('Sunday'))]) self.timerentry_day = ConfigSubList() for x in (0, 1, 2, 3, 4, 5, 6): self.timerentry_day.append(ConfigYesNo(default=day[x])) servicename = 'N/A' try: servicename = str(self.timer.service_ref.getServiceName()) except: pass self.timerentry_service_ref = self.timer.service_ref self.timerentry_service = ConfigSelection([servicename]) return def createSetup(self, widget): self.list = [] self.entryName = getConfigListEntry(_('Name'), self.timerentry_name, _('Set the name the recording will get.')) self.list.append(self.entryName) self.entryDescription = getConfigListEntry(_('Description'), self.timerentry_description, _('Set the description of the recording.')) self.list.append(self.entryDescription) self.timerJustplayEntry = getConfigListEntry(_('Timer type'), self.timerentry_justplay, _('Chose between record and ZAP.')) self.list.append(self.timerJustplayEntry) self.timerTypeEntry = getConfigListEntry(_('Repeat type'), self.timerentry_type, _('A repeating timer or just once?')) self.list.append(self.timerTypeEntry) if self.timerentry_type.value == 'once': self.frequencyEntry = None else: self.frequencyEntry = getConfigListEntry(_('Repeats'), self.timerentry_repeated, _('Choose between Daily, Weekly, Weekdays or user defined.')) self.list.append(self.frequencyEntry) self.repeatedbegindateEntry = getConfigListEntry(_('Starting on'), self.timerentry_repeatedbegindate, _('Set the date the timer must start.')) self.list.append(self.repeatedbegindateEntry) if self.timerentry_repeated.value == 'daily': pass if self.timerentry_repeated.value == 'weekdays': pass if self.timerentry_repeated.value == 'weekly': self.list.append(getConfigListEntry(_('Weekday'), self.timerentry_weekday)) if self.timerentry_repeated.value == 'user': self.list.append(getConfigListEntry(_('Monday'), self.timerentry_day[0])) self.list.append(getConfigListEntry(_('Tuesday'), self.timerentry_day[1])) self.list.append(getConfigListEntry(_('Wednesday'), self.timerentry_day[2])) self.list.append(getConfigListEntry(_('Thursday'), self.timerentry_day[3])) self.list.append(getConfigListEntry(_('Friday'), self.timerentry_day[4])) self.list.append(getConfigListEntry(_('Saturday'), self.timerentry_day[5])) self.list.append(getConfigListEntry(_('Sunday'), self.timerentry_day[6])) if self.timerentry_justplay.value != 'zap': self.list.append(getConfigListEntry(_('Rename name and description for new events'), self.timerentry_renamerepeat)) self.entryDate = getConfigListEntry(_('Date'), self.timerentry_date, _('Set the date the timer must start.')) if self.timerentry_type.value == 'once': self.list.append(self.entryDate) self.entryStartTime = getConfigListEntry(_('Start time'), self.timerentry_starttime, _('Set the time the timer must start.')) self.list.append(self.entryStartTime) self.entryShowEndTime = getConfigListEntry(_('Set end time'), self.timerentry_showendtime, _('Set the time the timer must stop.')) if self.timerentry_justplay.value == 'zap': self.list.append(self.entryShowEndTime) self.entryEndTime = getConfigListEntry(_('End time'), self.timerentry_endtime, _('Set the time the timer must stop.')) if self.timerentry_justplay.value != 'zap' or self.timerentry_showendtime.value: self.list.append(self.entryEndTime) self.channelEntry = getConfigListEntry(_('Channel'), self.timerentry_service, _('Set the channel for this timer.')) self.list.append(self.channelEntry) if self.timerentry_showendtime.value and self.timerentry_justplay.value == 'zap': self.list.append(getConfigListEntry(_('After event'), self.timerentry_afterevent, _("What action is required on complettion of the timer? 'Auto' lets the box return to the state it had when the timer started. 'Do nothing', 'Go to standby' and 'Go to deep standby' do ecaxtly that."))) self.dirname = getConfigListEntry(_('Location'), self.timerentry_dirname, _('Where should the recording be saved?')) self.tagsSet = getConfigListEntry(_('Tags'), self.timerentry_tagsset, _('Choose a tag for easy finding a recording.')) if self.timerentry_justplay.value != 'zap': if config.usage.setup_level.index >= 2: self.list.append(self.dirname) if getPreferredTagEditor(): self.list.append(self.tagsSet) self.list.append(getConfigListEntry(_('After event'), self.timerentry_afterevent, _("What action is required on complettion of the timer? 'Auto' lets the box return to the state it had when the timer started. 'Do nothing', 'Go to standby' and 'Go to deep standby' do ecaxtly that."))) self.list.append(getConfigListEntry(_('Recording type'), self.timerentry_recordingtype, _("Descramble & record ECM' gives the option to descramble afterwards if descrambling on recording failed. 'Don't descramble, record ECM' save a scramble recording that can be descrambled on playback. 'Normal' means descramble the recording and don't record ECM."))) self[widget].list = self.list self[widget].l.setList(self.list) return def selectionChanged(self): if self['config'].getCurrent(): if len(self['config'].getCurrent()) > 2 and self['config'].getCurrent()[2]: self['description'].setText(self['config'].getCurrent()[2]) if isinstance(self['config'].getCurrent()[1], ConfigText): if self.has_key('VKeyIcon'): self['VirtualKB'].setEnabled(True) self['VKeyIcon'].boolean = True if self.has_key('HelpWindow'): if self['config'].getCurrent()[1].help_window and self['config'].getCurrent()[1].help_window.instance is not None: helpwindowpos = self['HelpWindow'].getPosition() from enigma import ePoint self['config'].getCurrent()[1].help_window.instance.move(ePoint(helpwindowpos[0], helpwindowpos[1])) elif self.has_key('VKeyIcon'): self['VirtualKB'].setEnabled(False) self['VKeyIcon'].boolean = False elif self.has_key('VKeyIcon'): self['VirtualKB'].setEnabled(False) self['VKeyIcon'].boolean = False return def layoutFinished(self): self.setTitle(_(self.setup_title)) def createSummary(self): return SetupSummary def changedEntry(self): for x in self.onChangedEntry: x() def getCurrentEntry(self): return self['config'].getCurrent() and self['config'].getCurrent()[0] or '' def getCurrentValue(self): return self['config'].getCurrent() and str(self['config'].getCurrent()[1].getText()) or '' def newConfig(self): if self['config'].getCurrent() in (self.timerTypeEntry, self.timerJustplayEntry, self.frequencyEntry, self.entryShowEndTime): self.createSetup('config') def KeyText(self): if self['config'].getCurrent()[0] in (_('Name'), _('Description')): self.session.openWithCallback(self.renameEntryCallback, VirtualKeyBoard, title=self['config'].getCurrent()[2], text=self['config'].getCurrent()[1].value) def keyLeft(self): cur = self['config'].getCurrent() if cur in (self.channelEntry, self.tagsSet): self.keySelect() elif cur in (self.entryName, self.entryDescription): self.renameEntry() else: ConfigListScreen.keyLeft(self) self.newConfig() def keyRight(self): cur = self['config'].getCurrent() if cur in (self.channelEntry, self.tagsSet): self.keySelect() elif cur in (self.entryName, self.entryDescription): self.renameEntry() else: ConfigListScreen.keyRight(self) self.newConfig() def renameEntry(self): cur = self['config'].getCurrent() if cur == self.entryName: title_text = _('Please enter new name:') old_text = self.timerentry_name.value else: title_text = _('Please enter new description:') old_text = self.timerentry_description.value self.session.openWithCallback(self.renameEntryCallback, VirtualKeyBoard, title=title_text, text=old_text) def renameEntryCallback(self, answer): if answer: if self['config'].getCurrent() == self.entryName: self.timerentry_name.value = answer self['config'].invalidate(self.entryName) else: self.timerentry_description.value = answer self['config'].invalidate(self.entryDescription) def handleKeyFileCallback(self, answer): if self['config'].getCurrent() in (self.channelEntry, self.tagsSet): self.keySelect() else: ConfigListScreen.handleKeyFileCallback(self, answer) self.newConfig() def keySelect(self): cur = self['config'].getCurrent() if cur == self.channelEntry: self.session.openWithCallback(self.finishedChannelSelection, ChannelSelection.SimpleChannelSelection, _('Select channel to record from'), currentBouquet=True) elif config.usage.setup_level.index >= 2 and cur == self.dirname: self.session.openWithCallback(self.pathSelected, MovieLocationBox, _('Select target folder'), self.timerentry_dirname.value, minFree=100) elif getPreferredTagEditor() and cur == self.tagsSet: self.session.openWithCallback(self.tagEditFinished, getPreferredTagEditor(), self.timerentry_tags) else: self.keyGo() def finishedChannelSelection(self, *args): if args: self.timerentry_service_ref = ServiceReference(args[0]) self.timerentry_service.setCurrentText(self.timerentry_service_ref.getServiceName()) self['config'].invalidate(self.channelEntry) def getTimestamp(self, date, mytime): d = localtime(date) dt = datetime(d.tm_year, d.tm_mon, d.tm_mday, mytime[0], mytime[1]) return int(mktime(dt.timetuple())) def getBeginEnd(self): date = self.timerentry_date.value endtime = self.timerentry_endtime.value starttime = self.timerentry_starttime.value begin = self.getTimestamp(date, starttime) end = self.getTimestamp(date, endtime) if end < begin: end += 86400 if self.timerentry_justplay.value == 'zap': if not self.timerentry_showendtime.value: end = begin + 1 return (begin, end) def selectChannelSelector(self, *args): self.session.openWithCallback(self.finishedChannelSelectionCorrection, ChannelSelection.SimpleChannelSelection, _('Select channel to record from')) def finishedChannelSelectionCorrection(self, *args): if args: self.finishedChannelSelection(*args) self.keyGo() def keyGo(self, result = None): if not self.timerentry_service_ref.isRecordable(): self.session.openWithCallback(self.selectChannelSelector, MessageBox, _("You didn't select a channel to record from."), MessageBox.TYPE_ERROR) return else: self.timer.name = self.timerentry_name.value self.timer.description = self.timerentry_description.value self.timer.justplay = self.timerentry_justplay.value == 'zap' self.timer.always_zap = self.timerentry_justplay.value == 'zap+record' self.timer.rename_repeat = self.timerentry_renamerepeat.value if self.timerentry_justplay.value == 'zap': if not self.timerentry_showendtime.value: self.timerentry_endtime.value = self.timerentry_starttime.value self.timerentry_afterevent.value = 'nothing' if self.timerentry_endtime.value == self.timerentry_starttime.value and self.timerentry_afterevent.value != 'nothing': self.timerentry_afterevent.value = 'nothing' self.session.open(MessageBox, _('Difference between timer begin and end must be equal or greater than %d minutes.\nEnd Action was disabled !') % 1, MessageBox.TYPE_INFO, timeout=30) self.timer.resetRepeated() self.timer.afterEvent = {'nothing': AFTEREVENT.NONE, 'deepstandby': AFTEREVENT.DEEPSTANDBY, 'standby': AFTEREVENT.STANDBY, 'auto': AFTEREVENT.AUTO}[self.timerentry_afterevent.value] self.timer.descramble = {'normal': True, 'descrambled+ecm': True, 'scrambled+ecm': False}[self.timerentry_recordingtype.value] self.timer.record_ecm = {'normal': False, 'descrambled+ecm': True, 'scrambled+ecm': True}[self.timerentry_recordingtype.value] self.timer.service_ref = self.timerentry_service_ref self.timer.tags = self.timerentry_tags if self.timer.dirname or self.timerentry_dirname.value != defaultMoviePath(): self.timer.dirname = self.timerentry_dirname.value config.movielist.last_timer_videodir.value = self.timer.dirname config.movielist.last_timer_videodir.save() if self.timerentry_type.value == 'once': self.timer.begin, self.timer.end = self.getBeginEnd() if self.timerentry_type.value == 'repeated': if self.timerentry_repeated.value == 'daily': for x in (0, 1, 2, 3, 4, 5, 6): self.timer.setRepeated(x) if self.timerentry_repeated.value == 'weekly': self.timer.setRepeated(self.timerentry_weekday.index) if self.timerentry_repeated.value == 'weekdays': for x in (0, 1, 2, 3, 4): self.timer.setRepeated(x) if self.timerentry_repeated.value == 'user': for x in (0, 1, 2, 3, 4, 5, 6): if self.timerentry_day[x].value: self.timer.setRepeated(x) self.timer.repeatedbegindate = self.getTimestamp(self.timerentry_repeatedbegindate.value, self.timerentry_starttime.value) if self.timer.repeated: self.timer.begin = self.getTimestamp(self.timerentry_repeatedbegindate.value, self.timerentry_starttime.value) self.timer.end = self.getTimestamp(self.timerentry_repeatedbegindate.value, self.timerentry_endtime.value) else: self.timer.begin = self.getTimestamp(time.time(), self.timerentry_starttime.value) self.timer.end = self.getTimestamp(time.time(), self.timerentry_endtime.value) if self.timer.end < self.timer.begin: self.timer.end += 86400 if self.timer.eit is not None: event = eEPGCache.getInstance().lookupEventId(self.timer.service_ref.ref, self.timer.eit) if event: n = event.getNumOfLinkageServices() if n > 1: tlist = [] ref = self.session.nav.getCurrentlyPlayingServiceOrGroup() parent = self.timer.service_ref.ref selection = 0 for x in range(n): i = event.getLinkageService(parent, x) if i.toString() == ref.toString(): selection = x tlist.append((i.getName(), i)) self.session.openWithCallback(self.subserviceSelected, ChoiceBox, title=_('Please select a subservice to record...'), list=tlist, selection=selection) return if n > 0: parent = self.timer.service_ref.ref self.timer.service_ref = ServiceReference(event.getLinkageService(parent, 0)) self.saveTimer() self.close((True, self.timer)) return def changeTimerType(self): self.timerentry_justplay.selectNext() self.timerJustplayEntry = getConfigListEntry(_('Timer type'), self.timerentry_justplay) self['config'].invalidate(self.timerJustplayEntry) def incrementStart(self): self.timerentry_starttime.increment() self['config'].invalidate(self.entryStartTime) if self.timerentry_type.value == 'once' and self.timerentry_starttime.value == [0, 0]: self.timerentry_date.value += 86400 self['config'].invalidate(self.entryDate) def decrementStart(self): self.timerentry_starttime.decrement() self['config'].invalidate(self.entryStartTime) if self.timerentry_type.value == 'once' and self.timerentry_starttime.value == [23, 59]: self.timerentry_date.value -= 86400 self['config'].invalidate(self.entryDate) def incrementEnd(self): if self.entryEndTime is not None: self.timerentry_endtime.increment() self['config'].invalidate(self.entryEndTime) return def decrementEnd(self): if self.entryEndTime is not None: self.timerentry_endtime.decrement() self['config'].invalidate(self.entryEndTime) return def subserviceSelected(self, service): if service is not None: self.timer.service_ref = ServiceReference(service[1]) self.saveTimer() self.close((True, self.timer)) return def saveTimer(self): self.session.nav.RecordTimer.saveTimer() def keyCancel(self): self.close((False,)) def pathSelected(self, res): if res is not None: if config.movielist.videodirs.value != self.timerentry_dirname.choices: self.timerentry_dirname.setChoices(config.movielist.videodirs.value, default=res) self.timerentry_dirname.value = res return def tagEditFinished(self, ret): if ret is not None: self.timerentry_tags = ret self.timerentry_tagsset.setChoices([not ret and 'None' or ' '.join(ret)]) self['config'].invalidate(self.tagsSet) return
class TimerEntry(Screen, ConfigListScreen): EMPTY = 0 def __init__(self, session, timer): Screen.__init__(self, session) self.timer = timer self.timer.service_ref_prev = self.timer.service_ref self.timer.begin_prev = self.timer.begin self.timer.end_prev = self.timer.end self.timer.external_prev = self.timer.external self.timer.dirname_prev = self.timer.dirname self.entryDate = None self.entryService = None self.key_red_choice = self.EMPTY if self.key_red_choice != Pixmap: self["key_red"] = StaticText(_("Cancel")) self["key_green"] = StaticText(_("Save")) self["key_yellow"] = StaticText(_("Timer type")) self["key_blue"] = StaticText("") if self.key_red_choice != StaticText: self["oktext"] = Label(_("OK")) self["canceltext"] = Label(_("Cancel")) self["ok"] = Pixmap() self["cancel"] = Pixmap() self["actions"] = NumberActionMap( [ "SetupActions", "GlobalActions", "PiPSetupActions", "ColorActions" ], { "ok": self.keySelect, "save": self.keyGo, "cancel": self.keyCancel, "volumeUp": self.incrementStart, "volumeDown": self.decrementStart, "size+": self.incrementEnd, "size-": self.decrementEnd, "red": self.keyCancel, "green": self.keyGo, "yellow": self.changeTimerType, "blue": self.changeZapWakeupType }, -2) self.list = [] ConfigListScreen.__init__(self, self.list, session=session) self.setTitle(_("Timer entry")) FallbackTimerDirs(self, self.createConfig) def createConfig(self, currlocation=None, locations=[]): justplay = self.timer.justplay always_zap = self.timer.always_zap zap_wakeup = self.timer.zap_wakeup pipzap = self.timer.pipzap rename_repeat = self.timer.rename_repeat conflict_detection = self.timer.conflict_detection afterevent = { AFTEREVENT.NONE: "nothing", AFTEREVENT.DEEPSTANDBY: "deepstandby", AFTEREVENT.STANDBY: "standby", AFTEREVENT.AUTO: "auto" }[self.timer.afterEvent] if self.timer.record_ecm and self.timer.descramble: recordingtype = "descrambled+ecm" elif self.timer.record_ecm: recordingtype = "scrambled+ecm" elif self.timer.descramble: recordingtype = "normal" weekday_table = ("mon", "tue", "wed", "thu", "fri", "sat", "sun") day = list( [int(x) for x in reversed('{0:07b}'.format(self.timer.repeated))]) weekday = 0 if self.timer.repeated: # repeated type = "repeated" if (self.timer.repeated == 31): # Mon-Fri repeated = "weekdays" elif (self.timer.repeated == 127): # daily repeated = "daily" else: repeated = "user" if day.count(1) == 1: repeated = "weekly" weekday = day.index(1) else: # once type = "once" repeated = None weekday = int(strftime("%u", localtime(self.timer.begin))) - 1 day[weekday] = 1 self.timerentry_fallback = ConfigYesNo( default=self.timer.external_prev or config.usage.remote_fallback_external_timer.value and config.usage. remote_fallback.value and not nimmanager.somethingConnected()) self.timerentry_justplay = ConfigSelection( choices=[("zap", _("zap")), ("record", _("record")), ("zap+record", _("zap and record"))], default={ 0: "record", 1: "zap", 2: "zap+record" }[justplay + 2 * always_zap]) if SystemInfo["DeepstandbySupport"]: shutdownString = _("go to deep standby") choicelist = [("always", _("always")), ("from_standby", _("only from standby")), ("from_deep_standby", _("only from deep standby")), ("never", _("never"))] else: shutdownString = _("shut down") choicelist = [("always", _("always")), ("never", _("never"))] self.timerentry_zapwakeup = ConfigSelection(choices=choicelist, default=zap_wakeup) self.timerentry_afterevent = ConfigSelection(choices=[ ("nothing", _("do nothing")), ("standby", _("go to standby")), ("deepstandby", shutdownString), ("auto", _("auto")) ], default=afterevent) self.timerentry_recordingtype = ConfigSelection(choices=[ ("normal", _("normal")), ("descrambled+ecm", _("descramble and record ecm")), ("scrambled+ecm", _("don't descramble, record ecm")) ], default=recordingtype) self.timerentry_type = ConfigSelection(choices=[("once", _("once")), ("repeated", _("repeated"))], default=type) self.timerentry_name = ConfigText(default=self.timer.name, visible_width=50, fixed_size=False) self.timerentry_description = ConfigText( default=self.timer.description, visible_width=50, fixed_size=False) self.timerentry_tags = self.timer.tags[:] self.timerentry_tagsset = ConfigSelection(choices=[ not self.timerentry_tags and "None" or " ".join(self.timerentry_tags) ]) self.timerentry_repeated = ConfigSelection( default=repeated, choices=[("weekly", _("weekly")), ("daily", _("daily")), ("weekdays", _("Mon-Fri")), ("user", _("user defined"))]) self.timerentry_renamerepeat = ConfigYesNo(default=rename_repeat) self.timerentry_pipzap = ConfigYesNo(default=pipzap) self.timerentry_conflictdetection = ConfigYesNo( default=conflict_detection) self.timerentry_date = ConfigDateTime( default=self.timer.begin, formatstring=config.usage.date.full.value, increment=86400) self.timerentry_starttime = ConfigClock(default=self.timer.begin) self.timerentry_endtime = ConfigClock(default=self.timer.end) self.timerentry_showendtime = ConfigSelection( default=((self.timer.end - self.timer.begin) > 4), choices=[(True, _("yes")), (False, _("no"))]) default = not self.timer.external_prev and self.timer.dirname or defaultMoviePath( ) tmp = config.movielist.videodirs.value if default not in tmp: tmp.append(default) self.timerentry_dirname = ConfigSelection(default=default, choices=tmp) default = self.timer.external_prev and self.timer.dirname or currlocation if default not in locations: locations.append(default) self.timerentry_fallbackdirname = ConfigSelection(default=default, choices=locations) self.timerentry_repeatedbegindate = ConfigDateTime( default=self.timer.repeatedbegindate, formatstring=config.usage.date.full.value, increment=86400) self.timerentry_weekday = ConfigSelection( default=weekday_table[weekday], choices=[("mon", _("Monday")), ("tue", _("Tuesday")), ("wed", _("Wednesday")), ("thu", _("Thursday")), ("fri", _("Friday")), ("sat", _("Saturday")), ("sun", _("Sunday"))]) self.timerentry_day = ConfigSubList() for x in (0, 1, 2, 3, 4, 5, 6): self.timerentry_day.append(ConfigYesNo(default=day[x])) # FIXME some service-chooser needed here servicename = "N/A" try: # no current service available? servicename = str(self.timer.service_ref.getServiceName()) except: pass self.timerentry_service_ref = self.timer.service_ref self.timerentry_service = ConfigSelection([servicename]) self.createSetup("config") def createSetup(self, widget): self.list = [] self.entryFallbackTimer = getConfigListEntry(_("Fallback Timer"), self.timerentry_fallback) if config.usage.remote_fallback_external_timer.value and config.usage.remote_fallback.value and not hasattr( self, "timerentry_remote"): self.list.append(self.entryFallbackTimer) self.entryName = getConfigListEntry(_("Name"), self.timerentry_name) self.list.append(self.entryName) self.entryDescription = getConfigListEntry(_("Description"), self.timerentry_description) self.list.append(self.entryDescription) self.timerJustplayEntry = getConfigListEntry(_("Timer type"), self.timerentry_justplay) self.list.append(self.timerJustplayEntry) self.timerTypeEntry = getConfigListEntry(_("Repeat type"), self.timerentry_type) self.list.append(self.timerTypeEntry) if self.timerentry_type.value == "once": self.frequencyEntry = None else: # repeated self.frequencyEntry = getConfigListEntry(_("Repeats"), self.timerentry_repeated) self.list.append(self.frequencyEntry) self.repeatedbegindateEntry = getConfigListEntry( _("Starting on"), self.timerentry_repeatedbegindate) self.list.append(self.repeatedbegindateEntry) if self.timerentry_repeated.value == "daily": pass if self.timerentry_repeated.value == "weekdays": pass if self.timerentry_repeated.value == "weekly": self.list.append( getConfigListEntry(_("Weekday"), self.timerentry_weekday)) if self.timerentry_repeated.value == "user": self.list.append( getConfigListEntry(_("Monday"), self.timerentry_day[0])) self.list.append( getConfigListEntry(_("Tuesday"), self.timerentry_day[1])) self.list.append( getConfigListEntry(_("Wednesday"), self.timerentry_day[2])) self.list.append( getConfigListEntry(_("Thursday"), self.timerentry_day[3])) self.list.append( getConfigListEntry(_("Friday"), self.timerentry_day[4])) self.list.append( getConfigListEntry(_("Saturday"), self.timerentry_day[5])) self.list.append( getConfigListEntry(_("Sunday"), self.timerentry_day[6])) if self.timerentry_justplay.value != "zap": self.list.append( getConfigListEntry( _("Rename name and description for new events"), self.timerentry_renamerepeat)) self.entryDate = getConfigListEntry(_("Date"), self.timerentry_date) if self.timerentry_type.value == "once": self.list.append(self.entryDate) self.entryStartTime = getConfigListEntry(_("Start time"), self.timerentry_starttime) self.list.append(self.entryStartTime) self.entryShowEndTime = getConfigListEntry(_("Set end time"), self.timerentry_showendtime) self.entryZapWakeup = getConfigListEntry( _("Wakeup receiver for start timer"), self.timerentry_zapwakeup) if self.timerentry_justplay.value == "zap": self.list.append(self.entryZapWakeup) if SystemInfo["PIPAvailable"]: self.list.append( getConfigListEntry(_("Use as PiP if possible"), self.timerentry_pipzap)) self.list.append(self.entryShowEndTime) self["key_blue"].setText(_("Wakeup type")) else: self["key_blue"].setText("") self.entryEndTime = getConfigListEntry(_("End time"), self.timerentry_endtime) if self.timerentry_justplay.value != "zap" or self.timerentry_showendtime.value: self.list.append(self.entryEndTime) self.channelEntry = getConfigListEntry(_("Channel"), self.timerentry_service) self.list.append(self.channelEntry) self.dirname = getConfigListEntry( _("Location"), self.timerentry_fallbackdirname ) if self.timerentry_fallback.value and self.timerentry_fallbackdirname.value else getConfigListEntry( _("Location"), self.timerentry_dirname) if config.usage.setup_level.index >= 2 and ( self.timerentry_fallback.value and self.timerentry_fallbackdirname.value or self.timerentry_dirname.value): # expert+ self.list.append(self.dirname) self.conflictDetectionEntry = getConfigListEntry( _("Enable timer conflict detection"), self.timerentry_conflictdetection) if not self.timerentry_fallback.value: self.list.append(self.conflictDetectionEntry) self.tagsSet = getConfigListEntry(_("Tags"), self.timerentry_tagsset) if self.timerentry_justplay.value != "zap" and not self.timerentry_fallback.value: if getPreferredTagEditor(): self.list.append(self.tagsSet) self.list.append( getConfigListEntry(_("After event"), self.timerentry_afterevent)) self.list.append( getConfigListEntry(_("Recording type"), self.timerentry_recordingtype)) self[widget].list = self.list self[widget].l.setList(self.list) def newConfig(self): print "[TimerEdit] newConfig", self["config"].getCurrent() if self["config"].getCurrent() in (self.timerTypeEntry, self.timerJustplayEntry, self.frequencyEntry, self.entryShowEndTime, self.entryFallbackTimer): self.createSetup("config") def keyLeft(self): cur = self["config"].getCurrent() if cur in (self.channelEntry, self.tagsSet): self.keySelect() elif cur in (self.entryName, self.entryDescription): self.renameEntry() else: ConfigListScreen.keyLeft(self) self.newConfig() def keyRight(self): cur = self["config"].getCurrent() if cur in (self.channelEntry, self.tagsSet): self.keySelect() elif cur in (self.entryName, self.entryDescription): self.renameEntry() else: ConfigListScreen.keyRight(self) self.newConfig() def renameEntry(self): cur = self["config"].getCurrent() if cur == self.entryName: title_text = _("Please enter new name:") old_text = self.timerentry_name.value else: title_text = _("Please enter new description:") old_text = self.timerentry_description.value self.session.openWithCallback(self.renameEntryCallback, VirtualKeyBoard, title=title_text, text=old_text) def renameEntryCallback(self, answer): if answer: cur = self["config"].getCurrent() if cur == self.entryName: self.timerentry_name.value = answer self["config"].invalidate(self.entryName) else: self.timerentry_description.value = answer self["config"].invalidate(self.entryDescription) def handleKeyFileCallback(self, answer): if self["config"].getCurrent() in (self.channelEntry, self.tagsSet): self.keySelect() else: ConfigListScreen.handleKeyFileCallback(self, answer) self.newConfig() def openMovieLocationBox(self, answer=""): self.session.openWithCallback( self.pathSelected, MovieLocationBox, _("Select target folder"), self.timerentry_dirname.value, filename=answer, minFree=100 # We require at least 100MB free space ) def keySelect(self): cur = self["config"].getCurrent() if cur == self.channelEntry: self.session.openWithCallback( self.finishedChannelSelection, ChannelSelection.SimpleChannelSelection, _("Select channel to record from"), currentBouquet=True) elif cur == self.dirname: menu = [(_("Open select location"), "empty")] if self.timerentry_type.value == "repeated" and self.timerentry_name.value: menu.append( (_("Open select location as timer name"), "timername")) if len(menu) == 1: self.openMovieLocationBox() elif len(menu) == 2: text = _("Select action") def selectAction(choice): if choice: if choice[1] == "timername": self.openMovieLocationBox( self.timerentry_name.value) elif choice[1] == "empty": self.openMovieLocationBox() self.session.openWithCallback(selectAction, ChoiceBox, title=text, list=menu) elif getPreferredTagEditor() and cur == self.tagsSet: self.session.openWithCallback(self.tagEditFinished, getPreferredTagEditor(), self.timerentry_tags) else: self.keyGo() def finishedChannelSelection(self, *args): if args: self.timerentry_service_ref = ServiceReference(args[0]) self.timerentry_service.setCurrentText( self.timerentry_service_ref.getServiceName()) self["config"].invalidate(self.channelEntry) def getTimestamp(self, date, mytime): d = localtime(date) dt = datetime(d.tm_year, d.tm_mon, d.tm_mday, mytime[0], mytime[1]) return int(mktime(dt.timetuple())) def getBeginEnd(self): date = self.timerentry_date.value endtime = self.timerentry_endtime.value starttime = self.timerentry_starttime.value begin = self.getTimestamp(date, starttime) end = self.getTimestamp(date, endtime) # if the endtime is less than the starttime, add 1 day. if end < begin: end += 86400 return begin, end def selectChannelSelector(self, *args): self.session.openWithCallback(self.finishedChannelSelectionCorrection, ChannelSelection.SimpleChannelSelection, _("Select channel to record from")) def finishedChannelSelectionCorrection(self, *args): if args: self.finishedChannelSelection(*args) self.keyGo() def RemoteSubserviceSelected(self, service): if service: # ouch, this hurts a little service_ref = timerentry_service_ref self.timerentry_service_ref = ServiceReference(service[1]) eit = self.timer.eit self.timer.eit = None self.keyGo() self.timerentry_service_ref = service_ref self.timer.eit = eit def keyGo(self, result=None): if not self.timerentry_service_ref.isRecordable(): self.session.openWithCallback( self.selectChannelSelector, MessageBox, _("You didn't select a channel to record from."), MessageBox.TYPE_ERROR) else: self.timer.external = self.timerentry_fallback.value self.timer.name = self.timerentry_name.value self.timer.description = self.timerentry_description.value self.timer.justplay = self.timerentry_justplay.value == "zap" self.timer.always_zap = self.timerentry_justplay.value == "zap+record" self.timer.zap_wakeup = self.timerentry_zapwakeup.value self.timer.pipzap = self.timerentry_pipzap.value self.timer.rename_repeat = self.timerentry_renamerepeat.value self.timer.conflict_detection = self.timerentry_conflictdetection.value if self.timerentry_justplay.value == "zap": if not self.timerentry_showendtime.value: self.timerentry_endtime.value = self.timerentry_starttime.value self.timerentry_afterevent.value = "nothing" self.timer.resetRepeated() self.timer.afterEvent = { "nothing": AFTEREVENT.NONE, "deepstandby": AFTEREVENT.DEEPSTANDBY, "standby": AFTEREVENT.STANDBY, "auto": AFTEREVENT.AUTO }[self.timerentry_afterevent.value] # There is no point doing anything after a Zap-only timer! # For a start, you can't actually configure anything in the menu, but # leaving it as AUTO means that the code may try to shutdown at Zap time # if the Zap timer woke the box up. # if self.timer.justplay: self.timer.afterEvent = AFTEREVENT.NONE self.timer.descramble = { "normal": True, "descrambled+ecm": True, "scrambled+ecm": False, }[self.timerentry_recordingtype.value] self.timer.record_ecm = { "normal": False, "descrambled+ecm": True, "scrambled+ecm": True, }[self.timerentry_recordingtype.value] self.timer.service_ref = self.timerentry_service_ref self.timer.tags = self.timerentry_tags if self.timerentry_fallback.value: self.timer.dirname = self.timerentry_fallbackdirname.value else: if self.timer.dirname or self.timerentry_dirname.value != defaultMoviePath( ): self.timer.dirname = self.timerentry_dirname.value config.movielist.last_timer_videodir.value = self.timer.dirname config.movielist.last_timer_videodir.save() if self.timerentry_type.value == "once": self.timer.begin, self.timer.end = self.getBeginEnd() if self.timerentry_type.value == "repeated": if self.timerentry_repeated.value == "daily": for x in (0, 1, 2, 3, 4, 5, 6): self.timer.setRepeated(x) if self.timerentry_repeated.value == "weekly": self.timer.setRepeated(self.timerentry_weekday.index) if self.timerentry_repeated.value == "weekdays": for x in (0, 1, 2, 3, 4): self.timer.setRepeated(x) if self.timerentry_repeated.value == "user": for x in (0, 1, 2, 3, 4, 5, 6): if self.timerentry_day[x].value: self.timer.setRepeated(x) self.timer.repeatedbegindate = self.getTimestamp( self.timerentry_repeatedbegindate.value, self.timerentry_starttime.value) if self.timer.repeated: self.timer.begin = self.getTimestamp( self.timerentry_repeatedbegindate.value, self.timerentry_starttime.value) self.timer.end = self.getTimestamp( self.timerentry_repeatedbegindate.value, self.timerentry_endtime.value) else: self.timer.begin = self.getTimestamp( time(), self.timerentry_starttime.value) self.timer.end = self.getTimestamp( time(), self.timerentry_endtime.value) # when a timer end is set before the start, add 1 day if self.timer.end < self.timer.begin: self.timer.end += 86400 if self.timer.eit is not None: event = eEPGCache.getInstance().lookupEventId( self.timer.service_ref.ref, self.timer.eit) if event: n = event.getNumOfLinkageServices() if n > 1: tlist = [] ref = self.session.nav.getCurrentlyPlayingServiceOrGroup( ) parent = self.timer.service_ref.ref selection = 0 for x in range(n): i = event.getLinkageService(parent, x) if i.toString() == ref.toString(): selection = x tlist.append((i.getName(), i)) self.session.openWithCallback( self.subserviceSelected, ChoiceBox, title=_("Please select a subservice to record..."), list=tlist, selection=selection) return elif n > 0: parent = self.timer.service_ref.ref self.timer.service_ref = ServiceReference( event.getLinkageService(parent, 0)) self.saveTimer() self.close((True, self.timer)) def changeTimerType(self): self.timerentry_justplay.selectNext() self.timerJustplayEntry = getConfigListEntry(_("Timer type"), self.timerentry_justplay) self["config"].invalidate(self.timerJustplayEntry) self.createSetup("config") def changeZapWakeupType(self): if self.timerentry_justplay.value == "zap": self.timerentry_zapwakeup.selectNext() self["config"].invalidate(self.entryZapWakeup) def incrementStart(self): self.timerentry_starttime.increment() self["config"].invalidate(self.entryStartTime) if self.timerentry_type.value == "once" and self.timerentry_starttime.value == [ 0, 0 ]: self.timerentry_date.value += 86400 self["config"].invalidate(self.entryDate) def decrementStart(self): self.timerentry_starttime.decrement() self["config"].invalidate(self.entryStartTime) if self.timerentry_type.value == "once" and self.timerentry_starttime.value == [ 23, 59 ]: self.timerentry_date.value -= 86400 self["config"].invalidate(self.entryDate) def incrementEnd(self): if self.entryEndTime is not None: self.timerentry_endtime.increment() self["config"].invalidate(self.entryEndTime) def decrementEnd(self): if self.entryEndTime is not None: self.timerentry_endtime.decrement() self["config"].invalidate(self.entryEndTime) def subserviceSelected(self, service): if not service is None: self.timer.service_ref = ServiceReference(service[1]) self.saveTimer() self.close((True, self.timer)) def saveTimer(self): self.session.nav.RecordTimer.saveTimer() def keyCancel(self): self.close((False, )) def pathSelected(self, res): if res is not None: if config.movielist.videodirs.value != self.timerentry_dirname.choices: self.timerentry_dirname.setChoices( config.movielist.videodirs.value, default=res) self.timerentry_dirname.value = res def tagEditFinished(self, ret): if ret is not None: self.timerentry_tags = ret self.timerentry_tagsset.setChoices( [not ret and "None" or " ".join(ret)]) self["config"].invalidate(self.tagsSet)
class TimerEntry(Screen, ConfigListScreen): def __init__(self, session, timer): Screen.__init__(self, session) self.timer = timer self.entryDate = None self.entryService = None self["HelpWindow"] = Pixmap() self["HelpWindow"].hide() self["oktext"] = Label(_("OK")) self["canceltext"] = Label(_("Cancel")) self["ok"] = Pixmap() self["cancel"] = Pixmap() self.createConfig() self["actions"] = NumberActionMap(["SetupActions", "GlobalActions", "PiPSetupActions"], { "ok": self.keySelect, "save": self.keyGo, "cancel": self.keyCancel, "volumeUp": self.incrementStart, "volumeDown": self.decrementStart, "size+": self.incrementEnd, "size-": self.decrementEnd }, -2) self.list = [] ConfigListScreen.__init__(self, self.list, session = session) self.setTitle(_("PowerManager entry")) self.createSetup("config") def createConfig(self): afterevent = { AFTEREVENT.NONE: "nothing", AFTEREVENT.WAKEUPTOSTANDBY: "wakeuptostandby", AFTEREVENT.STANDBY: "standby", AFTEREVENT.DEEPSTANDBY: "deepstandby" }[self.timer.afterEvent] 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.timer.timerType] weekday_table = ("mon", "tue", "wed", "thu", "fri", "sat", "sun") # calculate default values day = [] weekday = 0 for x in (0, 1, 2, 3, 4, 5, 6): day.append(0) if self.timer.repeated: # repeated type = "repeated" if self.timer.repeated == 31: # Mon-Fri repeated = "weekdays" elif self.timer.repeated == 127: # daily repeated = "daily" else: flags = self.timer.repeated repeated = "user" count = 0 for x in (0, 1, 2, 3, 4, 5, 6): if flags == 1: # weekly print "Set to weekday " + str(x) weekday = x if flags & 1 == 1: # set user defined flags day[x] = 1 count += 1 else: day[x] = 0 flags >>= 1 if count == 1: repeated = "weekly" else: # once type = "once" repeated = None weekday = int(strftime("%u", localtime(self.timer.begin))) - 1 day[weekday] = 1 autosleepinstandbyonly = self.timer.autosleepinstandbyonly autosleepdelay = self.timer.autosleepdelay autosleeprepeat = self.timer.autosleeprepeat if SystemInfo["DeepstandbySupport"]: shutdownString = _("go to deep standby") else: shutdownString = _("shut down") self.timerentry_timertype = ConfigSelection(choices = [("wakeup", _("wakeup")),("wakeuptostandby", _("wakeup to standby")), ("autostandby", _("auto standby")), ("autodeepstandby", _("auto deepstandby")), ("standby", _("go to standby")), ("deepstandby", shutdownString), ("reboot", _("reboot system")), ("restart", _("restart GUI"))], default = timertype) self.timerentry_afterevent = ConfigSelection(choices = [("nothing", _("do nothing")), ("wakeuptostandby", _("wakeup to standby")), ("standby", _("go to standby")), ("deepstandby", shutdownString), ("nothing", _("do nothing"))], default = afterevent) self.timerentry_type = ConfigSelection(choices = [("once",_("once")), ("repeated", _("repeated"))], default = type) self.timerentry_repeated = ConfigSelection(default = repeated, choices = [("daily", _("daily")), ("weekly", _("weekly")), ("weekdays", _("Mon-Fri")), ("user", _("user defined"))]) self.timerrntry_autosleepdelay = ConfigInteger(default=autosleepdelay, limits = (10, 300)) self.timerentry_autosleeprepeat = ConfigSelection(choices = [("once",_("once")), ("repeated", _("repeated"))], default = autosleeprepeat) self.timerrntry_autosleepinstandbyonly = ConfigSelection(choices = [("yes",_("Yes")), ("no", _("No"))],default=autosleepinstandbyonly) self.timerentry_date = ConfigDateTime(default = self.timer.begin, formatstring = _("%d.%B %Y"), increment = 86400) self.timerentry_starttime = ConfigClock(default = self.timer.begin) self.timerentry_endtime = ConfigClock(default = self.timer.end) self.timerentry_showendtime = ConfigSelection(default = (((self.timer.end - self.timer.begin) /60 ) > 1), choices = [(True, _("yes")), (False, _("no"))]) self.timerentry_repeatedbegindate = ConfigDateTime(default = self.timer.repeatedbegindate, formatstring = _("%d.%B %Y"), increment = 86400) self.timerentry_weekday = ConfigSelection(default = weekday_table[weekday], choices = [("mon",_("Monday")), ("tue", _("Tuesday")), ("wed",_("Wednesday")), ("thu", _("Thursday")), ("fri", _("Friday")), ("sat", _("Saturday")), ("sun", _("Sunday"))]) self.timerentry_day = ConfigSubList() for x in (0, 1, 2, 3, 4, 5, 6): self.timerentry_day.append(ConfigYesNo(default = day[x])) def createSetup(self, widget): self.list = [] self.timerType = getConfigListEntry(_("Timer type"), self.timerentry_timertype) self.list.append(self.timerType) if self.timerentry_timertype.value == "autostandby" or self.timerentry_timertype.value == "autodeepstandby": if self.timerentry_timertype.value == "autodeepstandby": self.list.append(getConfigListEntry(_("Only active when in standby"), self.timerrntry_autosleepinstandbyonly)) self.list.append(getConfigListEntry(_("Sleep delay"), self.timerrntry_autosleepdelay)) self.list.append(getConfigListEntry(_("Repeat type"), self.timerentry_autosleeprepeat)) self.timerTypeEntry = getConfigListEntry(_("Repeat type"), self.timerentry_type) self.entryShowEndTime = getConfigListEntry(_("Set end time"), self.timerentry_showendtime) self.frequencyEntry = getConfigListEntry(_("Repeats"), self.timerentry_repeated) else: self.timerTypeEntry = getConfigListEntry(_("Repeat type"), self.timerentry_type) self.list.append(self.timerTypeEntry) if self.timerentry_type.value == "once": self.frequencyEntry = None else: # repeated self.frequencyEntry = getConfigListEntry(_("Repeats"), self.timerentry_repeated) self.list.append(self.frequencyEntry) self.repeatedbegindateEntry = getConfigListEntry(_("Starting on"), self.timerentry_repeatedbegindate) self.list.append(self.repeatedbegindateEntry) if self.timerentry_repeated.value == "daily": pass if self.timerentry_repeated.value == "weekdays": pass if self.timerentry_repeated.value == "weekly": self.list.append(getConfigListEntry(_("Weekday"), self.timerentry_weekday)) if self.timerentry_repeated.value == "user": self.list.append(getConfigListEntry(_("Monday"), self.timerentry_day[0])) self.list.append(getConfigListEntry(_("Tuesday"), self.timerentry_day[1])) self.list.append(getConfigListEntry(_("Wednesday"), self.timerentry_day[2])) self.list.append(getConfigListEntry(_("Thursday"), self.timerentry_day[3])) self.list.append(getConfigListEntry(_("Friday"), self.timerentry_day[4])) self.list.append(getConfigListEntry(_("Saturday"), self.timerentry_day[5])) self.list.append(getConfigListEntry(_("Sunday"), self.timerentry_day[6])) self.entryDate = getConfigListEntry(_("Date"), self.timerentry_date) if self.timerentry_type.value == "once": self.list.append(self.entryDate) self.entryStartTime = getConfigListEntry(_("Start time"), self.timerentry_starttime) self.list.append(self.entryStartTime) self.entryShowEndTime = getConfigListEntry(_("Set end time"), self.timerentry_showendtime) self.list.append(self.entryShowEndTime) self.entryEndTime = getConfigListEntry(_("End time"), self.timerentry_endtime) if self.timerentry_showendtime.value: self.list.append(self.entryEndTime) self.list.append(getConfigListEntry(_("After event"), self.timerentry_afterevent)) self[widget].list = self.list self[widget].l.setList(self.list) def newConfig(self): if self["config"].getCurrent() in (self.timerType, self.timerTypeEntry, self.frequencyEntry, self.entryShowEndTime): self.createSetup("config") def keyLeft(self): ConfigListScreen.keyLeft(self) self.newConfig() def keyRight(self): ConfigListScreen.keyRight(self) self.newConfig() def keySelect(self): cur = self["config"].getCurrent() self.keyGo() def getTimestamp(self, date, mytime): d = localtime(date) dt = datetime(d.tm_year, d.tm_mon, d.tm_mday, mytime[0], mytime[1]) return int(mktime(dt.timetuple())) def getBeginEnd(self): date = self.timerentry_date.value endtime = self.timerentry_endtime.value starttime = self.timerentry_starttime.value begin = self.getTimestamp(date, starttime) end = self.getTimestamp(date, endtime) # if the endtime is less than the starttime, add 1 day. if end < begin: end += 86400 return begin, end def keyGo(self, result = None): if not self.timerentry_showendtime.value: self.timerentry_endtime.value = self.timerentry_starttime.value self.timer.resetRepeated() self.timer.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 }[self.timerentry_timertype.value] self.timer.afterEvent = { "nothing": AFTEREVENT.NONE, "wakeuptostandby": AFTEREVENT.WAKEUPTOSTANDBY, "standby": AFTEREVENT.STANDBY, "deepstandby": AFTEREVENT.DEEPSTANDBY }[self.timerentry_afterevent.value] if self.timerentry_type.value == "once": self.timer.begin, self.timer.end = self.getBeginEnd() if self.timerentry_timertype.value == "autostandby" or self.timerentry_timertype.value == "autodeepstandby": self.timer.begin = int(time()) + 10 self.timer.end = self.timer.begin self.timer.autosleepinstandbyonly = self.timerrntry_autosleepinstandbyonly.value self.timer.autosleepdelay = self.timerrntry_autosleepdelay.value self.timer.autosleeprepeat = self.timerentry_autosleeprepeat.value if self.timerentry_type.value == "repeated": if self.timerentry_repeated.value == "daily": for x in (0, 1, 2, 3, 4, 5, 6): self.timer.setRepeated(x) if self.timerentry_repeated.value == "weekly": self.timer.setRepeated(self.timerentry_weekday.index) if self.timerentry_repeated.value == "weekdays": for x in (0, 1, 2, 3, 4): self.timer.setRepeated(x) if self.timerentry_repeated.value == "user": for x in (0, 1, 2, 3, 4, 5, 6): if self.timerentry_day[x].value: self.timer.setRepeated(x) self.timer.repeatedbegindate = self.getTimestamp(self.timerentry_repeatedbegindate.value, self.timerentry_starttime.value) if self.timer.repeated: self.timer.begin = self.getTimestamp(self.timerentry_repeatedbegindate.value, self.timerentry_starttime.value) self.timer.end = self.getTimestamp(self.timerentry_repeatedbegindate.value, self.timerentry_endtime.value) else: self.timer.begin = self.getTimestamp(time.time(), self.timerentry_starttime.value) self.timer.end = self.getTimestamp(time.time(), self.timerentry_endtime.value) # when a timer end is set before the start, add 1 day if self.timer.end < self.timer.begin: self.timer.end += 86400 self.saveTimer() self.close((True, self.timer)) def incrementStart(self): self.timerentry_starttime.increment() self["config"].invalidate(self.entryStartTime) if self.timerentry_type.value == "once" and self.timerentry_starttime.value == [0, 0]: self.timerentry_date.value += 86400 self["config"].invalidate(self.entryDate) def decrementStart(self): self.timerentry_starttime.decrement() self["config"].invalidate(self.entryStartTime) if self.timerentry_type.value == "once" and self.timerentry_starttime.value == [23, 59]: self.timerentry_date.value -= 86400 self["config"].invalidate(self.entryDate) def incrementEnd(self): if self.entryEndTime is not None: self.timerentry_endtime.increment() self["config"].invalidate(self.entryEndTime) def decrementEnd(self): if self.entryEndTime is not None: self.timerentry_endtime.decrement() self["config"].invalidate(self.entryEndTime) def saveTimer(self): self.session.nav.PowerTimer.saveTimer() def keyCancel(self): self.close((False,))
def createConfig(self, currlocation=None, locations=[]): justplay = self.timer.justplay always_zap = self.timer.always_zap zap_wakeup = self.timer.zap_wakeup pipzap = self.timer.pipzap rename_repeat = self.timer.rename_repeat conflict_detection = self.timer.conflict_detection afterevent = { AFTEREVENT.NONE: "nothing", AFTEREVENT.DEEPSTANDBY: "deepstandby", AFTEREVENT.STANDBY: "standby", AFTEREVENT.AUTO: "auto" }[self.timer.afterEvent] if self.timer.record_ecm and self.timer.descramble: recordingtype = "descrambled+ecm" elif self.timer.record_ecm: recordingtype = "scrambled+ecm" elif self.timer.descramble: recordingtype = "normal" weekday_table = ("mon", "tue", "wed", "thu", "fri", "sat", "sun") day = list( [int(x) for x in reversed('{0:07b}'.format(self.timer.repeated))]) weekday = 0 if self.timer.repeated: # repeated type = "repeated" if (self.timer.repeated == 31): # Mon-Fri repeated = "weekdays" elif (self.timer.repeated == 127): # daily repeated = "daily" else: repeated = "user" if day.count(1) == 1: repeated = "weekly" weekday = day.index(1) else: # once type = "once" repeated = None weekday = int(strftime("%u", localtime(self.timer.begin))) - 1 day[weekday] = 1 self.timerentry_fallback = ConfigYesNo( default=self.timer.external_prev or config.usage.remote_fallback_external_timer.value and config.usage. remote_fallback.value and not nimmanager.somethingConnected()) self.timerentry_justplay = ConfigSelection( choices=[("zap", _("zap")), ("record", _("record")), ("zap+record", _("zap and record"))], default={ 0: "record", 1: "zap", 2: "zap+record" }[justplay + 2 * always_zap]) if SystemInfo["DeepstandbySupport"]: shutdownString = _("go to deep standby") choicelist = [("always", _("always")), ("from_standby", _("only from standby")), ("from_deep_standby", _("only from deep standby")), ("never", _("never"))] else: shutdownString = _("shut down") choicelist = [("always", _("always")), ("never", _("never"))] self.timerentry_zapwakeup = ConfigSelection(choices=choicelist, default=zap_wakeup) self.timerentry_afterevent = ConfigSelection(choices=[ ("nothing", _("do nothing")), ("standby", _("go to standby")), ("deepstandby", shutdownString), ("auto", _("auto")) ], default=afterevent) self.timerentry_recordingtype = ConfigSelection(choices=[ ("normal", _("normal")), ("descrambled+ecm", _("descramble and record ecm")), ("scrambled+ecm", _("don't descramble, record ecm")) ], default=recordingtype) self.timerentry_type = ConfigSelection(choices=[("once", _("once")), ("repeated", _("repeated"))], default=type) self.timerentry_name = ConfigText(default=self.timer.name, visible_width=50, fixed_size=False) self.timerentry_description = ConfigText( default=self.timer.description, visible_width=50, fixed_size=False) self.timerentry_tags = self.timer.tags[:] self.timerentry_tagsset = ConfigSelection(choices=[ not self.timerentry_tags and "None" or " ".join(self.timerentry_tags) ]) self.timerentry_repeated = ConfigSelection( default=repeated, choices=[("weekly", _("weekly")), ("daily", _("daily")), ("weekdays", _("Mon-Fri")), ("user", _("user defined"))]) self.timerentry_renamerepeat = ConfigYesNo(default=rename_repeat) self.timerentry_pipzap = ConfigYesNo(default=pipzap) self.timerentry_conflictdetection = ConfigYesNo( default=conflict_detection) self.timerentry_date = ConfigDateTime( default=self.timer.begin, formatstring=config.usage.date.full.value, increment=86400) self.timerentry_starttime = ConfigClock(default=self.timer.begin) self.timerentry_endtime = ConfigClock(default=self.timer.end) self.timerentry_showendtime = ConfigSelection( default=((self.timer.end - self.timer.begin) > 4), choices=[(True, _("yes")), (False, _("no"))]) default = not self.timer.external_prev and self.timer.dirname or defaultMoviePath( ) tmp = config.movielist.videodirs.value if default not in tmp: tmp.append(default) self.timerentry_dirname = ConfigSelection(default=default, choices=tmp) default = self.timer.external_prev and self.timer.dirname or currlocation if default not in locations: locations.append(default) self.timerentry_fallbackdirname = ConfigSelection(default=default, choices=locations) self.timerentry_repeatedbegindate = ConfigDateTime( default=self.timer.repeatedbegindate, formatstring=config.usage.date.full.value, increment=86400) self.timerentry_weekday = ConfigSelection( default=weekday_table[weekday], choices=[("mon", _("Monday")), ("tue", _("Tuesday")), ("wed", _("Wednesday")), ("thu", _("Thursday")), ("fri", _("Friday")), ("sat", _("Saturday")), ("sun", _("Sunday"))]) self.timerentry_day = ConfigSubList() for x in (0, 1, 2, 3, 4, 5, 6): self.timerentry_day.append(ConfigYesNo(default=day[x])) # FIXME some service-chooser needed here servicename = "N/A" try: # no current service available? servicename = str(self.timer.service_ref.getServiceName()) except: pass self.timerentry_service_ref = self.timer.service_ref self.timerentry_service = ConfigSelection([servicename]) self.createSetup("config")
class TimerEntry(Screen, ConfigListScreen): def __init__(self, session, timer): Screen.__init__(self, session) self.timer = timer self.entryDate = None self.entryService = None self["oktext"] = Label(_("OK")) self["canceltext"] = Label(_("Cancel")) self["ok"] = Pixmap() self["cancel"] = Pixmap() self.createConfig() self["actions"] = NumberActionMap(["SetupActions", "GlobalActions", "PiPSetupActions"], { "ok": self.keySelect, "save": self.keyGo, "cancel": self.keyCancel, "volumeUp": self.incrementStart, "volumeDown": self.decrementStart, "size+": self.incrementEnd, "size-": self.decrementEnd }, -2) self.list = [] ConfigListScreen.__init__(self, self.list, session = session) self.createSetup("config") def createConfig(self): justplay = self.timer.justplay afterevent = { AFTEREVENT.NONE: "nothing", AFTEREVENT.DEEPSTANDBY: "deepstandby", AFTEREVENT.STANDBY: "standby", AFTEREVENT.AUTO: "auto" }[self.timer.afterEvent] weekday_table = ("mon", "tue", "wed", "thu", "fri", "sat", "sun") # calculate default values day = [] weekday = 0 for x in (0, 1, 2, 3, 4, 5, 6): day.append(0) if self.timer.repeated: # repeated type = "repeated" if (self.timer.repeated == 31): # Mon-Fri repeated = "weekdays" elif (self.timer.repeated == 127): # daily repeated = "daily" else: flags = self.timer.repeated repeated = "user" count = 0 for x in (0, 1, 2, 3, 4, 5, 6): if flags == 1: # weekly print "Set to weekday " + str(x) weekday = x if flags & 1 == 1: # set user defined flags day[x] = 1 count += 1 else: day[x] = 0 flags = flags >> 1 if count == 1: repeated = "weekly" else: # once type = "once" repeated = None weekday = (int(strftime("%w", localtime(self.timer.begin))) - 1) % 7 day[weekday] = 1 if not config.misc.recording_allowed.value: self.timerentry_justplay = ConfigSelection(choices = [("zap", _("zap"))], default = "zap") else: tmp_dir = self.timer.dirname or defaultMoviePath() if not harddiskmanager.inside_mountpoint(tmp_dir): justplay = 1 justplay_default = {0: "record", 1: "zap"}[justplay] self.timerentry_justplay = ConfigSelection(choices = [("zap", _("zap")), ("record", _("record"))], default = justplay_default) if SystemInfo["DeepstandbySupport"]: shutdownString = _("go to standby") else: shutdownString = _("shut down") self.timerentry_afterevent = ConfigSelection(choices = [("nothing", _("do nothing")), ("standby", _("go to idle mode")), ("deepstandby", shutdownString), ("auto", _("auto"))], default = afterevent) self.timerentry_type = ConfigSelection(choices = [("once",_("once")), ("repeated", _("repeated"))], default = type) self.timerentry_name = ConfigText(default = self.timer.name, visible_width = 50, fixed_size = False) self.timerentry_description = ConfigText(default = self.timer.description, visible_width = 50, fixed_size = False) self.timerentry_tags = self.timer.tags[:] self.timerentry_tagsset = ConfigSelection(choices = [not self.timerentry_tags and "None" or " ".join(self.timerentry_tags)]) self.timerentry_repeated = ConfigSelection(default = repeated, choices = [("daily", _("daily")), ("weekly", _("weekly")), ("weekdays", _("Mon-Fri")), ("user", _("user defined"))]) self.timerentry_date = ConfigDateTime(default = self.timer.begin, formatstring = _("%d.%B %Y"), increment = 86400) self.timerentry_starttime = ConfigClock(default = self.timer.begin) self.timerentry_endtime = ConfigClock(default = self.timer.end) self.timerentry_showendtime = ConfigSelection(default = ((self.timer.end - self.timer.begin) > 4), choices = [(True, _("yes")), (False, _("no"))]) default = self.timer.dirname or defaultMoviePath() tmp = config.movielist.videodirs.value if default not in tmp: tmp.append(default) self.timerentry_dirname = ConfigSelection(default = default, choices = tmp) self.timerentry_repeatedbegindate = ConfigDateTime(default = self.timer.repeatedbegindate, formatstring = _("%d.%B %Y"), increment = 86400) self.timerentry_weekday = ConfigSelection(default = weekday_table[weekday], choices = [("mon",_("Monday")), ("tue", _("Tuesday")), ("wed",_("Wednesday")), ("thu", _("Thursday")), ("fri", _("Friday")), ("sat", _("Saturday")), ("sun", _("Sunday"))]) self.timerentry_day = ConfigSubList() for x in (0, 1, 2, 3, 4, 5, 6): self.timerentry_day.append(ConfigYesNo(default = day[x])) try: # no current service available? servicename = str(self.timer.service_ref.getServiceName()) except: pass servicename = servicename or "N/A" self.timerentry_service_ref = self.timer.service_ref self.timerentry_service = ConfigSelection([servicename]) self.timerentry_plugins = {} if config.usage.setup_level.index >= 2: from Plugins.Plugin import PluginDescriptor from Components.PluginComponent import plugins missing = self.timer.plugins.keys() for p in plugins.getPlugins(PluginDescriptor.WHERE_TIMEREDIT): if p.__call__.has_key("setupFnc"): setupFnc = p.__call__["setupFnc"] if setupFnc is not None: if p.__call__.has_key("configListEntry"): entry = p.__call__["configListEntry"]() pdata = None if p.name in self.timer.plugins: pval = self.timer.plugins[p.name][0] pdata = self.timer.plugins[p.name][1] try: if isinstance(entry[1].value, bool): entry[1].value = (pval == "True") elif isinstance(entry[1].value, str): entry[1].value = str(pval) elif isinstance(entry[1].value, int): entry[1].value = int(pval) except ValueError: print "could not get config_val", pval, type(pval), "for WHERE_TIMEREDIT plugin:", p.name break self.timerentry_plugins[entry] = [p.name, setupFnc, pdata] # [plugin name, function call for plugin setup, plugin private data] if p.name in missing: missing.remove(p.name) if len(missing): print "could not setup WHERE_TIMEREDIT plugin(s):", missing def createSetup(self, widget): 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.list.append(self.timerJustplayEntry) self.timerTypeEntry = getConfigListEntry(_("Repeat Type"), self.timerentry_type) self.list.append(self.timerTypeEntry) if self.timerentry_type.value == "once": self.frequencyEntry = None else: # repeated self.frequencyEntry = getConfigListEntry(_("Repeats"), self.timerentry_repeated) self.list.append(self.frequencyEntry) self.repeatedbegindateEntry = getConfigListEntry(_("Starting on"), self.timerentry_repeatedbegindate) self.list.append(self.repeatedbegindateEntry) if self.timerentry_repeated.value == "daily": pass if self.timerentry_repeated.value == "weekdays": pass if self.timerentry_repeated.value == "weekly": self.list.append(getConfigListEntry(_("Weekday"), self.timerentry_weekday)) if self.timerentry_repeated.value == "user": self.list.append(getConfigListEntry(_("Monday"), self.timerentry_day[0])) self.list.append(getConfigListEntry(_("Tuesday"), self.timerentry_day[1])) self.list.append(getConfigListEntry(_("Wednesday"), self.timerentry_day[2])) self.list.append(getConfigListEntry(_("Thursday"), self.timerentry_day[3])) self.list.append(getConfigListEntry(_("Friday"), self.timerentry_day[4])) self.list.append(getConfigListEntry(_("Saturday"), self.timerentry_day[5])) self.list.append(getConfigListEntry(_("Sunday"), self.timerentry_day[6])) self.entryDate = getConfigListEntry(_("Date"), self.timerentry_date) if self.timerentry_type.value == "once": self.list.append(self.entryDate) self.entryStartTime = getConfigListEntry(_("StartTime"), self.timerentry_starttime) self.list.append(self.entryStartTime) self.entryShowEndTime = getConfigListEntry(_("Set End Time"), self.timerentry_showendtime) if self.timerentry_justplay.value == "zap": self.list.append(self.entryShowEndTime) self.entryEndTime = getConfigListEntry(_("EndTime"), self.timerentry_endtime) if self.timerentry_justplay.value != "zap" or self.timerentry_showendtime.value: self.list.append(self.entryEndTime) self.channelEntry = getConfigListEntry(_("Channel"), self.timerentry_service) self.list.append(self.channelEntry) self.dirname = getConfigListEntry(_("Location"), self.timerentry_dirname) self.tagsSet = getConfigListEntry(_("Tags"), self.timerentry_tagsset) if self.timerentry_justplay.value != "zap": if config.usage.setup_level.index >= 2: # expert+ self.list.append(self.dirname) if getPreferredTagEditor(): self.list.append(self.tagsSet) self.list.append(getConfigListEntry(_("After event"), self.timerentry_afterevent)) for entry in self.timerentry_plugins.keys(): self.list.append(entry) self[widget].list = self.list self[widget].l.setList(self.list) def newConfig(self): print "newConfig", self["config"].getCurrent() if self["config"].getCurrent() in (self.timerTypeEntry, self.timerJustplayEntry, self.frequencyEntry, self.entryShowEndTime): self.createSetup("config") def keyLeft(self): if self["config"].getCurrent() in (self.channelEntry, self.tagsSet): self.keySelect() else: ConfigListScreen.keyLeft(self) self.newConfig() def keyRight(self): if self["config"].getCurrent() in (self.channelEntry, self.tagsSet): self.keySelect() else: ConfigListScreen.keyRight(self) self.newConfig() def keySelect(self): cur = self["config"].getCurrent() if cur == self.channelEntry: self.session.openWithCallback( self.finishedChannelSelection, ChannelSelection.SimpleChannelSelection, _("Select channel to record from") ) elif config.usage.setup_level.index >= 2 and cur == self.dirname: self.session.openWithCallback( self.pathSelected, MovieLocationBox, _("Choose target folder"), self.timerentry_dirname.value, minFree = 100 # We require at least 100MB free space ) elif getPreferredTagEditor() and cur == self.tagsSet: self.session.openWithCallback( self.tagEditFinished, getPreferredTagEditor(), self.timerentry_tags ) elif config.usage.setup_level.index >= 2 and cur in self.timerentry_plugins.keys(): self.getConfigListValues() setupFnc = self.timerentry_plugins[cur][1] configentry = cur[1] private_data = self.timerentry_plugins[cur][2] print "calling setupFnc of WHERE_TIMEREDIT plugin:", cur[0], setupFnc, configentry, private_data, self.timer.name self.session.openWithCallback(boundFunction(self.pluginFinished, cur), setupFnc , configentry, private_data, self.timer) else: self.keyGo() def pluginFinished(self, entry, ret=""): print "[pluginFinished]", entry, ret self.timerentry_plugins[entry][2] = ret self["config"].invalidate(entry) print "plugin private data", self.timerentry_plugins[entry][2] def finishedChannelSelection(self, *args): if args: self.timerentry_service_ref = ServiceReference(args[0]) self.timerentry_service.setCurrentText(self.timerentry_service_ref.getServiceName()) self["config"].invalidate(self.channelEntry) def getTimestamp(self, date, mytime): d = localtime(date) dt = datetime(d.tm_year, d.tm_mon, d.tm_mday, mytime[0], mytime[1]) return int(mktime(dt.timetuple())) def getBeginEnd(self): date = self.timerentry_date.value endtime = self.timerentry_endtime.value starttime = self.timerentry_starttime.value begin = self.getTimestamp(date, starttime) end = self.getTimestamp(date, endtime) # if the endtime is less than the starttime, add 1 day. if end < begin: end += 86400 return begin, end def selectChannelSelector(self, *args): self.session.openWithCallback( self.finishedChannelSelectionCorrection, ChannelSelection.SimpleChannelSelection, _("Select channel to record from") ) def finishedChannelSelectionCorrection(self, *args): if args: self.finishedChannelSelection(*args) self.keyGo() def getConfigListValues(self): if not self.timerentry_service_ref.isRecordable(): self.session.openWithCallback(self.selectChannelSelector, MessageBox, _("You didn't select a channel to record from."), MessageBox.TYPE_ERROR) return if self.timerentry_justplay.value == 'record': if not harddiskmanager.inside_mountpoint(self.timerentry_dirname.value): if harddiskmanager.HDDCount() and not harddiskmanager.HDDEnabledCount(): self.session.open(MessageBox, _("Unconfigured storage devices found!") + "\n" \ + _("Please make sure to set up your storage devices with the improved storage management in menu -> setup -> system -> storage devices."), MessageBox.TYPE_ERROR) return elif harddiskmanager.HDDEnabledCount() and defaultStorageDevice() == "<undefined>": self.session.open(MessageBox, _("No default storage device found!") + "\n" \ + _("Please make sure to set up your default storage device in menu -> setup -> system -> recording paths."), MessageBox.TYPE_ERROR) return elif harddiskmanager.HDDEnabledCount() and defaultStorageDevice() != "<undefined>": part = harddiskmanager.getDefaultStorageDevicebyUUID(defaultStorageDevice()) if part is None: self.session.open(MessageBox, _("Default storage device is not available!") + "\n" \ + _("Please verify if your default storage device is attached or set up your default storage device in menu -> setup -> system -> recording paths."), MessageBox.TYPE_ERROR) return else: self.session.open(MessageBox, _("Recording destination for this timer does not exists."), MessageBox.TYPE_ERROR) return self.timer.name = self.timerentry_name.value self.timer.description = self.timerentry_description.value self.timer.justplay = self.timerentry_justplay.value == "zap" if self.timerentry_justplay.value == "zap": if not self.timerentry_showendtime.value: self.timerentry_endtime.value = self.timerentry_starttime.value self.timer.resetRepeated() self.timer.afterEvent = { "nothing": AFTEREVENT.NONE, "deepstandby": AFTEREVENT.DEEPSTANDBY, "standby": AFTEREVENT.STANDBY, "auto": AFTEREVENT.AUTO }[self.timerentry_afterevent.value] self.timer.service_ref = self.timerentry_service_ref self.timer.tags = self.timerentry_tags if self.timer.dirname or self.timerentry_dirname.value != defaultMoviePath(): self.timer.dirname = self.timerentry_dirname.value config.movielist.last_timer_videodir.value = self.timer.dirname config.movielist.last_timer_videodir.save() if self.timerentry_type.value == "once": self.timer.begin, self.timer.end = self.getBeginEnd() if self.timerentry_type.value == "repeated": if self.timerentry_repeated.value == "daily": for x in (0, 1, 2, 3, 4, 5, 6): self.timer.setRepeated(x) if self.timerentry_repeated.value == "weekly": self.timer.setRepeated(self.timerentry_weekday.index) if self.timerentry_repeated.value == "weekdays": for x in (0, 1, 2, 3, 4): self.timer.setRepeated(x) if self.timerentry_repeated.value == "user": for x in (0, 1, 2, 3, 4, 5, 6): if self.timerentry_day[x].value: self.timer.setRepeated(x) self.timer.repeatedbegindate = self.getTimestamp(self.timerentry_repeatedbegindate.value, self.timerentry_starttime.value) if self.timer.repeated: self.timer.begin = self.getTimestamp(self.timerentry_repeatedbegindate.value, self.timerentry_starttime.value) self.timer.end = self.getTimestamp(self.timerentry_repeatedbegindate.value, self.timerentry_endtime.value) else: self.timer.begin = self.getTimestamp(time.time(), self.timerentry_starttime.value) self.timer.end = self.getTimestamp(time.time(), self.timerentry_endtime.value) # when a timer end is set before the start, add 1 day if self.timer.end < self.timer.begin: self.timer.end += 86400 def keyGo(self, result = None): self.getConfigListValues() if self.timer.eit is not None: event = eEPGCache.getInstance().lookupEventId(self.timer.service_ref.ref, self.timer.eit) if event: n = event.getNumOfLinkageServices() if n > 1: tlist = [] ref = self.session.nav.getCurrentlyPlayingServiceReference() parent = self.timer.service_ref.ref selection = 0 for x in range(n): i = event.getLinkageService(parent, x) if i.toString() == ref.toString(): selection = x tlist.append((i.getName(), i)) self.session.openWithCallback(self.subserviceSelected, ChoiceBox, title=_("Please select a subservice to record..."), list = tlist, selection = selection) return elif n > 0: parent = self.timer.service_ref.ref self.timer.service_ref = ServiceReference(event.getLinkageService(parent, 0)) if self.timerentry_plugins: self.timer.plugins = {} for key, val in self.timerentry_plugins.iteritems(): self.timer.plugins[val[0]] = (str(key[1].value),str(val[2])) print "timerentry self.timer.plugins", self.timer.plugins self.saveTimer() self.close((True, self.timer)) def incrementStart(self): self.timerentry_starttime.increment() self["config"].invalidate(self.entryStartTime) def decrementStart(self): self.timerentry_starttime.decrement() self["config"].invalidate(self.entryStartTime) def incrementEnd(self): if self.entryEndTime is not None: self.timerentry_endtime.increment() self["config"].invalidate(self.entryEndTime) def decrementEnd(self): if self.entryEndTime is not None: self.timerentry_endtime.decrement() self["config"].invalidate(self.entryEndTime) def subserviceSelected(self, service): if not service is None: self.timer.service_ref = ServiceReference(service[1]) self.saveTimer() self.close((True, self.timer)) def saveTimer(self): self.session.nav.RecordTimer.saveTimer() def keyCancel(self): self.close((False,)) def pathSelected(self, res): if res is not None: if config.movielist.videodirs.value != self.timerentry_dirname.choices: self.timerentry_dirname.setChoices(config.movielist.videodirs.value, default=res) self.timerentry_dirname.value = res def tagEditFinished(self, ret): if ret is not None: self.timerentry_tags = ret self.timerentry_tagsset.setChoices([not ret and "None" or " ".join(ret)]) self["config"].invalidate(self.tagsSet)
def createSetup(self, timer): # Name self.name = NoSave(ExtendedConfigText(default = timer.name, fixed_size = False)) # Match self.match = NoSave(ExtendedConfigText(default = timer.match, fixed_size = False)) # Encoding default = timer.encoding selection = ['UTF-8', 'ISO8859-15'] if default not in selection: selection.append(default) self.encoding = NoSave(ConfigSelection(choices = selection, default = default)) # ... self.searchType = NoSave(ConfigSelection(choices = [("partial", _("partial match")), ("exact", _("exact match"))], default = timer.searchType)) self.searchCase = NoSave(ConfigSelection(choices = [("sensitive", _("case-sensitive search")), ("insensitive", _("case-insensitive search"))], default = timer.searchCase)) # Alternatives override self.overrideAlternatives = NoSave(ConfigYesNo(default = timer.overrideAlternatives)) # Justplay self.justplay = NoSave(ConfigSelection(choices = [("zap", _("zap")), ("record", _("record"))], default = {0: "record", 1: "zap"}[int(timer.justplay)])) # Timespan now = [x for x in localtime()] if timer.hasTimespan(): default = True now[3] = timer.timespan[0][0] now[4] = timer.timespan[0][1] begin = mktime(now) now[3] = timer.timespan[1][0] now[4] = timer.timespan[1][1] end = mktime(now) else: default = False now[3] = 20 now[4] = 15 begin = mktime(now) now[3] = 23 now[4] = 15 end = mktime(now) self.timespan = NoSave(ConfigEnableDisable(default = default)) self.timespanbegin = NoSave(ConfigClock(default = begin)) self.timespanend = NoSave(ConfigClock(default = end)) # Timeframe if timer.hasTimeframe(): default = True begin = timer.getTimeframeBegin() end = timer.getTimeframeEnd() else: default = False now = [x for x in localtime()] now[3] = 0 now[4] = 0 begin = mktime(now) end = begin + 604800 # today + 7d self.timeframe = NoSave(ConfigEnableDisable(default = default)) self.timeframebegin = NoSave(ConfigDateTime(begin, _("%d.%B %Y"), increment = 86400)) self.timeframeend = NoSave(ConfigDateTime(end, _("%d.%B %Y"), increment = 86400)) # Services have their own Screen # Offset if timer.hasOffset(): default = True begin = timer.getOffsetBegin() end = timer.getOffsetEnd() else: default = False begin = 5 end = 5 self.offset = NoSave(ConfigEnableDisable(default = default)) self.offsetbegin = NoSave(ConfigNumber(default = begin)) self.offsetend = NoSave(ConfigNumber(default = end)) # AfterEvent if timer.hasAfterEvent(): default = { None: "default", AFTEREVENT.NONE: "nothing", AFTEREVENT.DEEPSTANDBY: "deepstandby", AFTEREVENT.STANDBY: "standby", AFTEREVENT.AUTO: "auto" }[timer.afterevent[0][0]] else: default = "default" self.afterevent = NoSave(ConfigSelection(choices = [ ("default", _("standard")), ("nothing", _("do nothing")), ("standby", _("go to standby")), ("deepstandby", _("go to deep standby")), ("auto", _("auto"))], default = default)) # AfterEvent (Timespan) if timer.hasAfterEvent() and timer.afterevent[0][1][0] is not None: default = True now[3] = timer.afterevent[0][1][0][0] now[4] = timer.afterevent[0][1][0][1] begin = mktime(now) now[3] = timer.afterevent[0][1][1][0] now[4] = timer.afterevent[0][1][1][1] end = mktime(now) else: default = False now[3] = 23 now[4] = 15 begin = mktime(now) now[3] = 7 now[4] = 0 end = mktime(now) self.afterevent_timespan = NoSave(ConfigEnableDisable(default = default)) self.afterevent_timespanbegin = NoSave(ConfigClock(default = begin)) self.afterevent_timespanend = NoSave(ConfigClock(default = end)) # Enabled self.enabled = NoSave(ConfigYesNo(default = timer.enabled)) # Maxduration if timer.hasDuration(): default = True duration = timer.getDuration() else: default = False duration =70 self.duration = NoSave(ConfigEnableDisable(default = default)) self.durationlength = NoSave(ConfigNumber(default = duration)) # Counter if timer.hasCounter(): default = timer.matchCount else: default = 0 self.counter = NoSave(ConfigNumber(default = default)) self.counterLeft = NoSave(ConfigNumber(default = timer.matchLeft)) default = timer.getCounterFormatString() selection = [("", _("Never")), ("%m", _("Monthly")), ("%U", _("Weekly (Sunday)")), ("%W", _("Weekly (Monday)"))] if default not in ('', '%m', '%U', '%W'): selection.append((default, _("Custom (%s)") % (default))) self.counterFormatString = NoSave(ConfigSelection(selection, default = default)) # Avoid Duplicate Description self.avoidDuplicateDescription = NoSave(ConfigSelection([ ("0", _("No")), ("1", _("On same service")), ("2", _("On any service")), ("3", _("Any service/recording")), ], default = str(timer.getAvoidDuplicateDescription()) )) # Custom Location if timer.hasDestination(): default = True else: default = False self.useDestination = NoSave(ConfigYesNo(default = default)) default = timer.destination or Directories.resolveFilename(Directories.SCOPE_HDD) choices = config.movielist.videodirs.value if default not in choices: choices.append(default) self.destination = NoSave(ConfigSelection(default = default, choices = choices)) # Tags self.timerentry_tags = timer.tags self.tags = NoSave(ConfigSelection(choices = [len(self.timerentry_tags) == 0 and _("None") or ' '.join(self.timerentry_tags)])) # Vps self.vps_enabled = NoSave(ConfigYesNo(default = timer.vps_enabled)) self.vps_overwrite = NoSave(ConfigYesNo(default = timer.vps_overwrite))
class TimerEntry(Screen, ConfigListScreen): def __init__(self, session, timer): Screen.__init__(self, session) self.setup_title = _("Timer entry") self.timer = timer self.entryDate = None self.entryService = None self["HelpWindow"] = Pixmap() self["HelpWindow"].hide() self["description"] = Label("") self["oktext"] = Label(_("OK")) self["canceltext"] = Label(_("Cancel")) self["ok"] = Pixmap() self["cancel"] = Pixmap() self["key_yellow"] = Label(_("Timer type")) self.createConfig() self["actions"] = NumberActionMap(["SetupActions", "GlobalActions", "PiPSetupActions", "ColorActions"], { "ok": self.keySelect, "save": self.keyGo, "cancel": self.keyCancel, "volumeUp": self.incrementStart, "volumeDown": self.decrementStart, "size+": self.incrementEnd, "size-": self.decrementEnd, "yellow": self.changeTimerType }, -2) self.onChangedEntry = [ ] self.list = [] ConfigListScreen.__init__(self, self.list, session = session) self.createSetup("config") self.onLayoutFinish.append(self.layoutFinished) if not self.selectionChanged in self["config"].onSelectionChanged: self["config"].onSelectionChanged.append(self.selectionChanged) self.selectionChanged() def createConfig(self): justplay = self.timer.justplay always_zap = self.timer.always_zap afterevent = { AFTEREVENT.NONE: "nothing", AFTEREVENT.DEEPSTANDBY: "deepstandby", AFTEREVENT.STANDBY: "standby", AFTEREVENT.AUTO: "auto" }[self.timer.afterEvent] if self.timer.record_ecm and self.timer.descramble: recordingtype = "descrambled+ecm" elif self.timer.record_ecm: recordingtype = "scrambled+ecm" elif self.timer.descramble: recordingtype = "normal" weekday_table = ("mon", "tue", "wed", "thu", "fri", "sat", "sun") # calculate default values day = [] weekday = 0 for x in (0, 1, 2, 3, 4, 5, 6): day.append(0) if self.timer.repeated: # repeated type = "repeated" if self.timer.repeated == 31: # Mon-Fri repeated = "weekdays" elif self.timer.repeated == 127: # daily repeated = "daily" else: flags = self.timer.repeated repeated = "user" count = 0 for x in (0, 1, 2, 3, 4, 5, 6): if flags == 1: # weekly # print "Set to weekday " + str(x) weekday = x if flags & 1 == 1: # set user defined flags day[x] = 1 count += 1 else: day[x] = 0 flags >>= 1 if count == 1: repeated = "weekly" else: # once type = "once" repeated = None weekday = int(strftime("%u", localtime(self.timer.begin))) - 1 day[weekday] = 1 self.timerentry_justplay = ConfigSelection(choices = [ ("zap", _("zap")), ("record", _("record")), ("zap+record", _("zap and record"))], default = {0: "record", 1: "zap", 2: "zap+record"}[justplay + 2*always_zap]) if SystemInfo["DeepstandbySupport"]: shutdownString = _("go to deep standby") else: shutdownString = _("shut down") self.timerentry_afterevent = ConfigSelection(choices = [("nothing", _("do nothing")), ("standby", _("go to standby")), ("deepstandby", shutdownString), ("auto", _("auto"))], default = afterevent) self.timerentry_recordingtype = ConfigSelection(choices = [("normal", _("normal")), ("descrambled+ecm", _("descramble and record ecm")), ("scrambled+ecm", _("don't descramble, record ecm"))], default = recordingtype) self.timerentry_type = ConfigSelection(choices = [("once",_("once")), ("repeated", _("repeated"))], default = type) self.timerentry_name = ConfigText(default = self.timer.name.replace('\xc2\x86', '').replace('\xc2\x87', '').encode("utf-8"), visible_width = 50, fixed_size = False) self.timerentry_description = ConfigText(default = self.timer.description, visible_width = 50, fixed_size = False) self.timerentry_tags = self.timer.tags[:] self.timerentry_tagsset = ConfigSelection(choices = [not self.timerentry_tags and "None" or " ".join(self.timerentry_tags)]) self.timerentry_repeated = ConfigSelection(default = repeated, choices = [("weekly", _("weekly")), ("daily", _("daily")), ("weekdays", _("Mon-Fri")), ("user", _("user defined"))]) self.timerentry_date = ConfigDateTime(default = self.timer.begin, formatstring = _("%d.%B %Y"), increment = 86400) self.timerentry_starttime = ConfigClock(default = self.timer.begin) self.timerentry_endtime = ConfigClock(default = self.timer.end) self.timerentry_showendtime = ConfigSelection(default = ((self.timer.end - self.timer.begin) > 4), choices = [(True, _("yes")), (False, _("no"))]) default = self.timer.dirname or defaultMoviePath() tmp = config.movielist.videodirs.getValue() if default not in tmp: tmp.append(default) self.timerentry_dirname = ConfigSelection(default = default, choices = tmp) self.timerentry_repeatedbegindate = ConfigDateTime(default = self.timer.repeatedbegindate, formatstring = _("%d.%B %Y"), increment = 86400) self.timerentry_weekday = ConfigSelection(default = weekday_table[weekday], choices = [("mon",_("Monday")), ("tue", _("Tuesday")), ("wed",_("Wednesday")), ("thu", _("Thursday")), ("fri", _("Friday")), ("sat", _("Saturday")), ("sun", _("Sunday"))]) self.timerentry_day = ConfigSubList() for x in (0, 1, 2, 3, 4, 5, 6): self.timerentry_day.append(ConfigYesNo(default = day[x])) # FIXME some service-chooser needed here servicename = "N/A" try: # no current service available? servicename = str(self.timer.service_ref.getServiceName()) except: pass self.timerentry_service_ref = self.timer.service_ref self.timerentry_service = ConfigSelection([servicename]) def createSetup(self, widget): self.list = [] self.list.append(getConfigListEntry(_("Name"), self.timerentry_name, _("Set the name the recording will get."))) self.list.append(getConfigListEntry(_("Description"), self.timerentry_description, _("Set the description of the recording."))) self.timerJustplayEntry = getConfigListEntry(_("Timer type"), self.timerentry_justplay, _("Chose between record and ZAP.")) self.list.append(self.timerJustplayEntry) self.timerTypeEntry = getConfigListEntry(_("Repeat type"), self.timerentry_type, _("A repeating timer or just once?")) self.list.append(self.timerTypeEntry) if self.timerentry_type.getValue() == "once": self.frequencyEntry = None else: # repeated self.frequencyEntry = getConfigListEntry(_("Repeats"), self.timerentry_repeated, _("Choose between Daily, Weekly, Weekdays or user defined.")) self.list.append(self.frequencyEntry) self.repeatedbegindateEntry = getConfigListEntry(_("Starting on"), self.timerentry_repeatedbegindate, _("Set the date the timer must start.")) self.list.append(self.repeatedbegindateEntry) if self.timerentry_repeated.getValue() == "daily": pass if self.timerentry_repeated.getValue() == "weekdays": pass if self.timerentry_repeated.getValue() == "weekly": self.list.append(getConfigListEntry(_("Weekday"), self.timerentry_weekday)) if self.timerentry_repeated.getValue() == "user": self.list.append(getConfigListEntry(_("Monday"), self.timerentry_day[0])) self.list.append(getConfigListEntry(_("Tuesday"), self.timerentry_day[1])) self.list.append(getConfigListEntry(_("Wednesday"), self.timerentry_day[2])) self.list.append(getConfigListEntry(_("Thursday"), self.timerentry_day[3])) self.list.append(getConfigListEntry(_("Friday"), self.timerentry_day[4])) self.list.append(getConfigListEntry(_("Saturday"), self.timerentry_day[5])) self.list.append(getConfigListEntry(_("Sunday"), self.timerentry_day[6])) self.entryDate = getConfigListEntry(_("Date"), self.timerentry_date, _("Set the date the timer must start.")) if self.timerentry_type.getValue() == "once": self.list.append(self.entryDate) self.entryStartTime = getConfigListEntry(_("Start time"), self.timerentry_starttime, _("Set the time the timer must start.")) self.list.append(self.entryStartTime) self.entryShowEndTime = getConfigListEntry(_("Set end time"), self.timerentry_showendtime, _("Set the time the timer must stop.")) if self.timerentry_justplay.getValue() == "zap": self.list.append(self.entryShowEndTime) self.entryEndTime = getConfigListEntry(_("End time"), self.timerentry_endtime, _("Set the time the timer must stop.")) if self.timerentry_justplay.getValue() != "zap" or self.timerentry_showendtime.getValue(): self.list.append(self.entryEndTime) self.channelEntry = getConfigListEntry(_("Channel"), self.timerentry_service, _("Set the channel for this timer.")) self.list.append(self.channelEntry) self.dirname = getConfigListEntry(_("Location"), self.timerentry_dirname, _("Where should the recording be saved?")) self.tagsSet = getConfigListEntry(_("Tags"), self.timerentry_tagsset, _("Choose a tag for easy finding a recording.")) if self.timerentry_justplay.getValue() != "zap": if config.usage.setup_level.index >= 2: # expert+ self.list.append(self.dirname) if getPreferredTagEditor(): self.list.append(self.tagsSet) self.list.append(getConfigListEntry(_("After event"), self.timerentry_afterevent, _("What action is required on complettion of the timer? 'Auto' lets the box return to the state it had when the timer started. 'Do nothing', 'Go to standby' and 'Go to deep standby' do ecaxtly that."))) self.list.append(getConfigListEntry(_("Recording type"), self.timerentry_recordingtype, _("Descramble & record ECM' gives the option to descramble afterwards if descrambling on recording failed. 'Don't descramble, record ECM' save a scramble recording that can be descrambled on playback. 'Normal' means descramble the recording and don't record ECM."))) self[widget].list = self.list self[widget].l.setList(self.list) def selectionChanged(self): if self["config"].getCurrent() and len(self["config"].getCurrent()) > 2 and self["config"].getCurrent()[2]: self["description"].setText(self["config"].getCurrent()[2]) def layoutFinished(self): self.setTitle(_(self.setup_title)) def createSummary(self): return SetupSummary # for summary: def changedEntry(self): for x in self.onChangedEntry: x() def getCurrentEntry(self): return self["config"].getCurrent() and self["config"].getCurrent()[0] or "" def getCurrentValue(self): return self["config"].getCurrent() and str(self["config"].getCurrent()[1].getText()) or "" def newConfig(self): if self["config"].getCurrent() in (self.timerTypeEntry, self.timerJustplayEntry, self.frequencyEntry, self.entryShowEndTime): self.createSetup("config") def keyLeft(self): if self["config"].getCurrent() in (self.channelEntry, self.tagsSet): self.keySelect() else: ConfigListScreen.keyLeft(self) self.newConfig() def keyRight(self): if self["config"].getCurrent() in (self.channelEntry, self.tagsSet): self.keySelect() else: ConfigListScreen.keyRight(self) self.newConfig() def keySelect(self): cur = self["config"].getCurrent() if cur == self.channelEntry: self.session.openWithCallback( self.finishedChannelSelection, ChannelSelection.SimpleChannelSelection, _("Select channel to record from") ) elif config.usage.setup_level.index >= 2 and cur == self.dirname: self.session.openWithCallback( self.pathSelected, MovieLocationBox, _("Select target folder"), self.timerentry_dirname.getValue(), minFree = 100 # We require at least 100MB free space ) elif getPreferredTagEditor() and cur == self.tagsSet: self.session.openWithCallback( self.tagEditFinished, getPreferredTagEditor(), self.timerentry_tags ) else: self.keyGo() def finishedChannelSelection(self, *args): if args: self.timerentry_service_ref = ServiceReference(args[0]) self.timerentry_service.setCurrentText(self.timerentry_service_ref.getServiceName()) self["config"].invalidate(self.channelEntry) def getTimestamp(self, date, mytime): d = localtime(date) dt = datetime(d.tm_year, d.tm_mon, d.tm_mday, mytime[0], mytime[1]) return int(mktime(dt.timetuple())) def getBeginEnd(self): date = self.timerentry_date.getValue() endtime = self.timerentry_endtime.getValue() starttime = self.timerentry_starttime.getValue() begin = self.getTimestamp(date, starttime) end = self.getTimestamp(date, endtime) # if the endtime is less than the starttime, add 1 day. if end < begin: end += 86400 # if the timer type is a Zap and no end is set, set duration to 1 second so time is shown in EPG's. if self.timerentry_justplay.getValue() == "zap": if not self.timerentry_showendtime.getValue(): end = begin + (config.recording.margin_before.getValue()*60) + 1 return begin, end def selectChannelSelector(self, *args): self.session.openWithCallback( self.finishedChannelSelectionCorrection, ChannelSelection.SimpleChannelSelection, _("Select channel to record from") ) def finishedChannelSelectionCorrection(self, *args): if args: self.finishedChannelSelection(*args) self.keyGo() def keyGo(self, result = None): if not self.timerentry_service_ref.isRecordable(): self.session.openWithCallback(self.selectChannelSelector, MessageBox, _("You didn't select a channel to record from."), MessageBox.TYPE_ERROR) return self.timer.name = self.timerentry_name.getValue() self.timer.description = self.timerentry_description.getValue() self.timer.justplay = self.timerentry_justplay.getValue() == "zap" self.timer.always_zap = self.timerentry_justplay.value == "zap+record" if self.timerentry_justplay.getValue() == "zap": if not self.timerentry_showendtime.getValue(): self.timerentry_endtime.value = self.timerentry_starttime.getValue() self.timer.resetRepeated() self.timer.afterEvent = { "nothing": AFTEREVENT.NONE, "deepstandby": AFTEREVENT.DEEPSTANDBY, "standby": AFTEREVENT.STANDBY, "auto": AFTEREVENT.AUTO }[self.timerentry_afterevent.value] self.timer.descramble = { "normal": True, "descrambled+ecm": True, "scrambled+ecm": False, }[self.timerentry_recordingtype.value] self.timer.record_ecm = { "normal": False, "descrambled+ecm": True, "scrambled+ecm": True, }[self.timerentry_recordingtype.value] self.timer.service_ref = self.timerentry_service_ref self.timer.tags = self.timerentry_tags if self.timer.dirname or self.timerentry_dirname.getValue() != defaultMoviePath(): self.timer.dirname = self.timerentry_dirname.getValue() config.movielist.last_timer_videodir.value = self.timer.dirname config.movielist.last_timer_videodir.save() if self.timerentry_type.getValue() == "once": self.timer.begin, self.timer.end = self.getBeginEnd() if self.timerentry_type.getValue() == "repeated": if self.timerentry_repeated.getValue() == "daily": for x in (0, 1, 2, 3, 4, 5, 6): self.timer.setRepeated(x) if self.timerentry_repeated.getValue() == "weekly": self.timer.setRepeated(self.timerentry_weekday.index) if self.timerentry_repeated.getValue() == "weekdays": for x in (0, 1, 2, 3, 4): self.timer.setRepeated(x) if self.timerentry_repeated.getValue() == "user": for x in (0, 1, 2, 3, 4, 5, 6): if self.timerentry_day[x].getValue(): self.timer.setRepeated(x) self.timer.repeatedbegindate = self.getTimestamp(self.timerentry_repeatedbegindate.getValue(), self.timerentry_starttime.getValue()) if self.timer.repeated: self.timer.begin = self.getTimestamp(self.timerentry_repeatedbegindate.getValue(), self.timerentry_starttime.getValue()) self.timer.end = self.getTimestamp(self.timerentry_repeatedbegindate.getValue(), self.timerentry_endtime.getValue()) else: self.timer.begin = self.getTimestamp(time.time(), self.timerentry_starttime.getValue()) self.timer.end = self.getTimestamp(time.time(), self.timerentry_endtime.getValue()) # when a timer end is set before the start, add 1 day if self.timer.end < self.timer.begin: self.timer.end += 86400 if self.timer.eit is not None: event = eEPGCache.getInstance().lookupEventId(self.timer.service_ref.ref, self.timer.eit) if event: n = event.getNumOfLinkageServices() if n > 1: tlist = [] ref = self.session.nav.getCurrentlyPlayingServiceOrGroup() parent = self.timer.service_ref.ref selection = 0 for x in range(n): i = event.getLinkageService(parent, x) if i.toString() == ref.toString(): selection = x tlist.append((i.getName(), i)) self.session.openWithCallback(self.subserviceSelected, ChoiceBox, title=_("Please select a subservice to record..."), list = tlist, selection = selection) return elif n > 0: parent = self.timer.service_ref.ref self.timer.service_ref = ServiceReference(event.getLinkageService(parent, 0)) self.saveTimer() self.close((True, self.timer)) def changeTimerType(self): self.timerentry_justplay.selectNext() self.timerJustplayEntry = getConfigListEntry(_("Timer type"), self.timerentry_justplay) self["config"].invalidate(self.timerJustplayEntry) def incrementStart(self): self.timerentry_starttime.increment() self["config"].invalidate(self.entryStartTime) if self.timerentry_type.value == "once" and self.timerentry_starttime.value == [0, 0]: self.timerentry_date.value += 86400 self["config"].invalidate(self.entryDate) def decrementStart(self): self.timerentry_starttime.decrement() self["config"].invalidate(self.entryStartTime) if self.timerentry_type.value == "once" and self.timerentry_starttime.value == [23, 59]: self.timerentry_date.value -= 86400 self["config"].invalidate(self.entryDate) def incrementEnd(self): if self.entryEndTime is not None: self.timerentry_endtime.increment() self["config"].invalidate(self.entryEndTime) def decrementEnd(self): if self.entryEndTime is not None: self.timerentry_endtime.decrement() self["config"].invalidate(self.entryEndTime) def subserviceSelected(self, service): if not service is None: self.timer.service_ref = ServiceReference(service[1]) self.saveTimer() self.close((True, self.timer)) def saveTimer(self): self.session.nav.RecordTimer.saveTimer() def keyCancel(self): self.close((False,)) def pathSelected(self, res): if res is not None: if config.movielist.videodirs.getValue() != self.timerentry_dirname.choices: self.timerentry_dirname.setChoices(config.movielist.videodirs.getValue(), default=res) self.timerentry_dirname.value = res def tagEditFinished(self, ret): if ret is not None: self.timerentry_tags = ret self.timerentry_tagsset.setChoices([not ret and "None" or " ".join(ret)]) self["config"].invalidate(self.tagsSet)
from .GBIpboxClient import GBIpboxClient, GBIpboxClientAutostart from .GBIpboxRemoteTimer import GBIpboxRemoteTimer from .GBIpboxWizard import GBIpboxWizard from .GBIpboxLocale import _ from boxbranding import getImageDistro config.ipboxclient = ConfigSubsection() config.ipboxclient.host = ConfigText(default="", fixed_size=False) config.ipboxclient.port = ConfigInteger(default=80, limits=(1, 65535)) config.ipboxclient.streamport = ConfigInteger(default=8001, limits=(1, 65535)) config.ipboxclient.auth = ConfigYesNo(default=False) config.ipboxclient.firstconf = ConfigYesNo(default=False) config.ipboxclient.username = ConfigText(default="", fixed_size=False) config.ipboxclient.password = ConfigText(default="", fixed_size=False) config.ipboxclient.schedule = ConfigYesNo(default=False) config.ipboxclient.scheduletime = ConfigClock(default=0) # 1:00 config.ipboxclient.repeattype = ConfigSelection(default="daily", choices=[ ("daily", _("Daily")), ("weekly", _("Weekly")), ("monthly", _("30 Days")) ]) config.ipboxclient.mounthdd = ConfigYesNo(default=False) config.ipboxclient.remotetimers = ConfigYesNo(default=False) def ipboxclientRecordTimer(): return GBIpboxRemoteTimer() def ipboxclientStart(menuid, **kwargs):
def createConfig(self): justplay = self.timer.justplay always_zap = self.timer.always_zap zap_wakeup = self.timer.zap_wakeup rename_repeat = self.timer.rename_repeat afterevent = { AFTEREVENT.NONE: "nothing", AFTEREVENT.DEEPSTANDBY: "deepstandby", AFTEREVENT.STANDBY: "standby", AFTEREVENT.AUTO: "auto" }[self.timer.afterEvent] if self.timer.record_ecm and self.timer.descramble: recordingtype = "descrambled+ecm" elif self.timer.record_ecm: recordingtype = "scrambled+ecm" elif self.timer.descramble: recordingtype = "normal" weekday_table = ("mon", "tue", "wed", "thu", "fri", "sat", "sun") # calculate default values day = [] weekday = 0 for x in (0, 1, 2, 3, 4, 5, 6): day.append(0) if self.timer.repeated: # repeated type = "repeated" if (self.timer.repeated == 31): # Mon-Fri repeated = "weekdays" elif (self.timer.repeated == 127): # daily repeated = "daily" else: flags = self.timer.repeated repeated = "user" count = 0 for x in (0, 1, 2, 3, 4, 5, 6): if flags == 1: # weekly print "Set to weekday " + str(x) weekday = x if flags & 1 == 1: # set user defined flags day[x] = 1 count += 1 else: day[x] = 0 flags = flags >> 1 if count == 1: repeated = "weekly" else: # once type = "once" repeated = None weekday = int(strftime("%u", localtime(self.timer.begin))) - 1 day[weekday] = 1 self.timerentry_justplay = ConfigSelection(choices = [ ("zap", _("zap")), ("record", _("record")), ("zap+record", _("zap and record"))], default = {0: "record", 1: "zap", 2: "zap+record"}[justplay + 2*always_zap]) if SystemInfo["DeepstandbySupport"]: shutdownString = _("go to deep standby") choicelist = [("always", _("always")), ("from_standby", _("only from standby")), ("from_deep_standby", _("only from deep standby")), ("never", _("never"))] else: shutdownString = _("shut down") choicelist = [("always", _("always")), ("never", _("never"))] self.timerentry_zapwakeup = ConfigSelection(choices = choicelist, default = zap_wakeup) self.timerentry_afterevent = ConfigSelection(choices = [("nothing", _("do nothing")), ("standby", _("go to standby")), ("deepstandby", shutdownString), ("auto", _("auto"))], default = afterevent) self.timerentry_recordingtype = ConfigSelection(choices = [("normal", _("normal")), ("descrambled+ecm", _("descramble and record ecm")), ("scrambled+ecm", _("don't descramble, record ecm"))], default = recordingtype) self.timerentry_type = ConfigSelection(choices = [("once",_("once")), ("repeated", _("repeated"))], default = type) self.timerentry_name = ConfigText(default = self.timer.name, visible_width = 50, fixed_size = False) self.timerentry_description = ConfigText(default = self.timer.description, visible_width = 50, fixed_size = False) self.timerentry_tags = self.timer.tags[:] self.timerentry_tagsset = ConfigSelection(choices = [not self.timerentry_tags and "None" or " ".join(self.timerentry_tags)]) self.timerentry_repeated = ConfigSelection(default = repeated, choices = [("weekly", _("weekly")), ("daily", _("daily")), ("weekdays", _("Mon-Fri")), ("user", _("user defined"))]) self.timerentry_renamerepeat = ConfigYesNo(default = rename_repeat) self.timerentry_date = ConfigDateTime(default = self.timer.begin, formatstring = _("%d.%B %Y"), increment = 86400) self.timerentry_starttime = ConfigClock(default = self.timer.begin) self.timerentry_endtime = ConfigClock(default = self.timer.end) self.timerentry_showendtime = ConfigSelection(default = ((self.timer.end - self.timer.begin) > 4), choices = [(True, _("yes")), (False, _("no"))]) default = self.timer.dirname or defaultMoviePath() tmp = config.movielist.videodirs.value if default not in tmp: tmp.append(default) self.timerentry_dirname = ConfigSelection(default = default, choices = tmp) self.timerentry_repeatedbegindate = ConfigDateTime(default = self.timer.repeatedbegindate, formatstring = _("%d.%B %Y"), increment = 86400) self.timerentry_weekday = ConfigSelection(default = weekday_table[weekday], choices = [("mon",_("Monday")), ("tue", _("Tuesday")), ("wed",_("Wednesday")), ("thu", _("Thursday")), ("fri", _("Friday")), ("sat", _("Saturday")), ("sun", _("Sunday"))]) self.timerentry_day = ConfigSubList() for x in (0, 1, 2, 3, 4, 5, 6): self.timerentry_day.append(ConfigYesNo(default = day[x])) # FIXME some service-chooser needed here servicename = "N/A" try: # no current service available? servicename = str(self.timer.service_ref.getServiceName()) except: pass self.timerentry_service_ref = self.timer.service_ref self.timerentry_service = ConfigSelection([servicename])
def __init__(self, session, serien_name, serien_wlid, serien_id, serien_fsid): serienRecBaseScreen.__init__(self, session) Screen.__init__(self, session) HelpableScreen.__init__(self) self.list = [] self.session = session self.serien_name = serien_name self.serien_id = serien_id self.serien_wlid = serien_wlid self.serien_fsid = serien_fsid self.database = SRDatabase(serienRecDataBaseFilePath) self.HilfeTexte = {} self.fromTime_index = 1 self.toTime_index = 1 self.margin_before_index = 1 self.margin_after_index = 1 self.NoOfRecords_index = 1 self["actions"] = HelpableActionMap(self, "SerienRecorderActions", { "red": (self.cancel, "Änderungen verwerfen und zurück zur Serien-Marker-Ansicht"), "green": (self.save, "Einstellungen speichern und zurück zur Serien-Marker-Ansicht"), "blue": (self.resetCover, "Cover zurücksetzen"), "cancel": (self.cancel, "Änderungen verwerfen und zurück zur Serien-Marker-Ansicht"), "ok": (self.ok, "Fenster für Verzeichnisauswahl öffnen"), "up": (self.keyUp, "eine Zeile nach oben"), "down": (self.keyDown, "eine Zeile nach unten"), "startTeletext": (self.showAbout, "Über dieses Plugin"), }, -1) self.helpList[0][2].sort() self["helpActions"] = ActionMap(["SerienRecorderActions", ], { "displayHelp": self.showHelp, "displayHelp_long": self.showManual, }, 0) self.setupSkin() if config.plugins.serienRec.showAllButtons.value: setMenuTexts(self) (AufnahmeVerzeichnis, Staffelverzeichnis, Vorlaufzeit, Nachlaufzeit, AnzahlWiederholungen, AufnahmezeitVon, AufnahmezeitBis, preferredChannel, useAlternativeChannel, vps, excludedWeekdays, tags, addToDatabase, updateFromEPG, skipSeriesServer, autoAdjust, epgSeriesName) = self.database.getMarkerSettings(self.serien_id) if not AufnahmeVerzeichnis: AufnahmeVerzeichnis = "" self.savetopath = ConfigText(default=AufnahmeVerzeichnis, fixed_size=False, visible_width=50) self.seasonsubdir = ConfigSelection(choices=[("-1", "Gemäß Setup (dzt. %s)" % str( config.plugins.serienRec.seasonsubdir.value).replace("True", "Ja").replace("False", "Nein")), ("0", "Nein"), ("1", "Ja")], default=str(Staffelverzeichnis)) if str(Vorlaufzeit).isdigit(): self.margin_before = ConfigInteger(Vorlaufzeit, (0, 999)) self.enable_margin_before = ConfigYesNo(default=True) else: self.margin_before = ConfigInteger(config.plugins.serienRec.margin_before.value, (0, 999)) self.enable_margin_before = ConfigYesNo(default=False) if str(Nachlaufzeit).isdigit(): self.margin_after = ConfigInteger(Nachlaufzeit, (0, 999)) self.enable_margin_after = ConfigYesNo(default=True) else: self.margin_after = ConfigInteger(config.plugins.serienRec.margin_after.value, (0, 999)) self.enable_margin_after = ConfigYesNo(default=False) if str(AnzahlWiederholungen).isdigit(): self.NoOfRecords = ConfigInteger(AnzahlWiederholungen, (1, 9)) self.enable_NoOfRecords = ConfigYesNo(default=True) else: self.NoOfRecords = ConfigInteger(config.plugins.serienRec.NoOfRecords.value, (1, 9)) self.enable_NoOfRecords = ConfigYesNo(default=False) if str(AufnahmezeitVon).isdigit(): self.fromTime = ConfigClock(default=int(AufnahmezeitVon) * 60 + time.timezone) self.enable_fromTime = ConfigYesNo(default=True) else: self.fromTime = ConfigClock(default=((config.plugins.serienRec.globalFromTime.value[0] * 60) + config.plugins.serienRec.globalFromTime.value[1]) * 60 + time.timezone) self.enable_fromTime = ConfigYesNo(default=False) if str(AufnahmezeitBis).isdigit(): self.toTime = ConfigClock(default=int(AufnahmezeitBis) * 60 + time.timezone) self.enable_toTime = ConfigYesNo(default=True) else: self.toTime = ConfigClock(default=((config.plugins.serienRec.globalToTime.value[0] * 60) + config.plugins.serienRec.globalToTime.value[1]) * 60 + time.timezone) self.enable_toTime = ConfigYesNo(default=False) if str(vps).isdigit(): self.override_vps = ConfigYesNo(default=True) self.enable_vps = ConfigYesNo(default=bool(vps & 0x1)) self.enable_vps_savemode = ConfigYesNo(default=bool(vps & 0x2)) else: self.override_vps = ConfigYesNo(default=False) self.enable_vps = ConfigYesNo(default=False) self.enable_vps_savemode = ConfigYesNo(default=False) if str(addToDatabase).isdigit(): self.addToDatabase = ConfigYesNo(default=bool(addToDatabase)) else: self.addToDatabase = ConfigYesNo(default=True) if str(updateFromEPG).isdigit(): self.updateFromEPG = ConfigYesNo(default=bool(updateFromEPG)) self.enable_updateFromEPG = ConfigYesNo(default=True) else: self.updateFromEPG = ConfigYesNo(default=config.plugins.serienRec.eventid.value) self.enable_updateFromEPG = ConfigYesNo(default=False) if str(skipSeriesServer).isdigit(): self.skipSeriesServer = ConfigYesNo(default=bool(skipSeriesServer)) self.enable_skipSeriesServer = ConfigYesNo(default=True) else: self.skipSeriesServer = ConfigYesNo(default=config.plugins.serienRec.tvplaner_skipSerienServer.value) self.enable_skipSeriesServer = ConfigYesNo(default=False) if str(autoAdjust).isdigit(): self.autoAdjust = ConfigYesNo(default=bool(autoAdjust)) self.enable_autoAdjust = ConfigYesNo(default=True) else: self.autoAdjust = ConfigYesNo(default=False) self.enable_autoAdjust = ConfigYesNo(default=False) self.preferredChannel = ConfigSelection(choices=[("1", "Standard"), ("0", "Alternativ")], default=str(preferredChannel)) self.useAlternativeChannel = ConfigSelection(choices=[("-1", "Gemäß Setup (dzt. %s)" % str( config.plugins.serienRec.useAlternativeChannel.value).replace("True", "Ja").replace("False", "Nein")), ("0", "Nein"), ("1", "Ja")], default=str(useAlternativeChannel)) # excluded weekdays # each weekday is represented by a bit in the database field # 0 = Monday to 6 = Sunday, so if all weekdays are excluded we got 1111111 = 127 if str(excludedWeekdays).isdigit(): self.enable_excludedWeekdays = ConfigYesNo(default=True) self.excludeMonday = ConfigYesNo(default=bool(excludedWeekdays & (1 << 0))) self.excludeTuesday = ConfigYesNo(default=bool(excludedWeekdays & (1 << 1))) self.excludeWednesday = ConfigYesNo(default=bool(excludedWeekdays & (1 << 2))) self.excludeThursday = ConfigYesNo(default=bool(excludedWeekdays & (1 << 3))) self.excludeFriday = ConfigYesNo(default=bool(excludedWeekdays & (1 << 4))) self.excludeSaturday = ConfigYesNo(default=bool(excludedWeekdays & (1 << 5))) self.excludeSunday = ConfigYesNo(default=bool(excludedWeekdays & (1 << 6))) else: self.enable_excludedWeekdays = ConfigYesNo(default=False) self.excludeMonday = ConfigYesNo(default=False) self.excludeTuesday = ConfigYesNo(default=False) self.excludeWednesday = ConfigYesNo(default=False) self.excludeThursday = ConfigYesNo(default=False) self.excludeFriday = ConfigYesNo(default=False) self.excludeSaturday = ConfigYesNo(default=False) self.excludeSunday = ConfigYesNo(default=False) # tags if tags is None or len(tags) == 0: self.serienmarker_tags = [] else: self.serienmarker_tags = pickle.loads(tags) self.tags = NoSave( ConfigSelection(choices=[len(self.serienmarker_tags) == 0 and "Keine" or ' '.join(self.serienmarker_tags)])) # EPG series name if epgSeriesName is None: epgSeriesName = "" self.epgSeriesName = ConfigText(default=epgSeriesName, fixed_size=False, visible_width=50) self.changedEntry() ConfigListScreen.__init__(self, self.list) self.setInfoText() self['config_information_text'].setText(self.HilfeTexte[self.savetopath]) self.onLayoutFinish.append(self.setSkinProperties)
def createConfig(self): afterevent = { AFTEREVENT.NONE: "nothing", AFTEREVENT.WAKEUP: "wakeup", AFTEREVENT.WAKEUPTOSTANDBY: "wakeuptostandby", AFTEREVENT.STANDBY: "standby", AFTEREVENT.DEEPSTANDBY: "deepstandby", }[self.timer.afterEvent] 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.timer.timerType] weekday_table = ("mon", "tue", "wed", "thu", "fri", "sat", "sun") time_table = [ (1, "1"), (3, "3"), (5, "5"), (10, "10"), (15, "15"), (30, "30"), (45, "45"), (60, "60"), (75, "75"), (90, "90"), (105, "105"), (120, "120"), (135, "135"), (150, "150"), (165, "165"), (180, "180"), (195, "195"), (210, "210"), (225, "225"), (240, "240"), (255, "255"), (270, "270"), (285, "285"), (300, "300"), ] traffic_table = [(10, "10"), (50, "50"), (100, "100"), (500, "500"), (1000, "1000")] # calculate default values day = [] weekday = 0 for x in (0, 1, 2, 3, 4, 5, 6): day.append(0) if self.timer.repeated: # repeated type = "repeated" if self.timer.repeated == 31: # Mon-Fri repeated = "weekdays" elif self.timer.repeated == 127: # daily repeated = "daily" else: flags = self.timer.repeated repeated = "user" count = 0 for x in (0, 1, 2, 3, 4, 5, 6): if flags == 1: # weekly print "Set to weekday " + str(x) weekday = x if flags & 1 == 1: # set user defined flags day[x] = 1 count += 1 else: day[x] = 0 flags >>= 1 if count == 1: repeated = "weekly" else: # once type = "once" repeated = None weekday = int(strftime("%u", localtime(self.timer.begin))) - 1 day[weekday] = 1 if SystemInfo["DeepstandbySupport"]: shutdownString = _("go to deep standby") else: shutdownString = _("shut down") self.timerentry_timertype = ConfigSelection( choices=[ ("nothing", _("do nothing")), ("wakeup", _("wakeup")), ("wakeuptostandby", _("wakeup to standby")), ("autostandby", _("auto standby")), ("autodeepstandby", _("auto deepstandby")), ("standby", _("go to standby")), ("deepstandby", shutdownString), ("reboot", _("reboot system")), ("restart", _("restart GUI")), ], default=timertype, ) self.timerentry_afterevent = ConfigSelection( choices=[ ("nothing", _("do nothing")), ("wakeup", _("wakeup")), ("wakeuptostandby", _("wakeup to standby")), ("standby", _("go to standby")), ("deepstandby", shutdownString), ("nothing", _("do nothing")), ], default=afterevent, ) self.timerentry_type = ConfigSelection(choices=[("once", _("once")), ("repeated", _("repeated"))], default=type) self.timerentry_repeated = ConfigSelection( default=repeated, choices=[ ("daily", _("daily")), ("weekly", _("weekly")), ("weekdays", _("Mon-Fri")), ("user", _("user defined")), ], ) self.timerrntry_autosleepdelay = ConfigSelection(choices=time_table, default=self.timer.autosleepdelay) self.timerentry_autosleeprepeat = ConfigSelection( choices=[("once", _("once")), ("repeated", _("repeated"))], default=self.timer.autosleeprepeat ) self.timerrntry_autosleepinstandbyonly = ConfigSelection( choices=[("yes", _("only in Standby")), ("no", _("Standard (always)")), ("noquery", _("without Query"))], default=self.timer.autosleepinstandbyonly, ) self.timerrntry_autosleepwindow = ConfigSelection( choices=[("yes", _("Yes")), ("no", _("No"))], default=self.timer.autosleepwindow ) self.timerrntry_autosleepbegin = ConfigClock(default=self.timer.autosleepbegin) self.timerrntry_autosleepend = ConfigClock(default=self.timer.autosleepend) self.timerentry_date = ConfigDateTime(default=self.timer.begin, formatstring=_("%d.%B %Y"), increment=86400) self.timerentry_starttime = ConfigClock(default=self.timer.begin) self.timerentry_endtime = ConfigClock(default=self.timer.end) self.timerentry_showendtime = ConfigSelection( default=(((self.timer.end - self.timer.begin) / 60) > 4), choices=[(True, _("yes")), (False, _("no"))] ) self.timerentry_repeatedbegindate = ConfigDateTime( default=self.timer.repeatedbegindate, formatstring=_("%d.%B %Y"), increment=86400 ) self.timerentry_weekday = ConfigSelection( default=weekday_table[weekday], choices=[ ("mon", _("Monday")), ("tue", _("Tuesday")), ("wed", _("Wednesday")), ("thu", _("Thursday")), ("fri", _("Friday")), ("sat", _("Saturday")), ("sun", _("Sunday")), ], ) self.timerentry_day = ConfigSubList() for x in (0, 1, 2, 3, 4, 5, 6): self.timerentry_day.append(ConfigYesNo(default=day[x])) self.timerrntry_showExtended = ConfigSelection( default=(self.timer.nettraffic == "yes" or self.timer.netip == "yes"), choices=[(True, _("yes")), (False, _("no"))], ) self.timerrntry_nettraffic = ConfigSelection( choices=[("yes", _("Yes")), ("no", _("No"))], default=self.timer.nettraffic ) self.timerrntry_trafficlimit = ConfigSelection(choices=traffic_table, default=self.timer.trafficlimit) self.timerrntry_netip = ConfigSelection(choices=[("yes", _("Yes")), ("no", _("No"))], default=self.timer.netip) self.timerrntry_ipadress = self.timer.ipadress.split(",") self.ipcount = ConfigSelectionNumber(default=len(self.timerrntry_ipadress), stepwidth=1, min=1, max=5) self.ipadressEntry = ConfigSubList() for x in (0, 1, 2, 3, 4, 5): try: self.ipadressEntry.append( ConfigIP(default=[int(n) for n in self.timerrntry_ipadress[x].split(".")] or [0, 0, 0, 0]) ) except: self.ipadressEntry.append(ConfigIP(default=[0, 0, 0, 0]))
from Components.ActionMap import ActionMap from Components.config import getConfigListEntry, config, ConfigSubsection, ConfigText, ConfigSelection, ConfigInteger, ConfigClock, NoSave, configfile from Components.ConfigList import ConfigListScreen from Components.Label import Label from Components.Sources.List import List from Components.Pixmap import Pixmap from Screens.Screen import Screen from Screens.MessageBox import MessageBox from Components.Console import Console from os import system, listdir, rename, symlink, unlink, path, mkdir from time import sleep config.infopanel = ConfigSubsection() config.infopanel.cronmanager_commandtype = NoSave(ConfigSelection(choices = [ ('custom',_("Custom")),('predefined',_("Predefined")) ])) config.infopanel.cronmanager_cmdtime = NoSave(ConfigClock(default=0)) config.infopanel.cronmanager_cmdtime.value, mytmpt = ([0, 0], [0, 0]) config.infopanel.cronmanager_user_command = NoSave(ConfigText(fixed_size=False)) config.infopanel.cronmanager_runwhen = NoSave(ConfigSelection(default='Daily', choices = [('Hourly', _("Hourly")),('Daily', _("Daily")),('Weekly', _("Weekly")),('Monthly', _("Monthly"))])) config.infopanel.cronmanager_dayofweek = NoSave(ConfigSelection(default='Monday', choices = [('Monday', _("Monday")),('Tuesday', _("Tuesday")),('Wednesday', _("Wednesday")),('Thursday', _("Thursday")),('Friday', _("Friday")),('Saturday', _("Saturday")),('Sunday', _("Sunday"))])) config.infopanel.cronmanager_dayofmonth = NoSave(ConfigInteger(default=1, limits=(1, 31))) class CronManager(Screen): skin = """ <screen position="center,center" size="590,400" title="Cron Manager"> <widget name="lab1" position="10,0" size="100,24" font="Regular;20" valign="center" transparent="0" /> <widget name="labdisabled" position="110,0" size="100,24" font="Regular;20" valign="center" halign="center" backgroundColor="red" zPosition="1" /> <widget name="labactive" position="110,0" size="100,24" font="Regular;20" valign="center" halign="center" backgroundColor="green" zPosition="2" /> <widget name="lab2" position="240,0" size="150,24" font="Regular;20" valign="center" transparent="0" /> <widget name="labstop" position="390,0" size="100,24" font="Regular;20" valign="center" halign="center" backgroundColor="red" zPosition="1" /> <widget name="labrun" position="390,0" size="100,24" font="Regular;20" valign="center" halign="center" backgroundColor="green" zPosition="2"/> <widget source="list" render="Listbox" position="10,35" size="540,325" scrollbarMode="showOnDemand" >