Python timer 模块,service_ref() 实例源码

我们从Python开源项目中,提取了以下19个代码示例,用于说明如何使用timer.service_ref()

项目:enigma2    作者:OpenLD    | 项目源码 | 文件源码
def setAutoincreaseEnd(self, entry = None):
        if not self.autoincrease:
            return False
        if entry is None:
            new_end =  int(time()) + self.autoincreasetime
        else:
            new_end = entry.begin -30

        dummyentry = RecordTimerEntry(self.service_ref, self.begin, new_end, self.name, self.description, self.eit, disabled=True, justplay = self.justplay, afterEvent = self.afterEvent, dirname = self.dirname, tags = self.tags)
        dummyentry.disabled = self.disabled
        timersanitycheck = TimerSanityCheck(NavigationInstance.instance.RecordTimer.timer_list, dummyentry)
        if not timersanitycheck.check():
            simulTimerList = timersanitycheck.getSimulTimerList()
            if simulTimerList is not None and len(simulTimerList) > 1:
                new_end = simulTimerList[1].begin
                new_end -= 30 # allow 30 seconds for prepare
        if new_end <= time():
            return False
        self.end = new_end
        return True
项目:enigma2    作者:Openeight    | 项目源码 | 文件源码
def setAutoincreaseEnd(self, entry = None):
        if not self.autoincrease:
            return False
        if entry is None:
            new_end =  int(time()) + self.autoincreasetime
        else:
            new_end = entry.begin - 30

        dummyentry = RecordTimerEntry(self.service_ref, self.begin, new_end, self.name, self.description, self.eit, disabled=True, justplay = self.justplay, afterEvent = self.afterEvent, dirname = self.dirname, tags = self.tags)
        dummyentry.disabled = self.disabled
        timersanitycheck = TimerSanityCheck(NavigationInstance.instance.RecordTimer.timer_list, dummyentry)
        if not timersanitycheck.check():
            simulTimerList = timersanitycheck.getSimulTimerList()
            if simulTimerList is not None and len(simulTimerList) > 1:
                new_end = simulTimerList[1].begin
                new_end -= 30               # 30 Sekunden Prepare-Zeit lassen
        if new_end <= time():
            return False
        self.end = new_end
        return True
项目:enigma2    作者:BlackHole    | 项目源码 | 文件源码
def calculateFilename(self, name=None):
        service_name = self.service_ref.getServiceName()
        begin_date = strftime("%Y%m%d %H%M", localtime(self.begin))

        name = name or self.name
        filename = begin_date + " - " + service_name
        if name:
            if config.recording.filename_composition.value == "event":
                filename = name + ' - ' + begin_date + "_" + service_name
            elif config.recording.filename_composition.value == "short":
                filename = strftime("%Y%m%d", localtime(self.begin)) + " - " + name
            elif config.recording.filename_composition.value == "long":
                filename += " - " + name + " - " + self.description
            else:
                filename += " - " + name # standard

        if config.recording.ascii_filenames.value:
            filename = ASCIItranslit.legacyEncode(filename)

        self.Filename = Directories.getRecordingFilename(filename, self.MountPath)
        self.log(0, "Filename calculated as: '%s'" % self.Filename)
        return self.Filename
项目:enigma2    作者:BlackHole    | 项目源码 | 文件源码
def setAutoincreaseEnd(self, entry = None):
        if not self.autoincrease:
            return False
        if entry is None:
            new_end =  int(time()) + self.autoincreasetime
        else:
            new_end = entry.begin -30

        dummyentry = RecordTimerEntry(self.service_ref, self.begin, new_end, self.name, self.description, self.eit, disabled=True, justplay = self.justplay, afterEvent = self.afterEvent, dirname = self.dirname, tags = self.tags)
        dummyentry.disabled = self.disabled
        timersanitycheck = TimerSanityCheck(NavigationInstance.instance.RecordTimer.timer_list, dummyentry)
        if not timersanitycheck.check():
            simulTimerList = timersanitycheck.getSimulTimerList()
            if simulTimerList is not None and len(simulTimerList) > 1:
                new_end = simulTimerList[1].begin
                new_end -= 30               # 30 Sekunden Prepare-Zeit lassen
        if new_end <= time():
            return False
        self.end = new_end
        return True
