python类repeated()的实例源码

RecordTimer.py 文件源码 项目:enigma2 作者: OpenLD 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def removeEntry(self, entry):
        print "[Timer] Remove " + str(entry)

        # avoid re-enqueuing
        entry.repeated = False

        # abort timer.
        # this sets the end time to current time, so timer will be stopped.
        entry.autoincrease = False
        entry.abort()

        if entry.state != entry.StateEnded:
            self.timeChanged(entry)

#       print "state: ", entry.state
#       print "in processed: ", entry in self.processed_timers
#       print "in running: ", entry in self.timer_list
        # autoincrease instanttimer if possible
        if not entry.dontSave:
            for x in self.timer_list:
                if x.setAutoincreaseEnd():
                    self.timeChanged(x)
        # now the timer should be in the processed_timers list. remove it from there.
        self.processed_timers.remove(entry)
        self.saveTimer()
PowerTimer.py 文件源码 项目:enigma2 作者: BlackHole 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def do_backoff(self):
        if self.backoff == 0:
            self.backoff = 5*60
        else:
            self.backoff *= 2
            if self.backoff > 1800:
                self.backoff = 1800
        self.log(10, "backoff: retry in %d minutes" % (int(self.backoff)/60))
        #
        # If this is the first backoff of a repeat timer remember the original
        # begin/end times, so that we can use *these* when setting up the
        # repeat.
        # A repeat timer (self.repeat != 0) is one set for a given time on a
        # day.
        # A timer that repeats every <n> mins has autosleeprepeat="repeated" and
        # is a different beast, whcih doesn't need, and mustn't have, this.
        #
        if self.repeated and not hasattr(self, "real_begin"):
            self.real_begin = self.begin
            self.real_end = self.end
RecordTimer.py 文件源码 项目:enigma2 作者: BlackHole 项目源码 文件源码 阅读 39 收藏 0 点赞 0 评论 0
def removeEntry(self, entry):
        print "[RecordTimer] Remove " + str(entry)

        # avoid re-enqueuing
        entry.repeated = False

        # abort timer.
        # this sets the end time to current time, so timer will be stopped.
        entry.autoincrease = False
        entry.abort()

        if entry.state != entry.StateEnded:
            self.timeChanged(entry)

#       print "[RecordTimer]state: ", entry.state
#       print "[RecordTimer]in processed: ", entry in self.processed_timers
#       print "[RecordTimer]in running: ", entry in self.timer_list
        # autoincrease instanttimer if possible
        if not entry.dontSave:
            for x in self.timer_list:
                if x.setAutoincreaseEnd():
                    self.timeChanged(x)
        # now the timer should be in the processed_timers list. remove it from there.
        self.processed_timers.remove(entry)
        self.saveTimer()
PowerTimer.py 文件源码 项目:enigma2 作者: OpenLD 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def getNextWakeup(self, getNextStbPowerOn = False):
        next_state = self.state + 1
        if getNextStbPowerOn:
            if next_state == 3 and (self.timerType == TIMERTYPE.WAKEUP or self.timerType == TIMERTYPE.WAKEUPTOSTANDBY or self.afterEvent == AFTEREVENT.WAKEUP or  self.afterEvent == AFTEREVENT.WAKEUPTOSTANDBY):
                if self.start_prepare > time() and (self.timerType == TIMERTYPE.WAKEUP or self.timerType == TIMERTYPE.WAKEUPTOSTANDBY): #timer start time is later as now - begin time was changed while running timer
                    return self.start_prepare
                elif self.begin > time() and (self.timerType == TIMERTYPE.WAKEUP or self.timerType == TIMERTYPE.WAKEUPTOSTANDBY): #timer start time is later as now - begin time was changed while running timer
                    return self.begin
                if self.afterEvent == AFTEREVENT.WAKEUP or self.afterEvent == AFTEREVENT.WAKEUPTOSTANDBY:
                    return self.end
                next_day = 0
                count_day = 0
                wd_timer = datetime.fromtimestamp(self.begin).isoweekday()*-1
                wd_repeated = bin(128+self.repeated)
                for s in range(wd_timer-1,-8,-1):
                    count_day +=1
                    if int(wd_repeated[s]):
                        next_day = s
                        break
                if next_day == 0:
                    for s in range(-1,wd_timer-1,-1):
                        count_day +=1
                        if int(wd_repeated[s]):
                            next_day = s
                            break
                #return self.begin + 86400 * count_day
                return self.start_prepare + 86400 * count_day
            elif next_state == 2 and (self.timerType == TIMERTYPE.WAKEUP or self.timerType == TIMERTYPE.WAKEUPTOSTANDBY):
                return self.begin
            elif next_state == 1 and (self.timerType == TIMERTYPE.WAKEUP or self.timerType == TIMERTYPE.WAKEUPTOSTANDBY):
                return self.start_prepare
            elif next_state < 3 and (self.afterEvent == AFTEREVENT.WAKEUP or self.afterEvent == AFTEREVENT.WAKEUPTOSTANDBY):
                return self.end
            else:
                return -1

        if self.state == self.StateEnded or self.state == self.StateFailed:
            return self.end
        return {self.StatePrepared: self.start_prepare,
                self.StateRunning: self.begin,
                self.StateEnded: self.end}[next_state]
