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

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

项目: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 = PowerTimerEntry(self.begin, new_end, disabled=True, afterEvent = self.afterEvent, timerType = self.timerType)
        dummyentry.disabled = self.disabled
        timersanitycheck = TimerSanityCheck(NavigationInstance.instance.PowerManager.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 getPriorityCheck(self,prioPT,prioPTae):
        shiftPT = breakPT = False
        nextPTlist = NavigationInstance.instance.PowerTimer.getNextPowerManagerTime(getNextTimerTyp = True)
        for entry in nextPTlist:
            #check timers within next 15 mins will started or ended
            if abs(entry[0] - time()) > 900:
                continue
            #faketime
            if entry[1] is None and entry[2] is None and entry[3] is None:
                if debug: print "shift#2 - entry is faketime", ctime(entry[0]), entry
                shiftPT = True
                continue
            #is timer in list itself?
            if entry[0] == self.begin and entry[1] == self.timerType and entry[2] is None and entry[3] == self.state \
                or entry[0] == self.end and entry[1] is None and entry[2] == self.afterEvent and entry[3] == self.state:
                if debug: print "entry is itself", ctime(entry[0]), entry
                nextPTitself = True
            else:
                nextPTitself = False
            if (entry[1] in prioPT or entry[2] in prioPTae) and not nextPTitself:
                if debug: print "break#2 <= 900", ctime(entry[0]), entry
                breakPT = True
                break
        return shiftPT, breakPT
项目:enigma2    作者:OpenLD    | 项目源码 | 文件源码
def getNextPowerManagerTimeOld(self, getNextStbPowerOn = False):
        now = int(time())
        nextPTlist = [(-1,None,None,None)]
        for timer in self.timer_list:
            if timer.timerType != TIMERTYPE.AUTOSTANDBY and timer.timerType != TIMERTYPE.AUTODEEPSTANDBY:
                next_act = timer.getNextWakeup(getNextStbPowerOn)
                if next_act + 3 < now:
                    continue
                if getNextStbPowerOn and debug:
                    print "[powertimer] next stb power up", strftime("%a, %Y/%m/%d %H:%M", localtime(next_act))
                next_timertype = next_afterevent = None
                if nextPTlist[0][0] == -1:
                    if abs(next_act - timer.begin) <= 30:
                        next_timertype = timer.timerType
                    elif abs(next_act - timer.end) <= 30:
                        next_afterevent = timer.afterEvent
                    nextPTlist = [(next_act,next_timertype,next_afterevent,timer.state)]
                else:
                    if abs(next_act - timer.begin) <= 30:
                        next_timertype = timer.timerType
                    elif abs(next_act - timer.end) <= 30:
                        next_afterevent = timer.afterEvent
                    nextPTlist.append((next_act,next_timertype,next_afterevent,timer.state))
        nextPTlist.sort()
        return nextPTlist
项目: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    作者:OpenLD    | 项目源码 | 文件源码
def getNextRecordingTimeOld(self, getNextStbPowerOn = False):
        now = time()
        if getNextStbPowerOn:
            save_act = -1, 0
            for timer in self.timer_list:
                next_act = timer.getNextActivation(getNextStbPowerOn)
                if timer.justplay or next_act + 3 < now:
                    continue
                if debug: print "[recordtimer] next stb power up", strftime("%a, %Y/%m/%d %H:%M", localtime(next_act))
                if save_act[0] == -1:
                    save_act = next_act, int(not timer.always_zap)
                else:
                    if next_act < save_act[0]:
                        save_act = next_act, int(not timer.always_zap)
            return save_act
        else:
            for timer in self.timer_list:
                next_act = timer.getNextActivation()
                if timer.justplay or next_act + 3 < now or timer.end == next_act:
                    continue
                return next_act
        return -1
项目:enigma2    作者:OpenLD    | 项目源码 | 文件源码
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()
项目: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 __init__(self, begin, end, disabled = False, afterEvent = AFTEREVENT.NONE, timerType = TIMERTYPE.WAKEUP, checkOldTimers = False):
        timer.TimerEntry.__init__(self, int(begin), int(end))
        if checkOldTimers:
            if self.begin < time() - 1209600:
                self.begin = int(time())

        if self.end < self.begin:
            self.end = self.begin

        self.dontSave = False
        self.disabled = disabled
        self.timer = None
        self.__record_service = None
        self.start_prepare = 0
        self.timerType = timerType
        self.afterEvent = afterEvent
        self.autoincrease = False
        self.autoincreasetime = 3600 * 24 # 1 day
        self.autosleepinstandbyonly = 'no'
        self.autosleepdelay = 60
        self.autosleeprepeat = 'once'

        self.log_entries = []
        self.resetState()
项目:enigma2    作者:BlackHole    | 项目源码 | 文件源码
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
项目: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 = PowerTimerEntry(self.begin, new_end, disabled=True, afterEvent = self.afterEvent, timerType = self.timerType)
        dummyentry.disabled = self.disabled
        timersanitycheck = TimerSanityCheck(NavigationInstance.instance.PowerManager.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 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()
项目: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 resetTimerWakeup():
    global wasTimerWakeup
    if os.path.exists("/tmp/was_powertimer_wakeup"):
        os.remove("/tmp/was_powertimer_wakeup")
        if debug: print "[POWERTIMER] reset wakeup state"
    wasTimerWakeup = False

# parses an event, and gives out a (begin, end, name, duration, eit)-tuple.
# begin and end will be corrected
项目:enigma2    作者:OpenLD    | 项目源码 | 文件源码
def parseEvent(ev):
    begin = ev.getBeginTime()
    end = begin + ev.getDuration()
    return begin, end
项目:enigma2    作者:OpenLD    | 项目源码 | 文件源码
def __init__(self, begin, end, disabled = False, afterEvent = AFTEREVENT.NONE, timerType = TIMERTYPE.WAKEUP, checkOldTimers = False, autosleepdelay = 60):
        timer.TimerEntry.__init__(self, int(begin), int(end))
        if checkOldTimers:
            if self.begin < time() - 1209600:
                self.begin = int(time())

        if self.end < self.begin:
            self.end = self.begin

        self.dontSave = False
        self.disabled = disabled
        self.timer = None
        self.__record_service = None
        self.start_prepare = 0
        self.timerType = timerType
        self.afterEvent = afterEvent
        self.autoincrease = False
        self.autoincreasetime = 3600 * 24 # 1 day
        self.autosleepinstandbyonly = 'no'
        self.autosleepdelay = autosleepdelay
        self.autosleeprepeat = 'once'
        self.autosleepwindow = 'no'
        self.autosleepbegin = self.begin
        self.autosleepend = self.end

        self.nettraffic = 'no'
        self.trafficlimit = 100
        self.netip = 'no'
        self.ipadress = "0.0.0.0"

        self.log_entries = []
        self.resetState()

        self.messageBoxAnswerPending = False

        #check autopowertimer
        if (self.timerType == TIMERTYPE.AUTOSTANDBY or self.timerType == TIMERTYPE.AUTODEEPSTANDBY) and not self.disabled and time() > 3600 and self.begin > time():
            self.begin = int(time())                        #the begin is in the future -> set to current time = no start delay of this timer
项目:enigma2    作者:OpenLD    | 项目源码 | 文件源码
def keyPressed(self, key, tag):
        if self.getAutoSleepWindow():
            self.begin = self.end = int(time()) + int(self.autosleepdelay)*60
项目:enigma2    作者:OpenLD    | 项目源码 | 文件源码
def getNextActivation(self):
        if self.state == self.StateEnded or self.state == self.StateFailed:
            return self.end

        next_state = self.state + 1

        return {self.StatePrepared: self.start_prepare,
                self.StateRunning: self.begin,
                self.StateEnded: self.end }[next_state]
项目:enigma2    作者:OpenLD    | 项目源码 | 文件源码
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]
项目:enigma2    作者:OpenLD    | 项目源码 | 文件源码
def resetTimerWakeup():
    global wasRecTimerWakeup
    if os.path.exists("/tmp/was_rectimer_wakeup"):
        os.remove("/tmp/was_rectimer_wakeup")
        if debug: print "[RECORDTIMER] reset wakeup state"
    wasRecTimerWakeup = False

# parses an event and returns a (begin, end, name, duration, eit)-tuple.
# begin and end will be corrected
项目:enigma2    作者:OpenLD    | 项目源码 | 文件源码
def parseEvent(ev, description = True):
    if description:
        name = ev.getEventName()
        description = ev.getShortDescription()
        if description == "":
            description = ev.getExtendedDescription()
    else:
        name = ""
        description = ""
    begin = ev.getBeginTime()
    end = begin + ev.getDuration()
    eit = ev.getEventId()
    begin -= config.recording.margin_before.value * 60
    end += config.recording.margin_after.value * 60
    return begin, end, name, description, eit
项目:enigma2    作者:OpenLD    | 项目源码 | 文件源码
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]
项目:enigma2    作者:Openeight    | 项目源码 | 文件源码
def parseEvent(ev, description = True):
    if description:
        name = ev.getEventName()
        description = ev.getShortDescription()
        if description == "":
            description = ev.getExtendedDescription()
    else:
        name = ""
        description = ""
    begin = ev.getBeginTime()
    end = begin + ev.getDuration()
    eit = ev.getEventId()
    begin -= config.recording.margin_before.value * 60
    end += config.recording.margin_after.value * 60
    return (begin, end, name, description, eit)