项目:enigma2-openpli-fulan    作者:Taapat    | 项目源码 | 文件源码
def setAutoincreaseEnd(self, entry = None):
        if not self.autoincrease:
            return False
        if entry is None:
            new_end =  int(time()) + self.autoincreasetime
        else:
            new_end = entry.begin - 30

        dummyentry = RecordTimerEntry(self.service_ref, self.begin, new_end, self.name, self.description, self.eit, disabled=True, justplay = self.justplay, afterEvent = self.afterEvent, dirname = self.dirname, tags = self.tags)
        dummyentry.disabled = self.disabled
        timersanitycheck = TimerSanityCheck(NavigationInstance.instance.RecordTimer.timer_list, dummyentry)
        if not timersanitycheck.check():
            simulTimerList = timersanitycheck.getSimulTimerList()
            if simulTimerList is not None and len(simulTimerList) > 1:
                new_end = simulTimerList[1].begin
                new_end -= 30               # 30 Sekunden Prepare-Zeit lassen
        if new_end <= time():
            return False
        self.end = new_end
        return True
项目:enigma2    作者:OpenLD    | 项目源码 | 文件源码
def __repr__(self):
        if not self.disabled:
            return "RecordTimerEntry(name=%s, begin=%s, serviceref=%s, justplay=%s, isAutoTimer=%s)" % (self.name, ctime(self.begin), self.service_ref, self.justplay, self.isAutoTimer)
        else:
            return "RecordTimerEntry(name=%s, begin=%s, serviceref=%s, justplay=%s, isAutoTimer=%s, Disabled)" % (self.name, ctime(self.begin), self.service_ref, self.justplay, self.isAutoTimer)
项目:enigma2    作者:OpenLD    | 项目源码 | 文件源码
def calculateFilename(self, name=None):
        service_name = self.service_ref.getServiceName()
        begin_date = strftime("%Y%m%d %H%M", localtime(self.begin))

        self.name = name or self.name
        filename = begin_date + " - " + service_name
        if self.name:
            if config.recording.filename_composition.value == "veryveryshort":
                filename = self.name
            elif config.recording.filename_composition.value == "veryshort":
                filename = self.name + " - " + begin_date
            elif config.recording.filename_composition.value == "event":
                filename = self.name + ' - ' + begin_date + "_" + service_name
            elif config.recording.filename_composition.value == "short":
                filename = strftime("%Y%m%d", localtime(self.begin)) + " - " + self.name
            elif config.recording.filename_composition.value == "shortwithtime":
                filename = strftime("%Y%m%d %H%M", localtime(self.begin)) + " - " + self.name
            elif config.recording.filename_composition.value == "long":
                filename += " - " + self.name + " - " + self.description
            else:
                filename += " - " + self.name # standard

        if config.recording.ascii_filenames.value:
            filename = ASCIItranslit.legacyEncode(filename)
        self.Filename = Directories.getRecordingFilename(filename, self.MountPath)
        if debug:
            self.log(0, "Filename calculated as: '%s'" % self.Filename)
        return self.Filename
项目:enigma2    作者:OpenLD    | 项目源码 | 文件源码
def switchToAll(self):
        refStr = self.service_ref.ref.toString()
        global InfoBar
        if not InfoBar: from Screens.InfoBar import InfoBar
        if refStr.startswith('1:0:2:'):
            if InfoBar.instance.servicelist.mode != 1:
                InfoBar.instance.servicelist.setModeRadio()
                InfoBar.instance.servicelist.radioTV = 1
            InfoBar.instance.servicelist.clearPath()
            rootbouquet = eServiceReference('1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.radio" ORDER BY bouquet')
            bouquet = eServiceReference('%s ORDER BY name'% service_types_radio)
        else:
            if InfoBar.instance.servicelist.mode != 0:
                InfoBar.instance.servicelist.setModeTV()
                InfoBar.instance.servicelist.radioTV = 0
            InfoBar.instance.servicelist.clearPath()
            rootbouquet = eServiceReference('1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.tv" ORDER BY bouquet')
            bouquet = eServiceReference('%s ORDER BY name'% service_types_tv)
        if InfoBar.instance.servicelist.bouquet_root != rootbouquet:
            InfoBar.instance.servicelist.bouquet_root = rootbouquet
        InfoBar.instance.servicelist.enterPath(bouquet)
        InfoBar.instance.servicelist.setCurrentSelection(self.service_ref.ref)
        InfoBar.instance.servicelist.zap(enable_pipzap = True)
        InfoBar.instance.servicelist.correctChannelNumber()
        InfoBar.instance.servicelist.startRoot = bouquet
        InfoBar.instance.servicelist.addToHistory(self.service_ref.ref)