PowerTimer.py 文件源码 项目:enigma2 作者: OpenLD 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def doActivate(self, w):
        # when activating a timer which has already passed,
        # simply abort the timer. don't run trough all the stages.
        if w.shouldSkip():
            w.state = PowerTimerEntry.StateEnded
        else:
            # when active returns true, this means "accepted".
            # otherwise, the current state is kept.
            # the timer entry itself will fix up the delay then.
            if w.activate():
                w.state += 1

        try:
            self.timer_list.remove(w)
        except:
            print '[PowerManager]: Remove list failed'

        # did this timer reached the last state?
        if w.state < PowerTimerEntry.StateEnded:
            # no, sort it into active list
            insort(self.timer_list, w)
        else:
            # yes. Process repeated, and re-add.
            if w.repeated:
                w.processRepeated()
                w.state = PowerTimerEntry.StateWaiting
                self.addTimerEntry(w)
            else:
                # Remove old timers as set in config
                self.cleanupDaily(config.recording.keep_timers.value)
                insort(self.processed_timers, w)
        self.stateChanged(w)
PowerTimer.py 文件源码 项目:enigma2 作者: OpenLD 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def removeEntry(self, entry):
        print "[PowerTimer] Remove",str(entry)

        # avoid re-enqueuing
        entry.repeated = False

        # abort timer.
        # this sets the end time to current time, so timer will be stopped.
        entry.autoincrease = False
        entry.abort()

        if entry.state != entry.StateEnded:
            self.timeChanged(entry)

#       print "state: ", entry.state
#       print "in processed: ", entry in self.processed_timers
#       print "in running: ", entry in self.timer_list
        # disable timer first
        if entry.state != 3:
            entry.disable()
        # autoincrease instanttimer if possible
        if not entry.dontSave:
            for x in self.timer_list:
                if x.setAutoincreaseEnd():
                    self.timeChanged(x)
        # now the timer should be in the processed_timers list. remove it from there.
        if entry in self.processed_timers:
            self.processed_timers.remove(entry)
        self.saveTimer()
RecordTimer.py 文件源码 项目:enigma2 作者: OpenLD 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def getNextActivation(self, getNextStbPowerOn = False):
        self.isStillRecording = False
        next_state = self.state + 1
        if getNextStbPowerOn:
            if next_state == 3:
                self.isStillRecording = True
                next_day = 0
                count_day = 0
                wd_timer = datetime.fromtimestamp(self.begin).isoweekday()*-1
                wd_repeated = bin(128+int(self.repeated))

                for s in range(wd_timer-1,-8,-1):
                    count_day +=1
                    if int(wd_repeated[s]):
                        next_day = s
                        break
                if next_day == 0:
                    for s in range(-1,wd_timer-1,-1):
                        count_day +=1
                        if int(wd_repeated[s]):
                            next_day = s
                            break
                #return self.begin + 86400 * count_day
                return self.start_prepare + 86400 * count_day
            elif next_state == 2:
                return self.begin
            elif next_state == 1:
                return self.start_prepare
            else:
                return -1

        if self.state == self.StateEnded or self.state == self.StateFailed:
            if self.end > time():
                self.isStillRecording = True
            return self.end
        if next_state == self.StateEnded or next_state == self.StateFailed:
            if self.end > time():
                self.isStillRecording = True
        return {self.StatePrepared: self.start_prepare,
                self.StateRunning: self.begin,
                self.StateEnded: self.end}[next_state]