项目:enigma2    作者:Openeight    | 项目源码 | 文件源码
def getNextActivation(self):
        if self.state == self.StateEnded:
            return self.end

        next_state = self.state + 1

        return {self.StatePrepared: self.start_prepare,
                self.StateRunning: self.begin,
                self.StateEnded: self.end }[next_state]
项目:enigma2    作者:BlackHole    | 项目源码 | 文件源码
def parseEvent(ev):
    begin = ev.getBeginTime()
    end = begin + ev.getDuration()
    return begin, end
项目:enigma2    作者:BlackHole    | 项目源码 | 文件源码
def keyPressed(self, key, tag):
        self.begin = time() + int(self.autosleepdelay)*60
        if self.end <= self.begin:
            self.end = self.begin
项目:enigma2    作者:BlackHole    | 项目源码 | 文件源码
def getNextWakeup(self):
        if self.state == self.StateEnded or self.state == self.StateFailed:
            return self.end

        if self.timerType != TIMERTYPE.WAKEUP and self.timerType != TIMERTYPE.WAKEUPTOSTANDBY and not self.afterEvent:
            return -1
        elif self.timerType != TIMERTYPE.WAKEUP and self.timerType != TIMERTYPE.WAKEUPTOSTANDBY and self.afterEvent:
            return self.end
        next_state = self.state + 1
        return {self.StatePrepared: self.start_prepare,
                self.StateRunning: self.begin,
                self.StateEnded: self.end }[next_state]