项目:enigma2    作者:Openeight    | 项目源码 | 文件源码
def __repr__(self):
        return "RecordTimerEntry(name=%s, begin=%s, serviceref=%s, justplay=%s, isAutoTimer=%s)" % (self.name, ctime(self.begin), self.service_ref, self.justplay, self.isAutoTimer)
项目:enigma2    作者:Openeight    | 项目源码 | 文件源码
def calculateFilename(self, name=None):
        service_name = self.service_ref.getServiceName()
        begin_date = strftime("%Y%m%d %H%M", localtime(self.begin))
        name = name or self.name
        filename = begin_date + " - " + service_name
        if name:
            if config.recording.filename_composition.value == "short":
                filename = strftime("%Y%m%d", localtime(self.begin)) + " - " + name
            elif config.recording.filename_composition.value == "long":
                filename += " - " + name + " - " + self.description
            else:
                filename += " - " + name # standard

        if config.recording.ascii_filenames.value:
            filename = ASCIItranslit.legacyEncode(filename)
        if not self.dirname:
            dirname = findSafeRecordPath(defaultMoviePath())
        else:
            dirname = findSafeRecordPath(self.dirname)
            if dirname is None:
                dirname = findSafeRecordPath(defaultMoviePath())
                self.dirnameHadToFallback = True
        if not dirname:
            return None
        self.Filename = Directories.getRecordingFilename(filename, dirname)
        self.log(0, "Filename calculated as: '%s'" % self.Filename)
        return self.Filename
项目:enigma2    作者:Openeight    | 项目源码 | 文件源码
def failureCB(self, answer):
        self.ts_dialog = None
        if answer == True:
            self.log(13, "ok, zapped away")
            #NavigationInstance.instance.stopUserServices()
            NavigationInstance.instance.playService(self.service_ref.ref)
            if not self.first_try_prepare and self.InfoBarInstance and hasattr(self.InfoBarInstance.session, 'pipshown') and self.InfoBarInstance.session.pipshown:
                hasattr(self.InfoBarInstance, "showPiP") and self.InfoBarInstance.showPiP()
                if hasattr(self.InfoBarInstance.session, 'pip'):
                    del self.InfoBarInstance.session.pip
                    self.InfoBarInstance.session.pipshown = False
        else:
            self.log(14, "user didn't want to zap away, record will probably fail")
项目:enigma2    作者:BlackHole    | 项目源码 | 文件源码
def __repr__(self):
        if not self.disabled:
            return "RecordTimerEntry(name=%s, begin=%s, serviceref=%s, justplay=%s, isAutoTimer=%s)" % (self.name, ctime(self.begin), self.service_ref, self.justplay, self.isAutoTimer)
        else:
            return "RecordTimerEntry(name=%s, begin=%s, serviceref=%s, justplay=%s, isAutoTimer=%s, Disabled)" % (self.name, ctime(self.begin), self.service_ref, self.justplay, self.isAutoTimer)
项目:enigma2-openpli-fulan    作者:Taapat    | 项目源码 | 文件源码
def __repr__(self):
        return "RecordTimerEntry(name=%s, begin=%s, serviceref=%s, justplay=%s)" % (self.name, ctime(self.begin), self.service_ref, self.justplay)