RecordTimer.py 文件源码 项目:enigma2 作者: OpenLD 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def doActivate(self, w):
        # when activating a timer which has already passed,
        # simply abort the timer. don't run through all the stages.
        if w.shouldSkip():
            w.state = RecordTimerEntry.StateEnded
        else:
            # when active returns true, this means "accepted".
            # otherwise, the current state is kept.
            # the timer entry itself will fix up the delay then.
            if w.activate():
                w.state += 1

        try:
            self.timer_list.remove(w)
        except:
            print '[RecordTimer]: Remove list failed'

        # did this timer reach the last state?
        if w.state < RecordTimerEntry.StateEnded:
            # no, sort it into active list
            insort(self.timer_list, w)
        else:
            # yes. Process repeated, and re-add.
            if w.repeated:
                w.processRepeated()
                w.state = RecordTimerEntry.StateWaiting
                w.first_try_prepare = 0 # changed from a bool to a counter, not renamed for compatibility with openWebif
                w.messageBoxAnswerPending = False
                w.justTriedFreeingTuner = False
                w.messageString = "" # incremental MessageBox string
                w.messageStringShow = False
                self.addTimerEntry(w)
            else:
                # correct wrong running timers
                self.checkWrongRunningTimers()
                # check for disabled timers, if time as passed set to completed
                self.cleanupDisabled()
                # remove old timers as set in config
                self.cleanupDaily(config.recording.keep_timers.value)
                insort(self.processed_timers, w)
        self.stateChanged(w)
RecordTimer.py 文件源码 项目:enigma2 作者: Openeight 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def gotRecordEvent(self, record, event):
        # TODO: this is not working (never true), please fix. (comparing two swig wrapped ePtrs)
        if self.__record_service.__deref__() != record.__deref__():
            return
        self.log(16, "record event %d" % event)
        if event == iRecordableService.evRecordWriteError:
            print "WRITE ERROR on recording, disk full?"
            # show notification. the 'id' will make sure that it will be
            # displayed only once, even if more timers are failing at the
            # same time. (which is very likely in case of disk fullness)
            Notifications.AddPopup(text = _("Write error while recording. Disk full?\n"), type = MessageBox.TYPE_ERROR, timeout = 0, id = "DiskFullMessage")
            # ok, the recording has been stopped. we need to properly note
            # that in our state, with also keeping the possibility to re-try.
            # TODO: this has to be done.
        elif event == iRecordableService.evStart:
            text = _("A record has been started:\n%s") % self.name
            notify = config.usage.show_message_when_recording_starts.value and not Screens.Standby.inStandby and self.InfoBarInstance and self.InfoBarInstance.execing
            if self.dirnameHadToFallback:
                text = '\n'.join((text, _("Please note that the previously selected media could not be accessed and therefore the default directory is being used instead.")))
                notify = True
            if notify:
                Notifications.AddPopup(text = text, type = MessageBox.TYPE_INFO, timeout = 3)
        elif event == iRecordableService.evRecordAborted:
            NavigationInstance.instance.RecordTimer.removeEntry(self)
        elif event == iRecordableService.evGstRecordEnded:
            if self.repeated:
                self.processRepeated(findRunningEvent = False)
            NavigationInstance.instance.RecordTimer.doActivate(self)

    # we have record_service as property to automatically subscribe to record service events
RecordTimer.py 文件源码 项目:enigma2 作者: Openeight 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def doActivate(self, w):
        # when activating a timer which has already passed,
        # simply abort the timer. don't run trough all the stages.
        if w.shouldSkip():
            w.state = RecordTimerEntry.StateEnded
        else:
            # when active returns true, this means "accepted".
            # otherwise, the current state is kept.
            # the timer entry itself will fix up the delay then.
            if w.activate():
                w.state += 1

        self.timer_list.remove(w)

        # did this timer reached the last state?
        if w.state < RecordTimerEntry.StateEnded:
            # no, sort it into active list
            insort(self.timer_list, w)
        else:
            # yes. Process repeated, and re-add.
            if w.repeated:
                w.processRepeated()
                w.state = RecordTimerEntry.StateWaiting
                w.first_try_prepare = True
                self.addTimerEntry(w)
            else:
                # correct wrong running timers
                self.checkWrongRunningTimers()
                # check for disabled timers, if time as passed set to completed
                self.cleanupDisabled()
                # Remove old timers as set in config
                self.cleanupDaily(config.recording.keep_timers.value)
                # If we want to keep done timers, re-insert in the active list
                if config.recording.keep_timers.value > 0 and w not in self.processed_timers:
                    insort(self.processed_timers, w)

        self.stateChanged(w)