项目:enigma2    作者:BlackHole    | 项目源码 | 文件源码
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
项目:enigma2    作者:BlackHole    | 项目源码 | 文件源码
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)
项目:enigma2    作者:BlackHole    | 项目源码 | 文件源码
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()
项目:enigma2    作者:BlackHole    | 项目源码 | 文件源码
def parseEvent(ev, description = True):
    if description:
        name = ev.getEventName()
        description = ev.getShortDescription()
        if description == "":
            description = ev.getExtendedDescription()
    else:
        name = ""
        description = ""
    begin = ev.getBeginTime()
    end = begin + ev.getDuration()
    eit = ev.getEventId()
    begin -= config.recording.margin_before.value * 60
    end += config.recording.margin_after.value * 60
    return (begin, end, name, description, eit)
项目:enigma2    作者:BlackHole    | 项目源码 | 文件源码
def getNextActivation(self):
        self.isStillRecording = False
        if self.state == self.StateEnded or self.state == self.StateFailed:
            if self.end > time():
                self.isStillRecording = True
            return self.end
        next_state = self.state + 1
        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]
项目:enigma2-openpli-fulan    作者:Taapat    | 项目源码 | 文件源码
def parseEvent(ev, description = True):
    if description:
        name = ev.getEventName()
        description = ev.getShortDescription()
        if description == "":
            description = ev.getExtendedDescription()
    else:
        name = ""
        description = ""
    begin = ev.getBeginTime()
    end = begin + ev.getDuration()
    eit = ev.getEventId()
    begin -= config.recording.margin_before.value * 60
    end += config.recording.margin_after.value * 60
    return (begin, end, name, description, eit)
项目:enigma2-openpli-fulan    作者:Taapat    | 项目源码 | 文件源码
def getNextActivation(self):
        if self.state == self.StateEnded:
            return self.end

        next_state = self.state + 1

        return {self.StatePrepared: self.start_prepare,
                self.StateRunning: self.begin,
                self.StateEnded: self.end }[next_state]
项目:enigma2    作者:OpenLD    | 项目源码 | 文件源码
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
项目:enigma2    作者:OpenLD    | 项目源码 | 文件源码
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
项目: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    作者:Openeight    | 项目源码 | 文件源码
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
项目: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 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
项目: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)
项目:enigma2-openpli-fulan    作者:Taapat    | 项目源码 | 文件源码
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