项目:enigma2-openpli-fulan    作者:Taapat    | 项目源码 | 文件源码
def calculateFilename(self, name=None):
        service_name = self.service_ref.getServiceName()
        begin_date = strftime("%Y%m%d %H%M", localtime(self.begin))
        name = name or self.name
        filename = begin_date + " - " + service_name
        if name:
            if config.recording.filename_composition.value == "short":
                filename = strftime("%Y%m%d", localtime(self.begin)) + " - " + name
            elif config.recording.filename_composition.value == "long":
                filename += " - " + name + " - " + self.description
            else:
                filename += " - " + name # standard

        if config.recording.ascii_filenames.value:
            filename = ASCIItranslit.legacyEncode(filename)
        if not self.dirname:
            dirname = findSafeRecordPath(defaultMoviePath())
        else:
            dirname = findSafeRecordPath(self.dirname)
            if dirname is None:
                dirname = findSafeRecordPath(defaultMoviePath())
                self.dirnameHadToFallback = True
        if not dirname:
            return None
        self.Filename = Directories.getRecordingFilename(filename, dirname)
        self.log(0, "Filename calculated as: '%s'" % self.Filename)
        return self.Filename
项目:enigma2-openpli-fulan    作者:Taapat    | 项目源码 | 文件源码
def failureCB(self, answer):
        self.ts_dialog = None
        if answer:
            self.log(13, "ok, zapped away")
            #NavigationInstance.instance.stopUserServices()
            NavigationInstance.instance.playService(self.service_ref.ref)
            if not self.first_try_prepare and self.InfoBarInstance and hasattr(self.InfoBarInstance.session, 'pipshown') and self.InfoBarInstance.session.pipshown:
                hasattr(self.InfoBarInstance, "showPiP") and self.InfoBarInstance.showPiP()
                if hasattr(self.InfoBarInstance.session, 'pip'):
                    del self.InfoBarInstance.session.pip
                    self.InfoBarInstance.session.pipshown = False
        else:
            self.log(14, "user didn't want to zap away, record will probably fail")
项目:enigma2    作者:Openeight    | 项目源码 | 文件源码
def openChoiceActionBeforeZap(self):
        if self.ts_dialog is None:
            type = _("record")
            if self.justplay:
                type = _("zap")
            elif self.always_zap:
                type = _("zap and record")
            message = _("You must switch to the service %s (%s - '%s')!\n") % (type, self.service_ref.getServiceName(), self.name)
            if self.repeated:
                message += _("Attention, this is repeated timer!\n")
            message += _("Timeshift is running. Select an action.\n")
            choice = [(_("Zap"), "zap"), (_("Don't zap and disable timer"), "disable"), (_("Don't zap and remove timer"), "remove")]
            if not self.InfoBarInstance.save_timeshift_file:
                choice.insert(1, (_("Save timeshift in movie dir and zap"), "save_movie"))
                if self.InfoBarInstance.timeshiftActivated():
                    choice.insert(0, (_("Save timeshift and zap"), "save"))
                else:
                    choice.insert(1, (_("Save timeshift and zap"), "save"))
            else:
                message += _("Reminder, you have chosen to save timeshift file.")
            #if self.justplay or self.always_zap:
            #   choice.insert(2, (_("Don't zap"), "continue"))
            choice.insert(2, (_("Don't zap"), "continue"))
            def zapAction(choice):
                start_zap = True
                if choice:
                    if choice in ("zap", "save", "save_movie"):
                        self.log(8, "zap to recording service")
                        if choice in ("save", "save_movie"):
                            ts = self.InfoBarInstance.getTimeshift()
                            if ts and ts.isTimeshiftEnabled():
                                if choice =="save_movie":
                                    self.InfoBarInstance.save_timeshift_in_movie_dir = True
                                self.InfoBarInstance.save_timeshift_file = True
                                ts.saveTimeshiftFile()
                                del ts
                                self.InfoBarInstance.saveTimeshiftFiles()
                    elif choice == "disable":
                        self.disable()
                        NavigationInstance.instance.RecordTimer.timeChanged(self)
                        start_zap = False
                        self.log(8, "zap canceled by the user, timer disabled")
                    elif choice == "remove":
                        start_zap = False
                        self.afterEvent = AFTEREVENT.NONE
                        NavigationInstance.instance.RecordTimer.removeEntry(self)
                        self.log(8, "zap canceled by the user, timer removed")
                    elif choice == "continue":
                        if self.justplay:
                            self.end = self.begin
                        start_zap = False
                        self.log(8, "zap canceled by the user")
                if start_zap:
                    if not self.justplay:
                        self.setRecordingPreferredTuner()
                        self.failureCB(True)
                    else:
                        self.log(8, "zapping")
                        NavigationInstance.instance.playService(self.service_ref.ref)
            self.ts_dialog = self.InfoBarInstance.session.openWithCallback(zapAction, MessageBox, message, simple=True, list=choice, timeout=20)