RecordTimer.py 文件源码 项目:enigma2 作者: Openeight 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def removeEntry(self, entry):
        print "[Timer] Remove " + str(entry)

        # avoid re-enqueuing
        entry.repeated = False

        # abort timer.
        # this sets the end time to current time, so timer will be stopped.
        entry.autoincrease = False
        entry.abort()

        if entry.state != entry.StateEnded:
            self.timeChanged(entry)

        print "state: ", entry.state
        print "in processed: ", entry in self.processed_timers
        print "in running: ", entry in self.timer_list
        # autoincrease instanttimer if possible
        if not entry.dontSave:
            for x in self.timer_list:
                if x.setAutoincreaseEnd():
                    self.timeChanged(x)
        if entry in self.processed_timers:
            # now the timer should be in the processed_timers list. remove it from there.
            self.processed_timers.remove(entry)
        self.saveTimer()
PowerTimer.py 文件源码 项目:enigma2 作者: BlackHole 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def createTimer(xml):
    timertype = str(xml.get("timertype") or "wakeup")
    timertype = {
        "wakeup": TIMERTYPE.WAKEUP,
        "wakeuptostandby": TIMERTYPE.WAKEUPTOSTANDBY,
        "autostandby": TIMERTYPE.AUTOSTANDBY,
        "autodeepstandby": TIMERTYPE.AUTODEEPSTANDBY,
        "standby": TIMERTYPE.STANDBY,
        "deepstandby": TIMERTYPE.DEEPSTANDBY,
        "reboot": TIMERTYPE.REBOOT,
        "restart": TIMERTYPE.RESTART
        }[timertype]
    begin = int(xml.get("begin"))
    end = int(xml.get("end"))
    repeated = xml.get("repeated").encode("utf-8")
    disabled = long(xml.get("disabled") or "0")
    afterevent = str(xml.get("afterevent") or "nothing")
    afterevent = {
        "nothing": AFTEREVENT.NONE,
        "wakeuptostandby": AFTEREVENT.WAKEUPTOSTANDBY,
        "standby": AFTEREVENT.STANDBY,
        "deepstandby": AFTEREVENT.DEEPSTANDBY
        }[afterevent]
    autosleepinstandbyonly = str(xml.get("autosleepinstandbyonly") or "no")
    autosleepdelay = str(xml.get("autosleepdelay") or "0")
    autosleeprepeat = str(xml.get("autosleeprepeat") or "once")

    entry = PowerTimerEntry(begin, end, disabled, afterevent, timertype)
    entry.repeated = int(repeated)
    entry.autosleepinstandbyonly = autosleepinstandbyonly
    entry.autosleepdelay = int(autosleepdelay)
    entry.autosleeprepeat = autosleeprepeat

    for l in xml.findall("log"):
        time = int(l.get("time"))
        code = int(l.get("code"))
        msg = l.text.strip().encode("utf-8")
        entry.log_entries.append((time, code, msg))

    return entry
PowerTimer.py 文件源码 项目:enigma2 作者: BlackHole 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def doActivate(self, w):
        # when activating a timer which has already passed,
        # simply abort the timer. don't run trough all the stages.
        if w.shouldSkip():
            w.state = PowerTimerEntry.StateEnded
        else:
            # when active returns true, this means "accepted".
            # otherwise, the current state is kept.
            # the timer entry itself will fix up the delay then.
            if w.activate():
                w.state += 1

        try:
            self.timer_list.remove(w)
        except:
            print '[PowerManager]: Remove list failed'

        # did this timer reached the last state?
        if w.state < PowerTimerEntry.StateEnded:
            # no, sort it into active list
            insort(self.timer_list, w)
        else:
            # yes. Process repeated, and re-add.
            if w.repeated:
                # If we have saved original begin/end times for a backed off timer
                # restore those values now
                if hasattr(w, "real_begin"):
                    w.begin = w.real_begin
                    w.end = w.real_end
                    # Now remove the temporary holding attributes...
                    del w.real_begin
                    del w.real_end
                w.processRepeated()
                w.state = PowerTimerEntry.StateWaiting
                self.addTimerEntry(w)
            else:
                # Remove old timers as set in config
                self.cleanupDaily(config.recording.keep_timers.value)
                insort(self.processed_timers, w)
        self.stateChanged(w)
PowerTimer.py 文件源码 项目:enigma2 作者: BlackHole 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def removeEntry(self, entry):
        print "[PowerTimer] Remove",str(entry)

        # avoid re-enqueuing
        entry.repeated = False

        # abort timer.
        # this sets the end time to current time, so timer will be stopped.
        entry.autoincrease = False
        entry.abort()

        if entry.state != entry.StateEnded:
            self.timeChanged(entry)

