def sendStandbyNotification(self, answer): RecordTimerEntry.keypress() if answer: Notifications.AddNotification(Screens.Standby.Standby)
def DoElektroStandby(self,retval): if (retval): #Yes, go to sleep Notifications.AddNotification(Standby.Standby)
def showReceivedMessage(self, numReceived, peer): text = _("Birthday Reminder received %s birthdays from %s.") % ( numReceived, peer) Notifications.AddNotification(MessageBox, text, type=MessageBox.TYPE_INFO)
def __init__(self, nextRecordTimerAfterEventActionAuto=False): if NavigationInstance.instance is not None: raise NavigationInstance.instance NavigationInstance.instance = self self.ServiceHandler = eServiceCenter.getInstance() import Navigation as Nav Nav.navcore = self self.pnav = pNavigation() self.pnav.m_event.get().append(self.dispatchEvent) self.pnav.m_record_event.get().append(self.dispatchRecordEvent) self.event = [] self.record_event = [] self.currentlyPlayingServiceReference = None self.currentlyPlayingServiceOrGroup = None self.currentlyPlayingService = None self.RecordTimer = None for p in plugins.getPlugins(PluginDescriptor.WHERE_RECORDTIMER): self.RecordTimer = p() if self.RecordTimer: break if not self.RecordTimer: self.RecordTimer = RecordTimer.RecordTimer() self.nextRecordTimerAfterEventActionAuto = nextRecordTimerAfterEventActionAuto self.__wasTimerWakeup = False self.__wasRecTimerWakeup = False self.syncCount = 0 self.__isRestartUI = config.misc.RestartUI.value startup_to_standby = config.usage.startup_to_standby.value wakeup_time_type = config.misc.prev_wakeup_time_type.value wasTimerWakeup = getFPWasTimerWakeup() if not wasTimerWakeup: #work-around for boxes where driver not sent was_timer_wakeup signal to e2 print "[NAVIGATION] getNextRecordingTime= %s" % self.RecordTimer.getNextRecordingTime( ) print "[NAVIGATION] current Time=%s" % time() print "[NAVIGATION] timediff=%s" % abs( self.RecordTimer.getNextRecordingTime() - time()) if time( ) <= 31536000: # check for NTP-time sync, if no sync, wait for transponder time self.timesynctimer = eTimer() self.timesynctimer.callback.append(self.TimeSynctimer) self.timesynctimer.start(5000, True) print "[NAVIGATION] wait for time sync" elif abs( self.RecordTimer.getNextRecordingTime() - time() ) <= 360: # if there is a recording sheduled in the next 5 mins, set the wasTimerWakeup flag wasTimerWakeup = True f = open("/tmp/was_timer_wakeup_workaround.txt", "w") file = f.write(str(wasTimerWakeup)) f.close() print "[NAVIGATION] wasTimerWakeup = %s" % wasTimerWakeup if wasTimerWakeup: self.__wasTimerWakeup = True if time() <= 31536000: self.timesynctimer = eTimer() self.timesynctimer.callback.append(self.TimeSynctimer) self.timesynctimer.start(5000, True) print "[NAVIGATION] wait for time sync" elif nextRecordTimerAfterEventActionAuto and abs( self.RecordTimer.getNextRecordingTime() - time()) <= 360: self.__wasRecTimerWakeup = True print 'RECTIMER: wakeup to standby detected.' f = open("/tmp/was_rectimer_wakeup", "w") f.write('1') f.close() # as we woke the box to record, place the box in standby. self.standbytimer = eTimer() self.standbytimer.callback.append(self.gotostandby) self.standbytimer.start(15000, True) if config.usage.remote_fallback_import_restart.value: ImportChannels() if config.misc.RestartUI.value: config.misc.RestartUI.value = False config.misc.RestartUI.save() configfile.save() else: if config.usage.remote_fallback_import.value and not config.usage.remote_fallback_import_restart.value: ImportChannels() if startup_to_standby == "yes" or self.__wasTimerWakeup and config.misc.prev_wakeup_time.value and ( (wakeup_time_type == 0 or wakeup_time_type == 1) or (wakeup_time_type == 3 and startup_to_standby == "except")): if not Screens.Standby.inTryQuitMainloop: Notifications.AddNotification(Screens.Standby.Standby) if config.misc.prev_wakeup_time.value: config.misc.prev_wakeup_time.value = 0 config.misc.prev_wakeup_time.save() configfile.save()
def shutdown(self, answer): if answer is not None: if answer and not Screens.Standby.inTryQuitMainloop: Notifications.AddNotification(Screens.Standby.TryQuitMainloop, 1)
def sendStandbyNotification(self, answer): if answer: Notifications.AddNotification(Screens.Standby.Standby)
def standby(self): from Screens.Standby import Standby, inStandby if not inStandby: from Tools import Notifications Notifications.AddNotification(Standby)
def activate(self): next_state = self.state + 1 self.log(5, "activating state %d" % next_state) if next_state == self.StatePrepared and (self.timerType == TIMERTYPE.AUTOSTANDBY or self.timerType == TIMERTYPE.AUTODEEPSTANDBY): # This is the first action for an auto* timer. # It binds any key press to keyPressed(), which resets the timer delay, # and sets the initial delay. # eActionMap.getInstance().bindAction('', -0x7FFFFFFF, self.keyPressed) self.begin = time() + int(self.autosleepdelay) * 60 if self.end <= self.begin: self.end = self.begin if next_state == self.StatePrepared: self.log(6, "prepare ok, waiting for begin") self.next_activation = self.begin self.backoff = 0 return True elif next_state == self.StateRunning: self.wasPowerTimerWakeup = False if os.path.exists("/tmp/was_powertimer_wakeup"): self.wasPowerTimerWakeup = int(open("/tmp/was_powertimer_wakeup", "r").read()) and True or False os.remove("/tmp/was_powertimer_wakeup") # if this timer has been cancelled, just go to "end" state. if self.cancelled: return True if self.failed: return True if self.timerType == TIMERTYPE.WAKEUP: if Screens.Standby.inStandby: Screens.Standby.inStandby.Power() return True elif self.timerType == TIMERTYPE.WAKEUPTOSTANDBY: return True elif self.timerType == TIMERTYPE.STANDBY: if not Screens.Standby.inStandby: # not already in standby Notifications.AddNotificationWithUniqueIDCallback(self.sendStandbyNotification, "PT_StateChange", MessageBox, _("A finished powertimer wants to set your\n%s %s to standby. Do that now?") % (getMachineBrand(), getMachineName()), timeout=180) return True elif self.timerType == TIMERTYPE.AUTOSTANDBY: if NavigationInstance.instance.getCurrentlyPlayingServiceReference() and ('0:0:0:0:0:0:0:0:0' in NavigationInstance.instance.getCurrentlyPlayingServiceReference().toString() or '4097:' in NavigationInstance.instance.getCurrentlyPlayingServiceReference().toString()): self.do_backoff() # retry return False if not Screens.Standby.inStandby: # not already in standby Notifications.AddNotificationWithUniqueIDCallback(self.sendStandbyNotification, "PT_StateChange", MessageBox, _("A finished powertimer wants to set your\n%s %s to standby. Do that now?") % (getMachineBrand(), getMachineName()), timeout=180) if self.autosleeprepeat == "once": eActionMap.getInstance().unbindAction('', self.keyPressed) return True else: self.begin = time() + int(self.autosleepdelay) * 60 if self.end <= self.begin: self.end = self.begin else: self.begin = time() + int(self.autosleepdelay) * 60 if self.end <= self.begin: self.end = self.begin elif self.timerType == TIMERTYPE.AUTODEEPSTANDBY: # Check for there being any active Movie playback or IPTV channel # or any streaming clients before going to Deep Standby. # However, it is possible to put the box into Standby with the # MoviePlayer still active (it will play if the box is taken out # of Standby) - similarly for the IPTV player. This should not # prevent a DeepStandby # And check for existing or imminent recordings, etc.. # Also added () around the test and split them across lines # to make it clearer what each test is. # from Components.Converter.ClientsStreaming import ClientsStreaming if ((not Screens.Standby.inStandby and NavigationInstance.instance.getCurrentlyPlayingServiceReference() and ('0:0:0:0:0:0:0:0:0' in NavigationInstance.instance.getCurrentlyPlayingServiceReference().toString() or '4097:' in NavigationInstance.instance.getCurrentlyPlayingServiceReference().toString() ) or (int(ClientsStreaming("NUMBER").getText()) > 0) ) or (NavigationInstance.instance.RecordTimer.isRecording() or abs(NavigationInstance.instance.RecordTimer.getNextRecordingTime() - time()) <= 900 or abs(NavigationInstance.instance.RecordTimer.getNextZapTime() - time()) <= 900) or (self.autosleepinstandbyonly == 'yes' and not Screens.Standby.inStandby) or (self.autosleepinstandbyonly == 'yes' and Screens.Standby.inStandby and internalHDDNotSleeping() ) ): self.do_backoff() # retry return False if not Screens.Standby.inTryQuitMainloop: # not a shutdown messagebox is open if Screens.Standby.inStandby: # in standby quitMainloop(1) return True else: Notifications.AddNotificationWithUniqueIDCallback(self.sendTryQuitMainloopNotification, "PT_StateChange", MessageBox, _("A finished powertimer wants to shutdown your %s %s.\nDo that now?") % (getMachineBrand(), getMachineName()), timeout=180) if self.autosleeprepeat == "once": eActionMap.getInstance().unbindAction('', self.keyPressed) return True else: self.begin = time() + int(self.autosleepdelay) * 60 if self.end <= self.begin: self.end = self.begin elif self.timerType == TIMERTYPE.DEEPSTANDBY and self.wasPowerTimerWakeup: return True elif self.timerType == TIMERTYPE.DEEPSTANDBY and not self.wasPowerTimerWakeup: if NavigationInstance.instance.RecordTimer.isRecording() or abs(NavigationInstance.instance.RecordTimer.getNextRecordingTime() - time()) <= 900 or abs(NavigationInstance.instance.RecordTimer.getNextZapTime() - time()) <= 900: self.do_backoff() # retry return False if not Screens.Standby.inTryQuitMainloop: # not a shutdown messagebox is open if Screens.Standby.inStandby: # in standby quitMainloop(1) else: Notifications.AddNotificationWithUniqueIDCallback(self.sendTryQuitMainloopNotification, "PT_StateChange", MessageBox, _("A finished powertimer wants to shutdown your %s %s.\nDo that now?") % (getMachineBrand(), getMachineName()), timeout=180) return True elif self.timerType == TIMERTYPE.REBOOT: if NavigationInstance.instance.RecordTimer.isRecording() or abs(NavigationInstance.instance.RecordTimer.getNextRecordingTime() - time()) <= 900 or abs(NavigationInstance.instance.RecordTimer.getNextZapTime() - time()) <= 900: self.do_backoff() # retry return False if not Screens.Standby.inTryQuitMainloop: # not a shutdown messagebox is open if Screens.Standby.inStandby: # in standby quitMainloop(2) else: Notifications.AddNotificationWithUniqueIDCallback(self.sendTryToRebootNotification, "PT_StateChange", MessageBox, _("A finished powertimer wants to reboot your %s %s.\nDo that now?") % (getMachineBrand(), getMachineName()), timeout=180) return True elif self.timerType == TIMERTYPE.RESTART: if NavigationInstance.instance.RecordTimer.isRecording() or abs(NavigationInstance.instance.RecordTimer.getNextRecordingTime() - time()) <= 900 or abs(NavigationInstance.instance.RecordTimer.getNextZapTime() - time()) <= 900: self.do_backoff() # retry return False if not Screens.Standby.inTryQuitMainloop: # not a shutdown messagebox is open if Screens.Standby.inStandby: # in standby quitMainloop(3) else: Notifications.AddNotificationWithUniqueIDCallback(self.sendTryToRestartNotification, "PT_StateChange", MessageBox, _("A finished powertimer wants to restart the user interface.\nDo that now?"), timeout=180) return True elif next_state == self.StateEnded: old_end = self.end NavigationInstance.instance.PowerTimer.saveTimer() if self.afterEvent == AFTEREVENT.STANDBY: if not Screens.Standby.inStandby: # not already in standby Notifications.AddNotificationWithUniqueIDCallback(self.sendStandbyNotification, "PT_StateChange", MessageBox, _("A finished powertimer wants to set your\n%s %s to standby. Do that now?") % (getMachineBrand(), getMachineName()), timeout=180) elif self.afterEvent == AFTEREVENT.DEEPSTANDBY: if NavigationInstance.instance.RecordTimer.isRecording() or abs(NavigationInstance.instance.RecordTimer.getNextRecordingTime() - time()) <= 900 or abs(NavigationInstance.instance.RecordTimer.getNextZapTime() - time()) <= 900: self.do_backoff() # retry return False if not Screens.Standby.inTryQuitMainloop: # not a shutdown messagebox is open if Screens.Standby.inStandby: # in standby quitMainloop(1) else: Notifications.AddNotificationWithUniqueIDCallback(self.sendTryQuitMainloopNotification, "PT_StateChange", MessageBox, _("A finished powertimer wants to shutdown your %s %s.\nDo that now?") % (getMachineBrand(), getMachineName()), timeout=180) return True
def startedConnecting(self, connector): #@UnusedVariable # pylint: disable=W0613 if config.plugins.NcidClient.connectionVerbose.value: Notifications.AddNotification(MessageBox, _("Connecting to NCID Server..."), type=MessageBox.TYPE_INFO, timeout=2)
def activate(self): next_state = self.state + 1 self.log(5, "activating state %d" % next_state) if next_state == self.StatePrepared: if not self.justplay and not self.freespace(): Notifications.AddPopup( text=_("Write error while recording. Disk full?\n%s") % self.name, type=MessageBox.TYPE_ERROR, timeout=5, id="DiskFullMessage") self.failed = True self.next_activation = time() self.end = time() + 5 self.backoff = 0 return True if self.always_zap: if Screens.Standby.inStandby: self.wasInStandby = True eActionMap.getInstance().bindAction( '', -maxint - 1, self.keypress) #set service to zap after standby Screens.Standby.inStandby.prev_running_service = self.service_ref.ref Screens.Standby.inStandby.paused_service = None #wakeup standby Screens.Standby.inStandby.Power() self.log(5, "wakeup and zap to recording service") else: cur_zap_ref = NavigationInstance.instance.getCurrentlyPlayingServiceReference( ) if cur_zap_ref and not cur_zap_ref.getPath( ): # we do not zap away if it is no live service Notifications.AddNotification( MessageBox, _("In order to record a timer, the TV was switched to the recording service!\n" ), type=MessageBox.TYPE_INFO, timeout=20) self.failureCB(True) self.log(5, "zap to recording service") if self.tryPrepare(): self.log(6, "prepare ok, waiting for begin") # create file to "reserve" the filename # because another recording at the same time on another service can try to record the same event # i.e. cable / sat.. then the second recording needs an own extension... when we create the file # here than calculateFilename is happy if not self.justplay: open(self.Filename + ".ts", "w").close() # Give the Trashcan a chance to clean up try: Trashcan.instance.cleanIfIdle() except Exception, e: print "[TIMER] Failed to call Trashcan.instance.cleanIfIdle()" print "[TIMER] Error:", e # fine. it worked, resources are allocated. self.next_activation = self.begin self.backoff = 0 return True self.log(7, "prepare failed") if self.first_try_prepare: self.first_try_prepare = False cur_ref = NavigationInstance.instance.getCurrentlyPlayingServiceReference( ) if cur_ref and not cur_ref.getPath(): if not config.recording.asktozap.getValue(): self.log(8, "asking user to zap away") Notifications.AddNotificationWithCallback( self.failureCB, MessageBox, _("A timer failed to record!\nDisable TV and try again?\n" ), timeout=20) else: # zap without asking self.log(9, "zap without asking") Notifications.AddNotification( MessageBox, _("In order to record a timer, the TV was switched to the recording service!\n" ), type=MessageBox.TYPE_INFO, timeout=20) self.failureCB(True) elif cur_ref: self.log( 8, "currently running service is not a live service.. so stop it makes no sense" ) else: self.log( 8, "currently no service running... so we dont need to stop it" ) return False
def sendTryQuitMainloopNotification(self, answer): if answer: Notifications.AddNotification(Screens.Standby.TryQuitMainloop, 1) else: global wasRecTimerWakeup wasRecTimerWakeup = False
self.log(12, "stop recording") if not self.justplay: if self.record_service: NavigationInstance.instance.stopRecordService( self.record_service) self.record_service = None NavigationInstance.instance.RecordTimer.saveTimer() if self.afterEvent == AFTEREVENT.STANDBY or ( not wasRecTimerWakeup and self.autostate and self.afterEvent == AFTEREVENT.AUTO) or self.wasInStandby: self.keypress() #this unbinds the keypress detection if not Screens.Standby.inStandby: # not already in standby Notifications.AddNotificationWithCallback( self.sendStandbyNotification, MessageBox, _("A finished record timer wants to set your\n%s %s to standby. Do that now?" ) % (getMachineBrand(), getMachineName()), timeout=180) elif self.afterEvent == AFTEREVENT.DEEPSTANDBY or ( wasRecTimerWakeup and self.afterEvent == AFTEREVENT.AUTO): if ( abs(NavigationInstance.instance.RecordTimer. getNextRecordingTime() - time()) <= 900 or abs(NavigationInstance.instance.RecordTimer. getNextZapTime() - time()) <= 900 ) or NavigationInstance.instance.RecordTimer.getStillRecording( ): print '[Timer] Recording or Recording due is next 15 mins, not return to deepstandby' return True if not Screens.Standby.inTryQuitMainloop: # not a shutdown messagebox is open if Screens.Standby.inStandby: # in standby
class RecordTimerEntry(timer.TimerEntry, object): ######### the following static methods and members are only in use when the box is in (soft) standby wasInStandby = False wasInDeepStandby = False receiveRecordEvents = False @staticmethod def keypress(key=None, flag=1): if flag and (RecordTimerEntry.wasInStandby or RecordTimerEntry.wasInDeepStandby): RecordTimerEntry.wasInStandby = False RecordTimerEntry.wasInDeepStandby = False eActionMap.getInstance().unbindAction('', RecordTimerEntry.keypress) @staticmethod def setWasInDeepStandby(): RecordTimerEntry.wasInDeepStandby = True eActionMap.getInstance().bindAction('', -maxint - 1, RecordTimerEntry.keypress) @staticmethod def setWasInStandby(): if not RecordTimerEntry.wasInStandby: if not RecordTimerEntry.wasInDeepStandby: eActionMap.getInstance().bindAction('', -maxint - 1, RecordTimerEntry.keypress) RecordTimerEntry.wasInDeepStandby = False RecordTimerEntry.wasInStandby = True @staticmethod def shutdown(): quitMainloop(1) @staticmethod def staticGotRecordEvent(recservice, event): if event == iRecordableService.evEnd: print "RecordTimer.staticGotRecordEvent(iRecordableService.evEnd)" if not checkForRecordings(): print "No recordings busy of sceduled within 6 minutes so shutdown" RecordTimerEntry.shutdown() # immediate shutdown elif event == iRecordableService.evStart: print "RecordTimer.staticGotRecordEvent(iRecordableService.evStart)" @staticmethod def stopTryQuitMainloop(): print "RecordTimer.stopTryQuitMainloop" NavigationInstance.instance.record_event.remove(RecordTimerEntry.staticGotRecordEvent) RecordTimerEntry.receiveRecordEvents = False @staticmethod def TryQuitMainloop(): if not RecordTimerEntry.receiveRecordEvents and Screens.Standby.inStandby: print "RecordTimer.TryQuitMainloop" NavigationInstance.instance.record_event.append(RecordTimerEntry.staticGotRecordEvent) RecordTimerEntry.receiveRecordEvents = True # send fake event.. to check if another recordings are running or # other timers start in a few seconds RecordTimerEntry.staticGotRecordEvent(None, iRecordableService.evEnd) ################################################################# def __init__(self, serviceref, begin, end, name, description, eit, disabled = False, justplay = False, afterEvent = AFTEREVENT.AUTO, checkOldTimers = False, dirname = None, tags = None, descramble = True, record_ecm = False, isAutoTimer = False, always_zap = False, zap_wakeup = "always", rename_repeat = True): timer.TimerEntry.__init__(self, int(begin), int(end)) if checkOldTimers == True: if self.begin < time() - 1209600: self.begin = int(time()) if self.end < self.begin: self.end = self.begin assert isinstance(serviceref, ServiceReference) if serviceref and serviceref.isRecordable(): self.service_ref = serviceref else: self.service_ref = ServiceReference(None) self.eit = eit self.dontSave = False self.name = name self.description = description self.disabled = disabled self.timer = None self.__record_service = None self.start_prepare = 0 self.justplay = justplay self.always_zap = always_zap self.zap_wakeup = zap_wakeup self.afterEvent = afterEvent self.dirname = dirname self.dirnameHadToFallback = False self.autoincrease = False self.autoincreasetime = 3600 * 24 # 1 day self.tags = tags or [] self.descramble = descramble self.record_ecm = record_ecm self.rename_repeat = rename_repeat self.needChangePriorityFrontend = config.usage.recording_frontend_priority.value != "-2" and config.usage.recording_frontend_priority.value != config.usage.frontend_priority.value self.change_frontend = False self.isAutoTimer = isAutoTimer self.InfoBarInstance = Screens.InfoBar.InfoBar.instance self.ts_dialog = None self.log_entries = [] self.resetState() def __repr__(self): return "RecordTimerEntry(name=%s, begin=%s, serviceref=%s, justplay=%s, isAutoTimer=%s)" % (self.name, ctime(self.begin), self.service_ref, self.justplay, self.isAutoTimer) def log(self, code, msg): self.log_entries.append((int(time()), code, msg)) print "[TIMER]", msg def calculateFilename(self, name=None): service_name = self.service_ref.getServiceName() begin_date = strftime("%Y%m%d %H%M", localtime(self.begin)) name = name or self.name filename = begin_date + " - " + service_name if name: if config.recording.filename_composition.value == "short": filename = strftime("%Y%m%d", localtime(self.begin)) + " - " + name elif config.recording.filename_composition.value == "long": filename += " - " + name + " - " + self.description else: filename += " - " + name # standard if config.recording.ascii_filenames.value: filename = ASCIItranslit.legacyEncode(filename) if not self.dirname: dirname = findSafeRecordPath(defaultMoviePath()) else: dirname = findSafeRecordPath(self.dirname) if dirname is None: dirname = findSafeRecordPath(defaultMoviePath()) self.dirnameHadToFallback = True if not dirname: return None self.Filename = Directories.getRecordingFilename(filename, dirname) self.log(0, "Filename calculated as: '%s'" % self.Filename) return self.Filename def tryPrepare(self): if self.justplay: return True else: if not self.calculateFilename(): self.do_backoff() self.start_prepare = time() + self.backoff return False rec_ref = self.service_ref and self.service_ref.ref if rec_ref and rec_ref.flags & eServiceReference.isGroup: rec_ref = getBestPlayableServiceReference(rec_ref, eServiceReference()) if not rec_ref: self.log(1, "'get best playable service for group... record' failed") return False self.setRecordingPreferredTuner() self.record_service = rec_ref and NavigationInstance.instance.recordService(rec_ref) if not self.record_service: self.log(1, "'record service' failed") self.setRecordingPreferredTuner(setdefault=True) return False name = self.name description = self.description if self.repeated: epgcache = eEPGCache.getInstance() queryTime=self.begin+(self.end-self.begin)/2 evt = epgcache.lookupEventTime(rec_ref, queryTime) if evt: if self.rename_repeat: event_description = evt.getShortDescription() if not event_description: event_description = evt.getExtendedDescription() if event_description and event_description != description: description = event_description event_name = evt.getEventName() if event_name and event_name != name: name = event_name if not self.calculateFilename(event_name): self.do_backoff() self.start_prepare = time() + self.backoff return False event_id = evt.getEventId() else: event_id = -1 else: event_id = self.eit if event_id is None: event_id = -1 prep_res=self.record_service.prepare(self.Filename + self.record_service.getFilenameExtension(), self.begin, self.end, event_id, name.replace("\n", ""), description.replace("\n", ""), ' '.join(self.tags), bool(self.descramble), bool(self.record_ecm)) if prep_res: if prep_res == -255: self.log(4, "failed to write meta information") else: self.log(2, "'prepare' failed: error %d" % prep_res) # we must calc nur start time before stopRecordService call because in Screens/Standby.py TryQuitMainloop tries to get # the next start time in evEnd event handler... self.do_backoff() self.start_prepare = time() + self.backoff NavigationInstance.instance.stopRecordService(self.record_service) self.record_service = None self.setRecordingPreferredTuner(setdefault=True) return False return True def do_backoff(self): if self.backoff == 0: self.backoff = 5 else: self.backoff *= 2 if self.backoff > 100: self.backoff = 100 self.log(10, "backoff: retry in %d seconds" % self.backoff) def activate(self): next_state = self.state + 1 self.log(5, "activating state %d" % next_state) if next_state == 1: if self.always_zap: if Screens.Standby.inStandby: self.log(5, "wakeup and zap to recording service") RecordTimerEntry.setWasInStandby() #set service to zap after standby Screens.Standby.inStandby.prev_running_service = self.service_ref.ref Screens.Standby.inStandby.paused_service = None #wakeup standby Screens.Standby.inStandby.Power() else: if RecordTimerEntry.wasInDeepStandby: RecordTimerEntry.setWasInStandby() cur_zap_ref = NavigationInstance.instance.getCurrentlyPlayingServiceReference() if cur_zap_ref and not cur_zap_ref.getPath():# we do not zap away if it is no live service if self.checkingTimeshiftRunning(): if self.ts_dialog is None: self.openChoiceActionBeforeZap() else: Notifications.AddNotification(MessageBox, _("In order to record a timer, the TV was switched to the recording service!\n"), type=MessageBox.TYPE_INFO, timeout=20) self.setRecordingPreferredTuner() self.failureCB(True) self.log(5, "zap to recording service") if next_state == self.StatePrepared: if self.tryPrepare(): self.log(6, "prepare ok, waiting for begin") # create file to "reserve" the filename # because another recording at the same time on another service can try to record the same event # i.e. cable / sat.. then the second recording needs an own extension... when we create the file # here than calculateFilename is happy if not self.justplay: open(self.Filename + self.record_service.getFilenameExtension(), "w").close() # Give the Trashcan a chance to clean up try: Trashcan.instance.cleanIfIdle(self.Filename) except Exception, e: print "[TIMER] Failed to call Trashcan.instance.cleanIfIdle()" print "[TIMER] Error:", e # fine. it worked, resources are allocated. self.next_activation = self.begin self.backoff = 0 return True self.log(7, "prepare failed") if self.first_try_prepare or (self.ts_dialog is not None and not self.checkingTimeshiftRunning()): self.first_try_prepare = False cur_ref = NavigationInstance.instance.getCurrentlyPlayingServiceReference() if cur_ref and not cur_ref.getPath(): if self.always_zap: return False if Screens.Standby.inStandby: self.setRecordingPreferredTuner() self.failureCB(True) elif self.checkingTimeshiftRunning(): if self.ts_dialog is None: self.openChoiceActionBeforeZap() elif not config.recording.asktozap.value: self.log(8, "asking user to zap away") Notifications.AddNotificationWithCallback(self.failureCB, MessageBox, _("A timer failed to record!\nDisable TV and try again?\n"), timeout=20, default=True) else: # zap without asking self.log(9, "zap without asking") Notifications.AddNotification(MessageBox, _("In order to record a timer, the TV was switched to the recording service!\n"), type=MessageBox.TYPE_INFO, timeout=20) self.setRecordingPreferredTuner() self.failureCB(True) elif cur_ref: self.log(8, "currently running service is not a live service.. so stop it makes no sense") else: self.log(8, "currently no service running... so we dont need to stop it") return False elif next_state == self.StateRunning: # if this timer has been cancelled, just go to "end" state. if self.cancelled: return True if self.justplay: if Screens.Standby.inStandby: if RecordTimerEntry.wasInDeepStandby and self.zap_wakeup in ("always", "from_deep_standby") or self.zap_wakeup in ("always", "from_standby"): self.log(11, "wakeup and zap") RecordTimerEntry.setWasInStandby() #set service to zap after standby Screens.Standby.inStandby.prev_running_service = self.service_ref.ref Screens.Standby.inStandby.paused_service = None #wakeup standby Screens.Standby.inStandby.Power() else: if RecordTimerEntry.wasInDeepStandby: RecordTimerEntry.setWasInStandby() if self.checkingTimeshiftRunning(): if self.ts_dialog is None: self.openChoiceActionBeforeZap() else: self.log(11, "zapping") NavigationInstance.instance.playService(self.service_ref.ref) return True else: self.log(11, "start recording") if RecordTimerEntry.wasInDeepStandby: RecordTimerEntry.keypress() if Screens.Standby.inStandby: #In case some plugin did put the receiver already in standby config.misc.standbyCounter.value = 0 else: Notifications.AddNotification(Screens.Standby.Standby, StandbyCounterIncrease=False) record_res = self.record_service.start() self.setRecordingPreferredTuner(setdefault=True) if record_res: self.log(13, "start record returned %d" % record_res) self.do_backoff() # retry self.begin = time() + self.backoff return False # Tell the trashcan we started recording. The trashcan gets events, # but cannot tell what the associated path is. Trashcan.instance.markDirty(self.Filename) return True
def sendTryQuitMainloopNotification(self, answer): RecordTimerEntry.keypress() if answer: Notifications.AddNotification(Screens.Standby.TryQuitMainloop, 1)
def ImportChannelsDone(self, flag, message=None): shutil.rmtree(self.tmp_dir, True) if flag: Notifications.AddNotificationWithID("ChannelsImportOK", MessageBox, _("%s imported from fallback tuner") % message, type=MessageBox.TYPE_INFO, timeout=5) else: Notifications.AddNotificationWithID("ChannelsImportNOK", MessageBox, _("Import from fallback tuner failed, %s") % message, type=MessageBox.TYPE_ERROR, timeout=5)
def activate(self): global RSsave, RBsave, DSsave, aeDSsave, wasTimerWakeup breakPT = shiftPT = False now = time() next_state = self.state + 1 self.log(5, "activating state %d" % next_state) if next_state == self.StatePrepared and (self.timerType == TIMERTYPE.AUTOSTANDBY or self.timerType == TIMERTYPE.AUTODEEPSTANDBY): if self.autosleepwindow == 'yes': ltm = localtime(now) asb = strftime("%H:%M", localtime(self.autosleepbegin)).split(':') ase = strftime("%H:%M", localtime(self.autosleepend)).split(':') self.autosleepbegin = int(mktime(datetime(ltm.tm_year, ltm.tm_mon, ltm.tm_mday, int(asb[0]), int(asb[1])).timetuple())) self.autosleepend = int(mktime(datetime(ltm.tm_year, ltm.tm_mon, ltm.tm_mday, int(ase[0]), int(ase[1])).timetuple())) if self.autosleepend <= self.autosleepbegin: self.autosleepbegin -= 86400 if self.getAutoSleepWindow(): self.begin = self.end = int(now) + int(self.autosleepdelay)*60 eActionMap.getInstance().bindAction('', -0x7FFFFFFF, self.keyPressed) if (next_state == self.StateRunning or next_state == self.StateEnded) and NavigationInstance.instance.PowerTimer is None: #TODO: running/ended timer at system start has no nav instance #First fix: crash in getPriorityCheck (NavigationInstance.instance.PowerTimer...) #Second fix: suppress the message (A finished powertimer wants to ...) if debug: print "*****NavigationInstance.instance.PowerTimer is None*****", self.timerType, self.state, ctime(self.begin), ctime(self.end) return True elif next_state == self.StateRunning and abs(self.begin - now) >= 60: return True elif next_state == self.StateEnded and abs(self.end - now) >= 60: return True if next_state == self.StatePrepared: self.log(6, "prepare ok, waiting for begin") if self.begin <= now: self.next_activation = int(now) + 20 else: self.next_activation = self.begin self.backoff = 0 return True elif next_state == self.StateRunning: if os.path.exists("/tmp/was_powertimer_wakeup") and not wasTimerWakeup: wasTimerWakeup = int(open("/tmp/was_powertimer_wakeup", "r").read()) and True or False elif os.path.exists("/tmp/was_rectimer_wakeup") and not wasTimerWakeup: wasTimerWakeup = int(open("/tmp/was_rectimer_wakeup", "r").read()) and True or False # if this timer has been cancelled, just go to "end" state. if self.cancelled: return True if self.failed: return True if self.timerType == TIMERTYPE.NONE: return True elif self.timerType == TIMERTYPE.WAKEUP: if Screens.Standby.inStandby: Screens.Standby.inStandby.Power() return True elif self.timerType == TIMERTYPE.WAKEUPTOSTANDBY: return True elif self.timerType == TIMERTYPE.STANDBY: if debug: print "self.timerType == TIMERTYPE.STANDBY:" prioPT = [TIMERTYPE.WAKEUP,TIMERTYPE.RESTART,TIMERTYPE.REBOOT,TIMERTYPE.DEEPSTANDBY] prioPTae = [AFTEREVENT.WAKEUP,AFTEREVENT.DEEPSTANDBY] shiftPT,breakPT = self.getPriorityCheck(prioPT,prioPTae) if not Screens.Standby.inStandby and not breakPT: # not already in standby Notifications.AddNotificationWithCallback(self.sendStandbyNotification, MessageBox, _("A finished powertimer wants to set your\n%s %s to standby. Do that now?") % (getMachineBrand(), getMachineName()), timeout = 180) return True elif self.timerType == TIMERTYPE.AUTOSTANDBY: if debug: print "self.timerType == TIMERTYPE.AUTOSTANDBY:" if not self.getAutoSleepWindow(): return False if not Screens.Standby.inStandby: # not already in standby Notifications.AddNotificationWithCallback(self.sendStandbyNotification, MessageBox, _("A finished powertimer wants to set your\n%s %s to standby. Do that now?") % (getMachineBrand(), getMachineName()), timeout = 180) if self.autosleeprepeat == "once": eActionMap.getInstance().unbindAction('', self.keyPressed) return True else: self.begin = self.end = int(now) + int(self.autosleepdelay)*60 else: self.begin = self.end = int(now) + int(self.autosleepdelay)*60 elif self.timerType == TIMERTYPE.AUTODEEPSTANDBY: if debug: print "self.timerType == TIMERTYPE.AUTODEEPSTANDBY:" if not self.getAutoSleepWindow(): return False if self.getNetworkTraffic() or NavigationInstance.instance.PowerTimer.isProcessing() or abs(NavigationInstance.instance.PowerTimer.getNextPowerManagerTime() - now) <= 900 \ or NavigationInstance.instance.RecordTimer.isRecording() or abs(NavigationInstance.instance.RecordTimer.getNextRecordingTime() - now) <= 900 or abs(NavigationInstance.instance.RecordTimer.getNextZapTime() - now) <= 900 \ or ((self.autosleepinstandbyonly == 'yesACnetwork' or self.autosleepinstandbyonly == 'yes') and not Screens.Standby.inStandby): self.do_backoff() # retry self.begin = self.end = int(now) + self.backoff return False elif not Screens.Standby.inTryQuitMainloop: # not a shutdown messagebox is open if self.autosleeprepeat == "once": self.disabled = True if Screens.Standby.inStandby: # in standby print "[PowerTimer] quitMainloop #1" quitMainloop(1) return True else: Notifications.AddNotificationWithCallback(self.sendTryQuitMainloopNotification, MessageBox, _("A finished powertimer wants to shutdown your %s %s.\nDo that now?") % (getMachineBrand(), getMachineName()), timeout = 180) if self.autosleeprepeat == "once": eActionMap.getInstance().unbindAction('', self.keyPressed) return True else: self.begin = self.end = int(now) + int(self.autosleepdelay)*60 elif self.timerType == TIMERTYPE.RESTART: if debug: print "self.timerType == TIMERTYPE.RESTART:" #check priority prioPT = [TIMERTYPE.RESTART,TIMERTYPE.REBOOT,TIMERTYPE.DEEPSTANDBY] prioPTae = [AFTEREVENT.DEEPSTANDBY] shiftPT,breakPT = self.getPriorityCheck(prioPT,prioPTae) #a timer with higher priority was shifted - no execution of current timer if RBsave or aeDSsave or DSsave: if debug: print "break#1" breakPT = True #a timer with lower priority was shifted - shift now current timer and wait for restore the saved time values from other timer if False: if debug: print "shift#1" breakPT = False shiftPT = True #shift or break if shiftPT or breakPT \ or NavigationInstance.instance.RecordTimer.isRecording() or abs(NavigationInstance.instance.RecordTimer.getNextRecordingTime() - now) <= 900 or abs(NavigationInstance.instance.RecordTimer.getNextZapTime() - now) <= 900: if self.repeated and not RSsave: self.savebegin = self.begin self.saveend = self.end RSsave = True if not breakPT: self.do_backoff() #check difference begin to end before shift begin time if RSsave and self.end - self.begin > 3 and self.end - now - self.backoff <= 240: breakPT = True #breakPT if breakPT: if self.repeated and RSsave: try: self.begin = self.savebegin self.end = self.saveend except: pass RSsave = False return True # retry oldbegin = self.begin self.begin = int(now) + self.backoff if abs(self.end - oldbegin) <= 3: self.end = self.begin else: if not self.repeated and self.end < self.begin + 300: self.end = self.begin + 300 return False elif not Screens.Standby.inTryQuitMainloop: # not a shutdown messagebox is open if self.repeated and RSsave: try: self.begin = self.savebegin self.end = self.saveend except: pass if Screens.Standby.inStandby: # in standby print "[PowerTimer] quitMainloop #4" quitMainloop(3) else: Notifications.AddNotificationWithCallback(self.sendTryToRestartNotification, MessageBox, _("A finished powertimer wants to restart the user interface.\nDo that now?"), timeout = 180) RSsave = False return True elif self.timerType == TIMERTYPE.REBOOT: if debug: print "self.timerType == TIMERTYPE.REBOOT:" #check priority prioPT = [TIMERTYPE.REBOOT,TIMERTYPE.DEEPSTANDBY] prioPTae = [AFTEREVENT.DEEPSTANDBY] shiftPT,breakPT = self.getPriorityCheck(prioPT,prioPTae) #a timer with higher priority was shifted - no execution of current timer if aeDSsave or DSsave: if debug: print "break#1" breakPT = True #a timer with lower priority was shifted - shift now current timer and wait for restore the saved time values from other timer if RSsave: if debug: print "shift#1" breakPT = False shiftPT = True #shift or break if shiftPT or breakPT \ or NavigationInstance.instance.RecordTimer.isRecording() or abs(NavigationInstance.instance.RecordTimer.getNextRecordingTime() - now) <= 900 or abs(NavigationInstance.instance.RecordTimer.getNextZapTime() - now) <= 900: if self.repeated and not RBsave: self.savebegin = self.begin self.saveend = self.end RBsave = True if not breakPT: self.do_backoff() #check difference begin to end before shift begin time if RBsave and self.end - self.begin > 3 and self.end - now - self.backoff <= 240: breakPT = True #breakPT if breakPT: if self.repeated and RBsave: try: self.begin = self.savebegin self.end = self.saveend except: pass RBsave = False return True # retry oldbegin = self.begin self.begin = int(now) + self.backoff if abs(self.end - oldbegin) <= 3: self.end = self.begin else: if not self.repeated and self.end < self.begin + 300: self.end = self.begin + 300 return False elif not Screens.Standby.inTryQuitMainloop: # not a shutdown messagebox is open if self.repeated and RBsave: try: self.begin = self.savebegin self.end = self.saveend except: pass if Screens.Standby.inStandby: # in standby print "[PowerTimer] quitMainloop #3" quitMainloop(2) else: Notifications.AddNotificationWithCallback(self.sendTryToRebootNotification, MessageBox, _("A finished powertimer wants to reboot your %s %s.\nDo that now?") % (getMachineBrand(), getMachineName()), timeout = 180) RBsave = False return True elif self.timerType == TIMERTYPE.DEEPSTANDBY: if debug: print "self.timerType == TIMERTYPE.DEEPSTANDBY:" #check priority prioPT = [TIMERTYPE.WAKEUP,TIMERTYPE.WAKEUPTOSTANDBY,TIMERTYPE.DEEPSTANDBY] prioPTae = [AFTEREVENT.WAKEUP,AFTEREVENT.WAKEUPTOSTANDBY,AFTEREVENT.DEEPSTANDBY] shiftPT,breakPT = self.getPriorityCheck(prioPT,prioPTae) #a timer with higher priority was shifted - no execution of current timer if False: if debug: print "break#1" breakPT = True #a timer with lower priority was shifted - shift now current timer and wait for restore the saved time values from other timer if RSsave or RBsave or aeDSsave: if debug: print "shift#1" breakPT = False shiftPT = True #shift or break if shiftPT or breakPT \ or NavigationInstance.instance.RecordTimer.isRecording() or abs(NavigationInstance.instance.RecordTimer.getNextRecordingTime() - now) <= 900 or abs(NavigationInstance.instance.RecordTimer.getNextZapTime() - now) <= 900: if self.repeated and not DSsave: self.savebegin = self.begin self.saveend = self.end DSsave = True if not breakPT: self.do_backoff() #check difference begin to end before shift begin time if DSsave and self.end - self.begin > 3 and self.end - now - self.backoff <= 240: breakPT = True #breakPT if breakPT: if self.repeated and DSsave: try: self.begin = self.savebegin self.end = self.saveend except: pass DSsave = False return True # retry oldbegin = self.begin self.begin = int(now) + self.backoff if abs(self.end - oldbegin) <= 3: self.end = self.begin else: if not self.repeated and self.end < self.begin + 300: self.end = self.begin + 300 return False elif not Screens.Standby.inTryQuitMainloop: # not a shutdown messagebox is open if self.repeated and DSsave: try: self.begin = self.savebegin self.end = self.saveend except: pass if Screens.Standby.inStandby: # in standby print "[PowerTimer] quitMainloop #2" quitMainloop(1) else: Notifications.AddNotificationWithCallback(self.sendTryQuitMainloopNotification, MessageBox, _("A finished powertimer wants to shutdown your %s %s.\nDo that now?") % (getMachineBrand(), getMachineName()), timeout = 180) DSsave = False return True elif next_state == self.StateEnded: if self.afterEvent == AFTEREVENT.WAKEUP: if Screens.Standby.inStandby: Screens.Standby.inStandby.Power() elif self.afterEvent == AFTEREVENT.STANDBY: if not Screens.Standby.inStandby: # not already in standby Notifications.AddNotificationWithCallback(self.sendStandbyNotification, MessageBox, _("A finished powertimer wants to set your\n%s %s to standby. Do that now?") % (getMachineBrand(), getMachineName()), timeout = 180) elif self.afterEvent == AFTEREVENT.DEEPSTANDBY: if debug: print "self.afterEvent == AFTEREVENT.DEEPSTANDBY:" #check priority prioPT = [TIMERTYPE.WAKEUP,TIMERTYPE.WAKEUPTOSTANDBY,TIMERTYPE.DEEPSTANDBY] prioPTae = [AFTEREVENT.WAKEUP,AFTEREVENT.WAKEUPTOSTANDBY,AFTEREVENT.DEEPSTANDBY] shiftPT,breakPT = self.getPriorityCheck(prioPT,prioPTae) #a timer with higher priority was shifted - no execution of current timer if DSsave: if debug: print "break#1" breakPT = True #a timer with lower priority was shifted - shift now current timer and wait for restore the saved time values if RSsave or RBsave: if debug: print "shift#1" breakPT = False shiftPT = True #shift or break runningPT = False #option: check other powertimer is running (current disabled) #runningPT = NavigationInstance.instance.PowerTimer.isProcessing(exceptTimer = TIMERTYPE.NONE, endedTimer = self.timerType) if shiftPT or breakPT or runningPT \ or NavigationInstance.instance.RecordTimer.isRecording() or abs(NavigationInstance.instance.RecordTimer.getNextRecordingTime() - now) <= 900 or abs(NavigationInstance.instance.RecordTimer.getNextZapTime() - now) <= 900: if self.repeated and not aeDSsave: self.savebegin = self.begin self.saveend = self.end aeDSsave = True if not breakPT: self.do_backoff() #breakPT if breakPT: if self.repeated and aeDSsave: try: self.begin = self.savebegin self.end = self.saveend except: pass aeDSsave = False return True # retry self.end = int(now) + self.backoff return False elif not Screens.Standby.inTryQuitMainloop: # not a shutdown messagebox is open if self.repeated and aeDSsave: try: self.begin = self.savebegin self.end = self.saveend except: pass if Screens.Standby.inStandby: # in standby print "[PowerTimer] quitMainloop #5" quitMainloop(1) else: Notifications.AddNotificationWithCallback(self.sendTryQuitMainloopNotification, MessageBox, _("A finished powertimer wants to shutdown your %s %s.\nDo that now?") % (getMachineBrand(), getMachineName()), timeout = 180) aeDSsave = False NavigationInstance.instance.PowerTimer.saveTimer() return True
def playerClosed(self): if self.job.menupreview: self.closedCB(True) else: from Tools import Notifications Notifications.AddNotificationWithCallback(self.closedCB, MessageBox, _("Do you want to burn this collection to DVD medium?") )
class PowerTimerEntry(timer.TimerEntry, object): 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 def __repr__(self): timertype = { TIMERTYPE.NONE: "nothing", TIMERTYPE.WAKEUP: "wakeup", TIMERTYPE.WAKEUPTOSTANDBY: "wakeuptostandby", TIMERTYPE.AUTOSTANDBY: "autostandby", TIMERTYPE.AUTODEEPSTANDBY: "autodeepstandby", TIMERTYPE.STANDBY: "standby", TIMERTYPE.DEEPSTANDBY: "deepstandby", TIMERTYPE.REBOOT: "reboot", TIMERTYPE.RESTART: "restart" }[self.timerType] if not self.disabled: return "PowerTimerEntry(type=%s, begin=%s)" % (timertype, ctime(self.begin)) else: return "PowerTimerEntry(type=%s, begin=%s Disabled)" % (timertype, ctime(self.begin)) def log(self, code, msg): self.log_entries.append((int(time()), code, msg)) def do_backoff(self): if Screens.Standby.inStandby and not wasTimerWakeup or RSsave or RBsave or aeDSsave or DSsave: self.backoff = 300 else: if self.backoff == 0: self.backoff = 300 else: self.backoff += 300 if self.backoff > 900: self.backoff = 900 self.log(10, "backoff: retry in %d minutes" % (int(self.backoff)/60)) def activate(self): global RSsave, RBsave, DSsave, aeDSsave, wasTimerWakeup, InfoBar if not InfoBar: try: from Screens.InfoBar import InfoBar except Exception, e: print "[PowerTimer] import from 'Screens.InfoBar import InfoBar' failed:", e isRecTimerWakeup = breakPT = shiftPT = False now = time() next_state = self.state + 1 self.log(5, "activating state %d" % next_state) if next_state == self.StatePrepared and (self.timerType == TIMERTYPE.AUTOSTANDBY or self.timerType == TIMERTYPE.AUTODEEPSTANDBY): eActionMap.getInstance().bindAction('', -0x7FFFFFFF, self.keyPressed) if self.autosleepwindow == 'yes': ltm = localtime(now) asb = strftime("%H:%M", localtime(self.autosleepbegin)).split(':') ase = strftime("%H:%M", localtime(self.autosleepend)).split(':') self.autosleepbegin = int(mktime(datetime(ltm.tm_year, ltm.tm_mon, ltm.tm_mday, int(asb[0]), int(asb[1])).timetuple())) self.autosleepend = int(mktime(datetime(ltm.tm_year, ltm.tm_mon, ltm.tm_mday, int(ase[0]), int(ase[1])).timetuple())) if self.autosleepend <= self.autosleepbegin: self.autosleepbegin -= 86400 if self.getAutoSleepWindow(): if now < self.autosleepbegin and now > self.autosleepbegin - self.prepare_time - 3: #begin is in prepare time window self.begin = self.end = self.autosleepbegin + int(self.autosleepdelay)*60 else: self.begin = self.end = int(now) + int(self.autosleepdelay)*60 else: return False if self.timerType == TIMERTYPE.AUTODEEPSTANDBY: self.getNetworkTraffic(getInitialValue = True) if (next_state == self.StateRunning or next_state == self.StateEnded) and NavigationInstance.instance.PowerTimer is None: #TODO: running/ended timer at system start has no nav instance #First fix: crash in getPriorityCheck (NavigationInstance.instance.PowerTimer...) #Second fix: suppress the message (A finished powertimer wants to ...) if debug: print "*****NavigationInstance.instance.PowerTimer is None*****", self.timerType, self.state, ctime(self.begin), ctime(self.end) return True elif next_state == self.StateRunning and abs(self.begin - now) > 900: return True elif next_state == self.StateEnded and abs(self.end - now) > 900: return True if next_state == self.StateRunning or next_state == self.StateEnded: if NavigationInstance.instance.isRecordTimerImageStandard: isRecTimerWakeup = NavigationInstance.instance.RecordTimer.isRecTimerWakeup() if isRecTimerWakeup: wasTimerWakeup = True elif os.path.exists("/tmp/was_powertimer_wakeup") and not wasTimerWakeup: wasTimerWakeup = int(open("/tmp/was_powertimer_wakeup", "r").read()) and True or False if next_state == self.StatePrepared: self.log(6, "prepare ok, waiting for begin: %s" % ctime(self.begin)) self.backoff = 0 return True elif next_state == self.StateRunning: # if this timer has been cancelled, just go to "end" state. if self.cancelled: return True if self.failed: return True if self.timerType == TIMERTYPE.NONE: return True elif self.timerType == TIMERTYPE.WAKEUP: if debug: print "self.timerType == TIMERTYPE.WAKEUP:" if Screens.Standby.inStandby: Screens.Standby.inStandby.Power() return True elif self.timerType == TIMERTYPE.WAKEUPTOSTANDBY: if debug: print "self.timerType == TIMERTYPE.WAKEUPTOSTANDBY:" return True elif self.timerType == TIMERTYPE.STANDBY: if debug: print "self.timerType == TIMERTYPE.STANDBY:" prioPT = [TIMERTYPE.WAKEUP,TIMERTYPE.RESTART,TIMERTYPE.REBOOT,TIMERTYPE.DEEPSTANDBY] prioPTae = [AFTEREVENT.WAKEUP,AFTEREVENT.DEEPSTANDBY] shiftPT,breakPT = self.getPriorityCheck(prioPT,prioPTae) if not Screens.Standby.inStandby and not breakPT: # not already in standby callback = self.sendStandbyNotification message = _("A finished powertimer wants to set your\n%s %s to standby. Do that now?") % (getMachineBrand(), getMachineName()) messageboxtyp = MessageBox.TYPE_YESNO timeout = 180 default = True if InfoBar and InfoBar.instance: InfoBar.instance.openInfoBarMessageWithCallback(callback, message, messageboxtyp, timeout, default) else: Notifications.AddNotificationWithCallback(callback, MessageBox, message, messageboxtyp, timeout = timeout, default = default) return True elif self.timerType == TIMERTYPE.AUTOSTANDBY: if debug: print "self.timerType == TIMERTYPE.AUTOSTANDBY:" if not self.getAutoSleepWindow(): return False if not Screens.Standby.inStandby and not self.messageBoxAnswerPending: # not already in standby self.messageBoxAnswerPending = True callback = self.sendStandbyNotification message = _("A finished powertimer wants to set your\n%s %s to standby. Do that now?") % (getMachineBrand(), getMachineName()) messageboxtyp = MessageBox.TYPE_YESNO timeout = 180 default = True if InfoBar and InfoBar.instance: InfoBar.instance.openInfoBarMessageWithCallback(callback, message, messageboxtyp, timeout, default) else: Notifications.AddNotificationWithCallback(callback, MessageBox, message, messageboxtyp, timeout = timeout, default = default) if self.autosleeprepeat == "once": eActionMap.getInstance().unbindAction('', self.keyPressed) return True else: self.begin = self.end = int(now) + int(self.autosleepdelay)*60 else: self.begin = self.end = int(now) + int(self.autosleepdelay)*60 elif self.timerType == TIMERTYPE.AUTODEEPSTANDBY: if debug: print "self.timerType == TIMERTYPE.AUTODEEPSTANDBY:" if not self.getAutoSleepWindow(): return False if isRecTimerWakeup or (self.autosleepinstandbyonly == 'yes' and not Screens.Standby.inStandby) \ or NavigationInstance.instance.PowerTimer.isProcessing() or abs(NavigationInstance.instance.PowerTimer.getNextPowerManagerTime() - now) <= 900 or self.getNetworkAdress() or self.getNetworkTraffic() \ or NavigationInstance.instance.RecordTimer.isRecording() or abs(NavigationInstance.instance.RecordTimer.getNextRecordingTime() - now) <= 900 or abs(NavigationInstance.instance.RecordTimer.getNextZapTime() - now) <= 900: self.do_backoff() # retry self.begin = self.end = int(now) + self.backoff return False elif not Screens.Standby.inTryQuitMainloop: # not a shutdown messagebox is open if self.autosleeprepeat == "once": self.disabled = True if Screens.Standby.inStandby or self.autosleepinstandbyonly == 'noquery': # in standby or option 'without query' is enabled print "[PowerTimer] quitMainloop #1" quitMainloop(1) return True elif not self.messageBoxAnswerPending: self.messageBoxAnswerPending = True callback = self.sendTryQuitMainloopNotification message = _("A finished powertimer wants to shutdown your %s %s.\nDo that now?") % (getMachineBrand(), getMachineName()) messageboxtyp = MessageBox.TYPE_YESNO timeout = 180 default = True if InfoBar and InfoBar.instance: InfoBar.instance.openInfoBarMessageWithCallback(callback, message, messageboxtyp, timeout, default) else: Notifications.AddNotificationWithCallback(callback, MessageBox, message, messageboxtyp, timeout = timeout, default = default) if self.autosleeprepeat == "once": eActionMap.getInstance().unbindAction('', self.keyPressed) return True self.begin = self.end = int(now) + int(self.autosleepdelay)*60 elif self.timerType == TIMERTYPE.RESTART: if debug: print "self.timerType == TIMERTYPE.RESTART:" #check priority prioPT = [TIMERTYPE.RESTART,TIMERTYPE.REBOOT,TIMERTYPE.DEEPSTANDBY] prioPTae = [AFTEREVENT.DEEPSTANDBY] shiftPT,breakPT = self.getPriorityCheck(prioPT,prioPTae) #a timer with higher priority was shifted - no execution of current timer if RBsave or aeDSsave or DSsave: if debug: print "break#1" breakPT = True #a timer with lower priority was shifted - shift now current timer and wait for restore the saved time values from other timer if False: if debug: print "shift#1" breakPT = False shiftPT = True #shift or break if isRecTimerWakeup or shiftPT or breakPT \ or NavigationInstance.instance.RecordTimer.isRecording() or abs(NavigationInstance.instance.RecordTimer.getNextRecordingTime() - now) <= 900 or abs(NavigationInstance.instance.RecordTimer.getNextZapTime() - now) <= 900: if self.repeated and not RSsave: self.savebegin = self.begin self.saveend = self.end RSsave = True if not breakPT: self.do_backoff() #check difference begin to end before shift begin time if RSsave and self.end - self.begin > 3 and self.end - now - self.backoff <= 240: breakPT = True #breakPT if breakPT: if self.repeated and RSsave: try: self.begin = self.savebegin self.end = self.saveend except: pass RSsave = False return True # retry oldbegin = self.begin self.begin = int(now) + self.backoff if abs(self.end - oldbegin) <= 3: self.end = self.begin else: if not self.repeated and self.end < self.begin + 300: self.end = self.begin + 300 return False elif not Screens.Standby.inTryQuitMainloop: # not a shutdown messagebox is open if self.repeated and RSsave: try: self.begin = self.savebegin self.end = self.saveend except: pass if Screens.Standby.inStandby: # in standby print "[PowerTimer] quitMainloop #4" quitMainloop(3) else: callback = self.sendTryToRestartNotification message = _("A finished powertimer wants to restart the user interface.\nDo that now?") % (getMachineBrand(), getMachineName()) messageboxtyp = MessageBox.TYPE_YESNO timeout = 180 default = True if InfoBar and InfoBar.instance: InfoBar.instance.openInfoBarMessageWithCallback(callback, message, messageboxtyp, timeout, default) else: Notifications.AddNotificationWithCallback(callback, MessageBox, message, messageboxtyp, timeout = timeout, default = default) RSsave = False return True elif self.timerType == TIMERTYPE.REBOOT: if debug: print "self.timerType == TIMERTYPE.REBOOT:" #check priority prioPT = [TIMERTYPE.REBOOT,TIMERTYPE.DEEPSTANDBY] prioPTae = [AFTEREVENT.DEEPSTANDBY] shiftPT,breakPT = self.getPriorityCheck(prioPT,prioPTae) #a timer with higher priority was shifted - no execution of current timer if aeDSsave or DSsave: if debug: print "break#1" breakPT = True #a timer with lower priority was shifted - shift now current timer and wait for restore the saved time values from other timer if RSsave: if debug: print "shift#1" breakPT = False shiftPT = True #shift or break if isRecTimerWakeup or shiftPT or breakPT \ or NavigationInstance.instance.RecordTimer.isRecording() or abs(NavigationInstance.instance.RecordTimer.getNextRecordingTime() - now) <= 900 or abs(NavigationInstance.instance.RecordTimer.getNextZapTime() - now) <= 900: if self.repeated and not RBsave: self.savebegin = self.begin self.saveend = self.end RBsave = True if not breakPT: self.do_backoff() #check difference begin to end before shift begin time if RBsave and self.end - self.begin > 3 and self.end - now - self.backoff <= 240: breakPT = True #breakPT if breakPT: if self.repeated and RBsave: try: self.begin = self.savebegin self.end = self.saveend except: pass RBsave = False return True # retry oldbegin = self.begin self.begin = int(now) + self.backoff if abs(self.end - oldbegin) <= 3: self.end = self.begin else: if not self.repeated and self.end < self.begin + 300: self.end = self.begin + 300 return False elif not Screens.Standby.inTryQuitMainloop: # not a shutdown messagebox is open if self.repeated and RBsave: try: self.begin = self.savebegin self.end = self.saveend except: pass if Screens.Standby.inStandby: # in standby print "[PowerTimer] quitMainloop #3" quitMainloop(2) else: callback = self.sendTryToRebootNotification message = _("A finished powertimer wants to reboot your %s %s.\nDo that now?") % (getMachineBrand(), getMachineName()) messageboxtyp = MessageBox.TYPE_YESNO timeout = 180 default = True if InfoBar and InfoBar.instance: InfoBar.instance.openInfoBarMessageWithCallback(callback, message, messageboxtyp, timeout, default) else: Notifications.AddNotificationWithCallback(callback, MessageBox, message, messageboxtyp, timeout = timeout, default = default) RBsave = False return True elif self.timerType == TIMERTYPE.DEEPSTANDBY: if debug: print "self.timerType == TIMERTYPE.DEEPSTANDBY:" #check priority prioPT = [TIMERTYPE.WAKEUP,TIMERTYPE.WAKEUPTOSTANDBY,TIMERTYPE.DEEPSTANDBY] prioPTae = [AFTEREVENT.WAKEUP,AFTEREVENT.WAKEUPTOSTANDBY,AFTEREVENT.DEEPSTANDBY] shiftPT,breakPT = self.getPriorityCheck(prioPT,prioPTae) #a timer with higher priority was shifted - no execution of current timer if False: if debug: print "break#1" breakPT = True #a timer with lower priority was shifted - shift now current timer and wait for restore the saved time values from other timer if RSsave or RBsave or aeDSsave: if debug: print "shift#1" breakPT = False shiftPT = True #shift or break if isRecTimerWakeup or shiftPT or breakPT \ or NavigationInstance.instance.RecordTimer.isRecording() or abs(NavigationInstance.instance.RecordTimer.getNextRecordingTime() - now) <= 900 or abs(NavigationInstance.instance.RecordTimer.getNextZapTime() - now) <= 900: if self.repeated and not DSsave: self.savebegin = self.begin self.saveend = self.end DSsave = True if not breakPT: self.do_backoff() #check difference begin to end before shift begin time if DSsave and self.end - self.begin > 3 and self.end - now - self.backoff <= 240: breakPT = True #breakPT if breakPT: if self.repeated and DSsave: try: self.begin = self.savebegin self.end = self.saveend except: pass DSsave = False return True # retry oldbegin = self.begin self.begin = int(now) + self.backoff if abs(self.end - oldbegin) <= 3: self.end = self.begin else: if not self.repeated and self.end < self.begin + 300: self.end = self.begin + 300 return False elif not Screens.Standby.inTryQuitMainloop: # not a shutdown messagebox is open if self.repeated and DSsave: try: self.begin = self.savebegin self.end = self.saveend except: pass if Screens.Standby.inStandby: # in standby print "[PowerTimer] quitMainloop #2" quitMainloop(1) else: callback = self.sendTryQuitMainloopNotification message = _("A finished powertimer wants to shutdown your %s %s.\nDo that now?") % (getMachineBrand(), getMachineName()) messageboxtyp = MessageBox.TYPE_YESNO timeout = 180 default = True if InfoBar and InfoBar.instance: InfoBar.instance.openInfoBarMessageWithCallback(callback, message, messageboxtyp, timeout, default) else: Notifications.AddNotificationWithCallback(callback, MessageBox, message, messageboxtyp, timeout = timeout, default = default) DSsave = False return True elif next_state == self.StateEnded: if self.afterEvent == AFTEREVENT.WAKEUP: if Screens.Standby.inStandby: Screens.Standby.inStandby.Power() elif self.afterEvent == AFTEREVENT.STANDBY: if not Screens.Standby.inStandby: # not already in standby callback = self.sendStandbyNotification message = _("A finished powertimer wants to set your\n%s %s to standby. Do that now?") % (getMachineBrand(), getMachineName()) messageboxtyp = MessageBox.TYPE_YESNO timeout = 180 default = True if InfoBar and InfoBar.instance: InfoBar.instance.openInfoBarMessageWithCallback(callback, message, messageboxtyp, timeout, default) else: Notifications.AddNotificationWithCallback(callback, MessageBox, message, messageboxtyp, timeout = timeout, default = default) elif self.afterEvent == AFTEREVENT.DEEPSTANDBY: if debug: print "self.afterEvent == AFTEREVENT.DEEPSTANDBY:" #check priority prioPT = [TIMERTYPE.WAKEUP,TIMERTYPE.WAKEUPTOSTANDBY,TIMERTYPE.DEEPSTANDBY] prioPTae = [AFTEREVENT.WAKEUP,AFTEREVENT.WAKEUPTOSTANDBY,AFTEREVENT.DEEPSTANDBY] shiftPT,breakPT = self.getPriorityCheck(prioPT,prioPTae) #a timer with higher priority was shifted - no execution of current timer if DSsave: if debug: print "break#1" breakPT = True #a timer with lower priority was shifted - shift now current timer and wait for restore the saved time values if RSsave or RBsave: if debug: print "shift#1" breakPT = False shiftPT = True #shift or break runningPT = False #option: check other powertimer is running (current disabled) #runningPT = NavigationInstance.instance.PowerTimer.isProcessing(exceptTimer = TIMERTYPE.NONE, endedTimer = self.timerType) if isRecTimerWakeup or shiftPT or breakPT or runningPT \ or NavigationInstance.instance.RecordTimer.isRecording() or abs(NavigationInstance.instance.RecordTimer.getNextRecordingTime() - now) <= 900 or abs(NavigationInstance.instance.RecordTimer.getNextZapTime() - now) <= 900: if self.repeated and not aeDSsave: self.savebegin = self.begin self.saveend = self.end aeDSsave = True if not breakPT: self.do_backoff() #breakPT if breakPT: if self.repeated and aeDSsave: try: self.begin = self.savebegin self.end = self.saveend except: pass aeDSsave = False return True # retry self.end = int(now) + self.backoff return False elif not Screens.Standby.inTryQuitMainloop: # not a shutdown messagebox is open if self.repeated and aeDSsave: try: self.begin = self.savebegin self.end = self.saveend except: pass if Screens.Standby.inStandby: # in standby print "[PowerTimer] quitMainloop #5" quitMainloop(1) else: callback = self.sendTryQuitMainloopNotification message = _("A finished powertimer wants to shutdown your %s %s.\nDo that now?") % (getMachineBrand(), getMachineName()) messageboxtyp = MessageBox.TYPE_YESNO timeout = 180 default = True if InfoBar and InfoBar.instance: InfoBar.instance.openInfoBarMessageWithCallback(callback, message, messageboxtyp, timeout, default) else: Notifications.AddNotificationWithCallback(callback, MessageBox, message, messageboxtyp, timeout = timeout, default = default) aeDSsave = False NavigationInstance.instance.PowerTimer.saveTimer() resetTimerWakeup() return True
def sendTryQuitMainloopNotification(self, answer): if answer: Notifications.AddNotification(Screens.Standby.TryQuitMainloop, 1)
def gotostandby(self): if not Screens.Standby.inStandby: from Tools import Notifications print '[NAVIGATION] now entering standby' Notifications.AddNotification(Screens.Standby.Standby)
def gotostandby(self): from Tools import Notifications Notifications.AddNotification(Screens.Standby.Standby)
def activate(self): next_state = self.state + 1 self.log(5, "activating state %d" % next_state) if next_state == self.StatePrepared: if self.tryPrepare(): self.log(6, "prepare ok, waiting for begin") # create file to "reserve" the filename # because another recording at the same time on another service can try to record the same event # i.e. cable / sat.. then the second recording needs an own extension... when we create the file # here than calculateFilename is happy if not self.justplay: open(self.Filename + ".ts", "w").close() # fine. it worked, resources are allocated. self.next_activation = self.begin self.backoff = 0 return True self.log(7, "prepare failed") if self.first_try_prepare: self.first_try_prepare = False cur_ref = NavigationInstance.instance.getCurrentlyPlayingServiceReference( ) if cur_ref and not cur_ref.getPath(): if not config.recording.asktozap.value: self.log(8, "asking user to zap away") Notifications.AddNotificationWithCallback( self.failureCB, MessageBox, _("A timer failed to record!\nDisable TV and try again?\n" ), timeout=20) else: # zap without asking self.log(9, "zap without asking") Notifications.AddNotification( MessageBox, _("In order to record a timer, the TV was switched to the recording service!\n" ), type=MessageBox.TYPE_INFO, timeout=20) self.failureCB(True) elif cur_ref: self.log( 8, "currently running service is not a live service.. so stop it makes no sense" ) else: self.log( 8, "currently no service running... so we dont need to stop it" ) return False elif next_state == self.StateRunning: # if this timer has been cancelled, just go to "end" state. if self.cancelled: return True if self.justplay: if Screens.Standby.inStandby: self.log(11, "wakeup and zap") #set service to zap after standby Screens.Standby.inStandby.prev_running_service = self.service_ref.ref #wakeup standby Screens.Standby.inStandby.Power() else: self.log(11, "zapping") NavigationInstance.instance.playService( self.service_ref.ref) return True else: self.log(11, "start recording") record_res = self.record_service.start() if record_res: self.log(13, "start record returned %d" % record_res) self.do_backoff() # retry self.begin = time() + self.backoff return False return True elif next_state == self.StateEnded: old_end = self.end if self.setAutoincreaseEnd(): self.log( 12, "autoincrase recording %d minute(s)" % int( (self.end - old_end) / 60)) self.state -= 1 return True self.log(12, "stop recording") if not self.justplay: NavigationInstance.instance.stopRecordService( self.record_service) self.record_service = None if self.afterEvent == AFTEREVENT.STANDBY: if not Screens.Standby.inStandby: # not already in standby Notifications.AddNotificationWithCallback( self.sendStandbyNotification, MessageBox, _("A finished record timer wants to set your\nDreambox to standby. Do that now?" ), timeout=20) elif self.afterEvent == AFTEREVENT.DEEPSTANDBY: if not Screens.Standby.inTryQuitMainloop: # not a shutdown messagebox is open if Screens.Standby.inStandby: # in standby RecordTimerEntry.TryQuitMainloop( ) # start shutdown handling without screen else: Notifications.AddNotificationWithCallback( self.sendTryQuitMainloopNotification, MessageBox, _("A finished record timer wants to shut down\nyour Dreambox. Shutdown now?" ), timeout=20) # vvv Ensure shutdown after AUTO timer if no key has been pressed elif self.afterEvent == AFTEREVENT.AUTO: if not Screens.Standby.inTryQuitMainloop: # not a shutdown messagebox is open timerStart = open("/proc/stb/fp/was_timer_wakeup").read() if timerStart[:1] == "1": Notifications.AddNotificationWithCallback( self.sendTryQuitMainloopNotification, MessageBox, _("A finished record timer wants to shut down\nyour Dreambox. Shutdown now?" ), timeout=20) # ^^^ Ensure shutdown after AUTO timer if no key has been pressed return True
def doStandby(self): Notifications.AddNotification(Screens.Standby.Standby2)
def _autotimerErrback(self, failure): print("[EPGRefresh] Debug: AutoTimer failed:" + str(failure)) if config.plugins.epgrefresh.enablemessage.value: Notifications.AddPopup(_("AutoTimer failed with error %s") % (str(failure)), \ MessageBox.TYPE_ERROR, 10, domain = NOTIFICATIONDOMAIN) self._nextTodo()
def standby(self, answer): if answer is not None: if answer and not Screens.Standby.inStandby: Notifications.AddNotification(Screens.Standby.Standby)
def gotostandby(self): print '[NAVIGATION] TIMER: now entering standby' from Tools import Notifications Notifications.AddNotification(Screens.Standby.Standby)
def goStandby(self): Notifications.AddNotification(StandbyScreen, self.StandbyCounterIncrease)
def askForActivation(self): iTimeOut = config.plugins.KiddyTimer.activationDialogTimeout.getValue() Notifications.AddNotificationWithCallback( self.callbackAskForActivation, MessageBox, _("Do you want to start the kiddytimer- plugin now."), MessageBox.TYPE_YESNO, iTimeOut)
def displayPlayedName(self, ref, index, n): from Tools import Notifications Notifications.AddPopup(text=_("%s/%s: %s") % (index, n, self.ref2HumanName(ref)), type=MessageBox.TYPE_INFO, timeout=5)
def activate(self): next_state = self.state + 1 self.log(5, "activating state %d" % next_state) if next_state == 1: if self.always_zap: if Screens.Standby.inStandby: self.log(5, "wakeup and zap to recording service") RecordTimerEntry.setWasInStandby() #set service to zap after standby Screens.Standby.inStandby.prev_running_service = self.service_ref.ref Screens.Standby.inStandby.paused_service = None #wakeup standby Screens.Standby.inStandby.Power() else: if RecordTimerEntry.wasInDeepStandby: RecordTimerEntry.setWasInStandby() cur_zap_ref = NavigationInstance.instance.getCurrentlyPlayingServiceReference() if cur_zap_ref and not cur_zap_ref.getPath():# we do not zap away if it is no live service if self.checkingTimeshiftRunning(): if self.ts_dialog is None: self.openChoiceActionBeforeZap() else: Notifications.AddNotification(MessageBox, _("In order to record a timer, the TV was switched to the recording service!\n"), type=MessageBox.TYPE_INFO, timeout=20) self.setRecordingPreferredTuner() self.failureCB(True) self.log(5, "zap to recording service") if next_state == self.StatePrepared: if self.tryPrepare(): self.log(6, "prepare ok, waiting for begin") # create file to "reserve" the filename # because another recording at the same time on another service can try to record the same event # i.e. cable / sat.. then the second recording needs an own extension... when we create the file # here than calculateFilename is happy if not self.justplay: open(self.Filename + self.record_service.getFilenameExtension(), "w").close() # Give the Trashcan a chance to clean up try: Trashcan.instance.cleanIfIdle(self.Filename) except Exception, e: print "[TIMER] Failed to call Trashcan.instance.cleanIfIdle()" print "[TIMER] Error:", e # fine. it worked, resources are allocated. self.next_activation = self.begin self.backoff = 0 return True self.log(7, "prepare failed") if self.first_try_prepare or (self.ts_dialog is not None and not self.checkingTimeshiftRunning()): self.first_try_prepare = False cur_ref = NavigationInstance.instance.getCurrentlyPlayingServiceReference() if cur_ref and not cur_ref.getPath(): if self.always_zap: return False if Screens.Standby.inStandby: self.setRecordingPreferredTuner() self.failureCB(True) elif self.checkingTimeshiftRunning(): if self.ts_dialog is None: self.openChoiceActionBeforeZap() elif not config.recording.asktozap.value: self.log(8, "asking user to zap away") Notifications.AddNotificationWithCallback(self.failureCB, MessageBox, _("A timer failed to record!\nDisable TV and try again?\n"), timeout=20, default=True) else: # zap without asking self.log(9, "zap without asking") Notifications.AddNotification(MessageBox, _("In order to record a timer, the TV was switched to the recording service!\n"), type=MessageBox.TYPE_INFO, timeout=20) self.setRecordingPreferredTuner() self.failureCB(True) elif cur_ref: self.log(8, "currently running service is not a live service.. so stop it makes no sense") else: self.log(8, "currently no service running... so we dont need to stop it") return False