项目:enigma2    作者:BlackHole    | 项目源码 | 文件源码
def openChoiceActionBeforeZap(self):
        if self.ts_dialog is None:
            type = _("record")
            if self.justplay:
                type = _("zap")
            elif self.always_zap:
                type = _("zap and record")
            message = _("You must switch to the service %s (%s - '%s')!\n") % (type, self.service_ref.getServiceName(), self.name)
            if self.repeated:
                message += _("Attention, this is repeated timer!\n")
            message += _("Timeshift is running. Select an action.\n")
            choice = [(_("Zap"), "zap"), (_("Don't zap and disable timer"), "disable"), (_("Don't zap and remove timer"), "remove")]
            if not self.InfoBarInstance.save_timeshift_file:
                choice.insert(0, (_("Save timeshift and zap"), "save"))
            else:
                message += _("Reminder, you have chosen to save timeshift file.")
            #if self.justplay or self.always_zap:
            #   choice.insert(2, (_("Don't zap"), "continue"))
            choice.insert(2, (_("Don't zap"), "continue"))
            def zapAction(choice):
                start_zap = True
                if choice:
                    if choice in ("zap", "save"):
                        self.log(8, "zap to recording service")
                        if choice == "save":
                            ts = self.InfoBarInstance.getTimeshift()
                            if ts and ts.isTimeshiftEnabled():
                                del ts
                                self.InfoBarInstance.save_timeshift_file = True
                                self.InfoBarInstance.SaveTimeshift()
                    elif choice == "disable":
                        self.disable()
                        NavigationInstance.instance.RecordTimer.timeChanged(self)
                        start_zap = False
                        self.log(8, "zap canceled by the user, timer disabled")
                    elif choice == "remove":
                        start_zap = False
                        self.afterEvent = AFTEREVENT.NONE
                        NavigationInstance.instance.RecordTimer.removeEntry(self)
                        self.log(8, "zap canceled by the user, timer removed")
                    elif choice == "continue":
                        if self.justplay:
                            self.end = self.begin
                        start_zap = False
                        self.log(8, "zap canceled by the user")
                if start_zap:
                    if not self.justplay:
                        self.setRecordingPreferredTuner()
                        self.failureCB(True)
                    else:
                        self.log(8, "zapping")
                        NavigationInstance.instance.playService(self.service_ref.ref)
            self.ts_dialog = self.InfoBarInstance.session.openWithCallback(zapAction, MessageBox, message, simple=True, list=choice, timeout=20)