#       print "state: ", entry.state
#       print "in processed: ", entry in self.processed_timers
#       print "in running: ", entry in self.timer_list
        # disable timer first
        if entry.state != 3:
            entry.disable()
        # autoincrease instanttimer if possible
        if not entry.dontSave:
            for x in self.timer_list:
                if x.setAutoincreaseEnd():
                    self.timeChanged(x)
        # now the timer should be in the processed_timers list. remove it from there.
        if entry in self.processed_timers:
            self.processed_timers.remove(entry)
        self.saveTimer()
RecordTimer.py 文件源码 项目:enigma2 作者: BlackHole 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def doActivate(self, w):
        # when activating a timer which has already passed,
        # simply abort the timer. don't run trough all the stages.
        if w.shouldSkip():
            w.state = RecordTimerEntry.StateEnded
        else:
            # when active returns true, this means "accepted".
            # otherwise, the current state is kept.
            # the timer entry itself will fix up the delay then.
            if w.activate():
                w.state += 1

        try:
            self.timer_list.remove(w)
        except:
            print '[RecordTimer] Remove list failed'

        # did this timer reached the last state?
        if w.state < RecordTimerEntry.StateEnded:
            # no, sort it into active list
            insort(self.timer_list, w)
        else:
            # yes. Process repeated, and re-add.
            if w.repeated:
                w.processRepeated()
                w.state = RecordTimerEntry.StateWaiting
                w.first_try_prepare = True
                self.addTimerEntry(w)
            else:
                # correct wrong running timers
                self.checkWrongRunningTimers()
                # check for disabled timers, if time as passed set to completed
                self.cleanupDisabled()
                # Remove old timers as set in config
                self.cleanupDaily(config.recording.keep_timers.value)
                # If we want to keep done timers, re-insert in the active list
                if config.recording.keep_timers.value > 0:
                    insort(self.processed_timers, w)

        self.stateChanged(w)
RecordTimer.py 文件源码 项目:enigma2-openpli-fulan 作者: Taapat 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def gotRecordEvent(self, record, event):
        # TODO: this is not working (never true), please fix. (comparing two swig wrapped ePtrs)
        if self.__record_service.__deref__() != record.__deref__():
            return
        self.log(16, "record event %d" % event)
        if event == iRecordableService.evRecordWriteError:
            print "WRITE ERROR on recording, disk full?"
            # show notification. the 'id' will make sure that it will be
            # displayed only once, even if more timers are failing at the
            # same time. (which is very likely in case of disk fullness)
            Notifications.AddPopup(text = _("Write error while recording. Disk full?\n"), type = MessageBox.TYPE_ERROR, timeout = 0, id = "DiskFullMessage")
            # ok, the recording has been stopped. we need to properly note
            # that in our state, with also keeping the possibility to re-try.
            # TODO: this has to be done.
        elif event == iRecordableService.evStart:
            text = _("A record has been started:\n%s") % self.name
            notify = config.usage.show_message_when_recording_starts.value and not Screens.Standby.inStandby and self.InfoBarInstance and self.InfoBarInstance.execing
            if self.dirnameHadToFallback:
                text = '\n'.join((text, _("Please note that the previously selected media could not be accessed and therefore the default directory is being used instead.")))
                notify = True
            if notify:
                Notifications.AddPopup(text = text, type = MessageBox.TYPE_INFO, timeout = 3)
        elif event == iRecordableService.evRecordAborted:
            NavigationInstance.instance.RecordTimer.removeEntry(self)
        elif event == iRecordableService.evGstRecordEnded:
            if self.repeated:
                self.processRepeated(findRunningEvent = False)
            NavigationInstance.instance.RecordTimer.doActivate(self)

    # we have record_service as property to automatically subscribe to record service events
RecordTimer.py 文件源码 项目:enigma2-openpli-fulan 作者: Taapat 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def doActivate(self, w):
        # when activating a timer which has already passed,
        # simply abort the timer. don't run trough all the stages.
        if w.shouldSkip():
            w.state = RecordTimerEntry.StateEnded
        else:
            # when active returns true, this means "accepted".
            # otherwise, the current state is kept.
            # the timer entry itself will fix up the delay then.
            if w.activate():
                w.state += 1

        self.timer_list.remove(w)

        # did this timer reached the last state?
        if w.state < RecordTimerEntry.StateEnded:
            # no, sort it into active list
            insort(self.timer_list, w)
        else:
            # yes. Process repeated, and re-add.
            if w.repeated:
                w.processRepeated()
                w.state = RecordTimerEntry.StateWaiting
                w.first_try_prepare = True
                self.addTimerEntry(w)
            else:
                # correct wrong running timers
                self.checkWrongRunningTimers()
                # check for disabled timers, if time as passed set to completed
                self.cleanupDisabled()
                # Remove old timers as set in config
                self.cleanupDaily(config.recording.keep_timers.value)
                # If we want to keep done timers, re-insert in the active list
                if config.recording.keep_timers.value > 0 and w not in self.processed_timers:
                    insort(self.processed_timers, w)

        self.stateChanged(w)
RecordTimer.py 文件源码 项目:enigma2-openpli-fulan 作者: Taapat 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def removeEntry(self, entry):
        print "[Timer] Remove " + str(entry)

        # avoid re-enqueuing
        entry.repeated = False

        # abort timer.
        # this sets the end time to current time, so timer will be stopped.
        entry.autoincrease = False
        entry.abort()

        if entry.state != entry.StateEnded:
            self.timeChanged(entry)

        print "state: ", entry.state
        print "in processed: ", entry in self.processed_timers
        print "in running: ", entry in self.timer_list
        # autoincrease instanttimer if possible
        if not entry.dontSave:
            for x in self.timer_list:
                if x.setAutoincreaseEnd():
                    self.timeChanged(x)
        if entry in self.processed_timers:
            # now the timer should be in the processed_timers list. remove it from there.
            self.processed_timers.remove(entry)
        self.saveTimer()
PowerTimer.py 文件源码 项目:enigma2 作者: OpenLD 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def createTimer(xml):
    timertype = str(xml.get("timertype") or "wakeup")
    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
        }[timertype]
    begin = int(xml.get("begin"))
    end = int(xml.get("end"))
    repeated = xml.get("repeated").encode("utf-8")
    disabled = long(xml.get("disabled") or "0")
    afterevent = str(xml.get("afterevent") or "nothing")
    afterevent = {
        "nothing": AFTEREVENT.NONE,
        "wakeup": AFTEREVENT.WAKEUP,
        "wakeuptostandby": AFTEREVENT.WAKEUPTOSTANDBY,
        "standby": AFTEREVENT.STANDBY,
        "deepstandby": AFTEREVENT.DEEPSTANDBY
        }[afterevent]
    autosleepinstandbyonly = str(xml.get("autosleepinstandbyonly") or "no")
    autosleepdelay = str(xml.get("autosleepdelay") or "0")
    autosleeprepeat = str(xml.get("autosleeprepeat") or "once")
    autosleepwindow = str(xml.get("autosleepwindow") or "no")
    autosleepbegin = int(xml.get("autosleepbegin") or begin)
    autosleepend = int(xml.get("autosleepend") or end)

    nettraffic = str(xml.get("nettraffic") or "no")
    trafficlimit = int(xml.get("trafficlimit") or 100)
    netip = str(xml.get("netip") or "no")
    ipadress = str(xml.get("ipadress") or "0.0.0.0")

    entry = PowerTimerEntry(begin, end, disabled, afterevent, timertype)
    entry.repeated = int(repeated)
    entry.autosleepinstandbyonly = autosleepinstandbyonly
    entry.autosleepdelay = int(autosleepdelay)
    entry.autosleeprepeat = autosleeprepeat
    entry.autosleepwindow = autosleepwindow
    entry.autosleepbegin = autosleepbegin
    entry.autosleepend = autosleepend

    entry.nettraffic = nettraffic
    entry.trafficlimit = trafficlimit
    entry.netip = netip
    entry.ipadress = ipadress

    for l in xml.findall("log"):
        ltime = int(l.get("time"))
        code = int(l.get("code"))
        msg = l.text.strip().encode("utf-8")
        entry.log_entries.append((ltime, code, msg))

    return entry