项目:enigma2    作者:BlackHole    | 项目源码 | 文件源码
def failureCB(self, answer):
        if answer:
            self.log(13, "ok, zapped away")
            #NavigationInstance.instance.stopUserServices()
            from Screens.ChannelSelection import ChannelSelection
            ChannelSelectionInstance = ChannelSelection.instance
            self.service_types = service_types_tv
            if ChannelSelectionInstance:
                if config.usage.multibouquet.value:
                    bqrootstr = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.tv" ORDER BY bouquet'
                else:
                    bqrootstr = '%s FROM BOUQUET "userbouquet.favourites.tv" ORDER BY bouquet'% self.service_types
                rootstr = ''
                serviceHandler = eServiceCenter.getInstance()
                rootbouquet = eServiceReference(bqrootstr)
                bouquet = eServiceReference(bqrootstr)
                bouquetlist = serviceHandler.list(bouquet)
                if not bouquetlist is None:
                    while True:
                        bouquet = bouquetlist.getNext()
                        if bouquet.flags & eServiceReference.isDirectory:
                            ChannelSelectionInstance.clearPath()
                            ChannelSelectionInstance.setRoot(bouquet)
                            servicelist = serviceHandler.list(bouquet)
                            if not servicelist is None:
                                serviceIterator = servicelist.getNext()
                                while serviceIterator.valid():
                                    if self.service_ref.ref == serviceIterator:
                                        break
                                    serviceIterator = servicelist.getNext()
                                if self.service_ref.ref == serviceIterator:
                                    break
                    ChannelSelectionInstance.enterPath(rootbouquet)
                    ChannelSelectionInstance.enterPath(bouquet)
                    ChannelSelectionInstance.saveRoot()
                    ChannelSelectionInstance.saveChannel(self.service_ref.ref)
                ChannelSelectionInstance.addToHistory(self.service_ref.ref)
            NavigationInstance.instance.playService(self.service_ref.ref)
            if not self.first_try_prepare and self.InfoBarInstance and hasattr(self.InfoBarInstance.session, 'pipshown') and self.InfoBarInstance.session.pipshown:
                hasattr(self.InfoBarInstance, "showPiP") and self.InfoBarInstance.showPiP()
                if hasattr(self.InfoBarInstance.session, 'pip'):
                    del self.InfoBarInstance.session.pip
                    self.InfoBarInstance.session.pipshown = False
        else:
            self.log(14, "user didn't want to zap away, record will probably fail")
项目:enigma2-openpli-fulan    作者:Taapat    | 项目源码 | 文件源码
def openChoiceActionBeforeZap(self):
        if self.ts_dialog is None:
            type = _("record")
            if self.justplay:
                type = _("zap")
            elif self.always_zap:
                type = _("zap and record")
            message = _("You must switch to the service %s (%s - '%s')!\n") % (type, self.service_ref.getServiceName(), self.name)
            if self.repeated:
                message += _("Attention, this is repeated timer!\n")
            message += _("Timeshift is running. Select an action.\n")
            choice = [(_("Zap"), "zap"), (_("Don't zap and disable timer"), "disable"), (_("Don't zap and remove timer"), "remove")]
            if not self.InfoBarInstance.save_timeshift_file:
                choice.insert(1, (_("Save timeshift in movie dir and zap"), "save_movie"))
                if self.InfoBarInstance.timeshiftActivated():
                    choice.insert(0, (_("Save timeshift and zap"), "save"))
                else:
                    choice.insert(1, (_("Save timeshift and zap"), "save"))
            else:
                message += _("Reminder, you have chosen to save timeshift file.")
            #if self.justplay or self.always_zap:
            #   choice.insert(2, (_("Don't zap"), "continue"))
            choice.insert(2, (_("Don't zap"), "continue"))
            def zapAction(choice):
                start_zap = True
                if choice:
                    if choice in ("zap", "save", "save_movie"):
                        self.log(8, "zap to recording service")
                        if choice in ("save", "save_movie"):
                            ts = self.InfoBarInstance.getTimeshift()
                            if ts and ts.isTimeshiftEnabled():
                                if choice =="save_movie":
                                    self.InfoBarInstance.save_timeshift_in_movie_dir = True
                                self.InfoBarInstance.save_timeshift_file = True
                                ts.saveTimeshiftFile()
                                del ts
                                self.InfoBarInstance.saveTimeshiftFiles()
                    elif choice == "disable":
                        self.disable()
                        NavigationInstance.instance.RecordTimer.timeChanged(self)
                        start_zap = False
                        self.log(8, "zap canceled by the user, timer disabled")
                    elif choice == "remove":
                        start_zap = False
                        self.afterEvent = AFTEREVENT.NONE
                        NavigationInstance.instance.RecordTimer.removeEntry(self)
                        self.log(8, "zap canceled by the user, timer removed")
                    elif choice == "continue":
                        if self.justplay:
                            self.end = self.begin
                        start_zap = False
                        self.log(8, "zap canceled by the user")
                if start_zap:
                    if not self.justplay:
                        self.setRecordingPreferredTuner()
                        self.failureCB(True)
                    else:
                        self.log(8, "zapping")
                        NavigationInstance.instance.playService(self.service_ref.ref)
            self.ts_dialog = self.InfoBarInstance.session.openWithCallback(zapAction, MessageBox, message, simple=True, list=choice, timeout=20)