RecordTimer.py 文件源码 项目:enigma2 作者: OpenLD 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def createTimer(xml):
    begin = int(xml.get("begin"))
    end = int(xml.get("end"))
    serviceref = ServiceReference(xml.get("serviceref").encode("utf-8"))
    description = xml.get("description").encode("utf-8")
    repeated = xml.get("repeated").encode("utf-8")
    rename_repeat = long(xml.get("rename_repeat") or "0")
    disabled = long(xml.get("disabled") or "0")
    justplay = long(xml.get("justplay") or "0")
    always_zap = long(xml.get("always_zap") or "0")
    conflict_detection = long(xml.get("conflict_detection") or "1")
    afterevent = str(xml.get("afterevent") or "nothing")
    afterevent = {
        "nothing": AFTEREVENT.NONE,
        "standby": AFTEREVENT.STANDBY,
        "deepstandby": AFTEREVENT.DEEPSTANDBY,
        "auto": AFTEREVENT.AUTO
        }[afterevent]
    eit = xml.get("eit")
    if eit and eit != "None":
        eit = long(eit)
    else:
        eit = None
    location = xml.get("location")
    if location and location != "None":
        location = location.encode("utf-8")
    else:
        location = None
    tags = xml.get("tags")
    if tags and tags != "None":
        tags = tags.encode("utf-8").split(' ')
    else:
        tags = None
    descramble = int(xml.get("descramble") or "1")
    record_ecm = int(xml.get("record_ecm") or "0")
    isAutoTimer = int(xml.get("isAutoTimer") or "0")

    name = xml.get("name").encode("utf-8")
    #filename = xml.get("filename").encode("utf-8")
    entry = RecordTimerEntry(serviceref, begin, end, name, description, eit, disabled, justplay, afterevent, dirname = location, tags = tags, descramble = descramble, record_ecm = record_ecm, conflict_detection = conflict_detection, isAutoTimer = isAutoTimer, always_zap = always_zap, rename_repeat = rename_repeat)
    entry.repeated = int(repeated)
    flags = xml.get("flags")
    if flags:
        entry.flags = set(flags.encode("utf-8").split(' '))

    for l in xml.findall("log"):
        time = int(l.get("time"))
        code = int(l.get("code"))
        msg = l.text.strip().encode("utf-8")
        entry.log_entries.append((time, code, msg))

    return entry
RecordTimer.py 文件源码 项目:enigma2 作者: Openeight 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
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)
RecordTimer.py 文件源码 项目:enigma2 作者: Openeight 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def createTimer(xml):
    begin = int(xml.get("begin"))
    end = int(xml.get("end"))
    serviceref = ServiceReference(xml.get("serviceref").encode("utf-8"))
    description = xml.get("description").encode("utf-8")
    repeated = xml.get("repeated").encode("utf-8")
    rename_repeat = long(xml.get("rename_repeat") or "1")
    disabled = long(xml.get("disabled") or "0")
    justplay = long(xml.get("justplay") or "0")
    always_zap = long(xml.get("always_zap") or "0")
    zap_wakeup = str(xml.get("zap_wakeup") or "always")
    conflict_detection = long(xml.get("conflict_detection") or "1")
    afterevent = str(xml.get("afterevent") or "nothing")
    afterevent = {
        "nothing": AFTEREVENT.NONE,
        "standby": AFTEREVENT.STANDBY,
        "deepstandby": AFTEREVENT.DEEPSTANDBY,
        "auto": AFTEREVENT.AUTO
        }[afterevent]
    eit = xml.get("eit")
    if eit and eit != "None":
        eit = long(eit)
    else:
        eit = None
    location = xml.get("location")
    if location and location != "None":
        location = location.encode("utf-8")
    else:
        location = None
    tags = xml.get("tags")
    if tags and tags != "None":
        tags = tags.encode("utf-8").split(' ')
    else:
        tags = None
    descramble = int(xml.get("descramble") or "1")
    record_ecm = int(xml.get("record_ecm") or "0")
    isAutoTimer = int(xml.get("isAutoTimer") or "0")

    name = xml.get("name").encode("utf-8")
    #filename = xml.get("filename").encode("utf-8")
    entry = RecordTimerEntry(serviceref, begin, end, name, description, eit, disabled, justplay, afterevent, dirname = location, tags = tags, descramble = descramble, record_ecm = record_ecm, isAutoTimer = isAutoTimer, always_zap = always_zap, zap_wakeup = zap_wakeup, rename_repeat = rename_repeat, conflict_detection = conflict_detection)
    entry.repeated = int(repeated)
    flags = xml.get("flags")
    if flags:
        entry.flags = set(flags.encode("utf-8").split(' '))

    for l in xml.findall("log"):
        time = int(l.get("time"))
        code = int(l.get("code"))
        msg = l.text.strip().encode("utf-8")
        entry.log_entries.append((time, code, msg))

    return entry
RecordTimer.py 文件源码 项目:enigma2 作者: BlackHole 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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)
RecordTimer.py 文件源码 项目:enigma2 作者: BlackHole 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def createTimer(xml):
    begin = int(xml.get("begin"))
    end = int(xml.get("end"))
    serviceref = ServiceReference(xml.get("serviceref").encode("utf-8"))
    description = xml.get("description").encode("utf-8")
    repeated = xml.get("repeated").encode("utf-8")
    rename_repeat = long(xml.get("rename_repeat") or "1")
    disabled = long(xml.get("disabled") or "0")
    justplay = long(xml.get("justplay") or "0")
    always_zap = long(xml.get("always_zap") or "0")
    pipzap = long(xml.get("pipzap") or "0")
    conflict_detection = long(xml.get("conflict_detection") or "1")
    afterevent = str(xml.get("afterevent") or "nothing")
    afterevent = {
        "nothing": AFTEREVENT.NONE,
        "standby": AFTEREVENT.STANDBY,
        "deepstandby": AFTEREVENT.DEEPSTANDBY,
        "auto": AFTEREVENT.AUTO
        }[afterevent]
    eit = xml.get("eit")
    if eit and eit != "None":
        eit = long(eit)
    else:
        eit = None
    location = xml.get("location")
    if location and location != "None":
        location = location.encode("utf-8")
    else:
        location = None
    tags = xml.get("tags")
    if tags and tags != "None":
        tags = tags.encode("utf-8").split(' ')
    else:
        tags = None
    descramble = int(xml.get("descramble") or "1")
    record_ecm = int(xml.get("record_ecm") or "0")
    isAutoTimer = int(xml.get("isAutoTimer") or "0")

    name = xml.get("name").encode("utf-8")
    #filename = xml.get("filename").encode("utf-8")
    entry = RecordTimerEntry(serviceref, begin, end, name, description, eit, disabled, justplay, afterevent, dirname = location, tags = tags, descramble = descramble, record_ecm = record_ecm, isAutoTimer = isAutoTimer, always_zap = always_zap, rename_repeat = rename_repeat, conflict_detection = conflict_detection, pipzap = pipzap)
    entry.repeated = int(repeated)
    flags = xml.get("flags")
    if flags:
        entry.flags = set(flags.encode("utf-8").split(' '))

    for l in xml.findall("log"):
        time = int(l.get("time"))
        code = int(l.get("code"))
        msg = l.text.strip().encode("utf-8")
        entry.log_entries.append((time, code, msg))

    return entry
RecordTimer.py 文件源码 项目:enigma2-openpli-fulan 作者: Taapat 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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)
RecordTimer.py 文件源码 项目:enigma2-openpli-fulan 作者: Taapat 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def createTimer(xml):
    begin = int(xml.get("begin"))
    end = int(xml.get("end"))
    serviceref = ServiceReference(xml.get("serviceref").encode("utf-8"))
    description = xml.get("description").encode("utf-8")
    repeated = xml.get("repeated").encode("utf-8")
    rename_repeat = long(xml.get("rename_repeat") or "1")
    disabled = long(xml.get("disabled") or "0")
    justplay = long(xml.get("justplay") or "0")
    always_zap = long(xml.get("always_zap") or "0")
    zap_wakeup = str(xml.get("zap_wakeup") or "always")
    conflict_detection = long(xml.get("conflict_detection") or "1")
    afterevent = str(xml.get("afterevent") or "nothing")
    afterevent = {
        "nothing": AFTEREVENT.NONE,
        "standby": AFTEREVENT.STANDBY,
        "deepstandby": AFTEREVENT.DEEPSTANDBY,
        "auto": AFTEREVENT.AUTO
        }[afterevent]
    eit = xml.get("eit")
    if eit and eit != "None":
        eit = long(eit)
    else:
        eit = None
    location = xml.get("location")
    if location and location != "None":
        location = location.encode("utf-8")
    else:
        location = None
    tags = xml.get("tags")
    if tags and tags != "None":
        tags = tags.encode("utf-8").split(' ')
    else:
        tags = None
    descramble = int(xml.get("descramble") or "1")
    record_ecm = int(xml.get("record_ecm") or "0")

    name = xml.get("name").encode("utf-8")
    #filename = xml.get("filename").encode("utf-8")
    entry = RecordTimerEntry(serviceref, begin, end, name, description, eit, disabled, justplay, afterevent, dirname = location, tags = tags, descramble = descramble, record_ecm = record_ecm, always_zap = always_zap, zap_wakeup = zap_wakeup, rename_repeat = rename_repeat, conflict_detection = conflict_detection)
    entry.repeated = int(repeated)
    flags = xml.get("flags")
    if flags:
        entry.flags = set(flags.encode("utf-8").split(' '))

    for l in xml.findall("log"):
        time = int(l.get("time"))
        code = int(l.get("code"))
        msg = l.text.strip().encode("utf-8")
        entry.log_entries.append((time, code, msg))

    return entry


问题


面经


文章

微信
公众号

扫码关注公众号