def endFallback(self, message=""): if message: message = "%s\n%s" % (self.message, str(message).translate( None, '[]').strip()) Notifications.AddNotificationWithID( "ChannelsImportNOK", MessageBox, _("Import from fallback tuner failed, %s") % message, MessageBox.TYPE_ERROR, timeout=5) else: message = { "channels": _("Channels"), "epg": _("EPG"), "channels_epg": _("Channels and EPG") }[config.usage.remote_fallback_import.value] Notifications.AddNotificationWithID( "ChannelsImportOK", MessageBox, _("%s imported from fallback tuner") % message, MessageBox.TYPE_INFO, timeout=5) if os.path.isdir(TMPDIR): os.rmdir(TMPDIR) Import.isRunning = False
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: message = {"channels": _("Channels"), "epg": _("EPG"), "channels_epg": _("Channels and EPG")}[config.usage.remote_fallback_import.value] Notifications.AddNotificationWithID("ChannelsImportOK", MessageBox, _("%s imported from fallback tuner") % message, MessageBox.TYPE_INFO, timeout=5) if os.path.isdir(TMPDIR): os.rmdir(TMPDIR) Import.isRunning = False
def ImportChannelsDone(self, flag, errorstring=None): if flag: Notifications.AddNotificationWithID( "ChannelsImportOK", MessageBox, _("Channels from fallback tuner imported"), type=MessageBox.TYPE_INFO, timeout=5) else: Notifications.AddNotificationWithID( "ChannelsImportNOK", MessageBox, _("Channels from fallback tuner failed %s") % errorstring, type=MessageBox.TYPE_ERROR, timeout=5)
def ImportChannelsDone(self, flag, message=None): 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 __init__(self, nextRecordTimerAfterEventActionAuto=False): from Screens.ChannelSelection import ChannelSelection 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.nav_event_conn = self.pnav.m_event.connect(self.dispatchEvent) self.nav_record_event_conn = self.pnav.m_record_event.connect(self.dispatchRecordEvent) self.event = [ ] self.record_event = [ ] self.currentlyPlayingServiceReference = None self.currentlyPlayingService = None self.immediatePlay = False self.RecordTimer = RecordTimer.RecordTimer() self.__wasTimerWakeup = False if getFPWasTimerWakeup(): clearFPWasTimerWakeup() if getFPWasTimerWakeup(): # sanity check to detect if the FP driver is working correct! print "buggy fp driver detected!!! please update drivers.... ignore timer wakeup!" else: self.__wasTimerWakeup = True if config.misc.prev_wakeup_time.value and config.misc.prev_wakeup_time_type.value == 0: if not Screens.Standby.inTryQuitMainloop: # not a shutdown messagebox is open Notifications.AddNotificationWithID("Standby", Screens.Standby.Standby, domain="RecordTimer") self.SleepTimer = SleepTimer.SleepTimer() self.scheduledServiceReference = None ChannelSelection.initialized.addNotifier(self.serviceListInitialized, initial_call = True)
def sendTryQuitMainloopNotification(self, answer): if answer: Notifications.AddNotificationWithID( "Shutdown", Screens.Standby.TryQuitMainloop, 1, domain=NOTIFICATIONDOMAIN)
def finish(self, *args, **kwargs): if self.showPendingServicesMessageShown: self.msg.close() print("[EPGRefresh] Debug: Refresh finished!") if config.plugins.epgrefresh.enablemessage.value: Notifications.AddPopup(_("EPG refresh finished."), MessageBox.TYPE_INFO, 4, ENDNOTIFICATIONID, domain = NOTIFICATIONDOMAIN) epgrefreshtimer.cleanup() self.maybeStopAdapter() if config.plugins.epgrefresh.epgsave.value: Notifications.AddPopup(_("EPG refresh save."), MessageBox.TYPE_INFO, 4, ENDNOTIFICATIONID, domain = NOTIFICATIONDOMAIN) from enigma import eEPGCache myEpg = None myEpg = eEPGCache.getInstance() myEpg.save() # shutdown if we're supposed to go to standby and not recording # forced scan --> manually started scan / non-forced scan --> automated scan # dontshutdownonabort overrides the shutdown if not self.forcedScan and config.plugins.epgrefresh.afterevent.value \ and not Screens.Standby.inTryQuitMainloop: if (not config.plugins.epgrefresh.dontshutdownonabort.value and self.doStopRunningRefresh) or not self.doStopRunningRefresh: self.forcedScan = False if Screens.Standby.inStandby: RecordTimerEntry.TryQuitMainloop() else: Notifications.AddNotificationWithID("Shutdown", Screens.Standby.TryQuitMainloop, 1, domain = NOTIFICATIONDOMAIN) # reset doStopRunningRefresh here instead of cleanUp as it is needed to avoid shutdown self.doStopRunningRefresh = False self.forcedScan = False self.isrunning = False self._nextTodo()
def finish(self, *args, **kwargs): if self.showPendingServicesMessageShown: self.msg.close() print("[EPGRefresh] Debug: Refresh finished!") if config.plugins.epgrefresh.enablemessage.value: Notifications.AddPopup(_("EPG refresh finished."), MessageBox.TYPE_INFO, 4, ENDNOTIFICATIONID, domain = NOTIFICATIONDOMAIN) epgrefreshtimer.cleanup() self.maybeStopAdapter() if config.plugins.epgrefresh.epgsave.value: Notifications.AddPopup(_("EPG refresh save."), MessageBox.TYPE_INFO, 4, ENDNOTIFICATIONID, domain = NOTIFICATIONDOMAIN) from enigma import eEPGCache myEpg = None myEpg = eEPGCache.getInstance() myEpg.save() # shutdown if we're supposed to go to deepstandby and not recording if not self.forcedScan and config.plugins.epgrefresh.afterevent.value \ and not Screens.Standby.inTryQuitMainloop: self.forcedScan = False if Screens.Standby.inStandby: RecordTimerEntry.TryQuitMainloop() else: Notifications.AddNotificationWithID("Shutdown", Screens.Standby.TryQuitMainloop, 1, domain = NOTIFICATIONDOMAIN) self.forcedScan = False self.isrunning = False self._nextTodo()
def DoElektroSleep(self, retval): config_NASenable = True if config.plugins.elektro.NASenable.value == config.plugins.elektro.profile.value else False if config.plugins.elektro.profileShift.value == True: config.plugins.elektro.profile.value = "1" if config.plugins.elektro.profile.value == "2" else "2" config.plugins.elektro.profile.save() self.setNextWakeuptime() if (retval): if not Standby.inTryQuitMainloop: if config.plugins.elektro.NASenable.value == "true" or config_NASenable: ret = NASpowerdown(config.plugins.elektro.NASname.value, config.plugins.elektro.NASuser.value, config.plugins.elektro.NASpass.value, config.plugins.elektro.NAScommand.value, config.plugins.elektro.NASport.value) configfile.save() if Standby.inStandby: RecordTimerEntry.TryQuitMainloop() else: Notifications.AddNotificationWithID( "Shutdown", Standby.TryQuitMainloop, 1) else: # Dont try to sleep until next wakeup self.dontsleep = True #Start the timer again self.TimerSleep.startLongTimer(elektrostarttime)
def sendTryQuitMainloopNotification(self, answer): if answer: Notifications.AddNotificationWithID( "Shutdown", Screens.Standby.TryQuitMainloop, 1, domain="JobManager")
def shutdown(self, answer): if answer is not None: if answer and not Screens.Standby.inTryQuitMainloop: Notifications.AddNotificationWithID( "Shutdown", Screens.Standby.TryQuitMainloop, 1, domain="SleepTimer")
def __init__(self, session): Screen.__init__(self, session) print pluginPrintname, "Starting up Version", elektro_pluginversion self.session = session # Make sure wakeup time is set. self.setNextWakeuptime() # If we didn't wake up by a timer we don't want to go to sleep any more. # Unforturnately it is not possible to use getFPWasTimerWakeup() # Therfore we're checking wheter there is a recording starting within # the next five min automatic_wakeup = self.session.nav.wasTimerWakeup( ) # woken by any timer elektro_wakeup = automatic_wakeup and config.plugins.elektro.deepstandby_wakeup_time.value == config.misc.prev_wakeup_time.value record_wakeup = automatic_wakeup and config.misc.prev_wakeup_time.value and config.misc.prev_wakeup_time_type.value == 0 self.dontsleep = False #Let's assume we got woken up manually timerWakeup = elektro_wakeup or record_wakeup # If the start was a manual wakeup: Don't go to sleep if timerWakeup == False: #check sleep after manual boot - Sven H if config.plugins.elektro.checkSleepAfterManualBoot.value == False: self.dontsleep = True print pluginPrintname, "check for sleep after manual boot on next sleeptime (after next wakeuptime)" else: print pluginPrintname, "check for sleep directly after manual boot" #Check whether we should try to sleep: trysleep = config.plugins.elektro.standbyOnBoot.value #Don't go to sleep when this was a manual wakeup and the box shouldn't go to standby if timerWakeup == False and config.plugins.elektro.standbyOnManualBoot.value == False: trysleep = False #if waken up by timer and configured ask whether to go to sleep. if trysleep: print pluginPrintname, "add standby notification" Notifications.AddNotificationWithID("Standby", Standby.Standby) self.TimerSleep = eTimer() self.TimerSleep_conn = self.TimerSleep.timeout.connect( self.CheckElektro) self.TimerSleep.startLongTimer(elektrostarttime) print pluginPrintname, "Start timer for sleep-check" if debug: print pluginPrintname, "Translation test:", _("Standby on boot") #set the last_nfsread-value self.last_nfsread = "0"
def __evStart(self): if self.__position and self.__firstStart: self.__firstStart = False Notifications.AddNotificationWithID(self.RESUME_POPUP_ID, MessageBox, _("Resuming playback"), timeout=0, type=MessageBox.TYPE_INFO, enable_input=True) self.__timer.start(500, True)
def delayedStandby(): if DBG: printDEBUG("[StartupToStandby] delayedStandby") global MyDelayTimer try: MyDelayTimer.stop() MyDelayTimer = None except Exception: pass if config.plugins.startuptostandby.enabled.value: if DBG: printDEBUG('is enabled') Notifications.AddNotificationWithID("goStandby", Screens.Standby.Standby) elif config.plugins.startuptostandby.WhenWasInStandbyOnly.value and os.path.exists( statusFile): if DBG: printDEBUG('WhenWasInStandbyOnly') Notifications.AddNotificationWithID("goStandby", Screens.Standby.Standby) # from autoshutdown session.open(Screens.Standby.Standby) else: if DBG: printDEBUG('not enabled or was not in standby before')
def doPowerOffAnswer(self, answer): dont_currentday = time() > self.poweroff_time if answer: if not Standby.inTryQuitMainloop: print "[PowerOffTimer] Goto auto shutdown box." if Standby.inStandby: RecordTimerEntry.TryQuitMainloop() else: Notifications.AddNotificationWithID("Shutdown", Standby.TryQuitMainloop, 1) self.powerStateTimerChanged(dont_currentday=dont_currentday) else: print "[PowerOffTimer] Shutdown canceled by the user (dont_currentday=%s)" % dont_currentday self.powerStateTimerChanged(dont_currentday=dont_currentday)
def MESG(self, data): if not data: payload = "%d parameter not implemented" % (CODE_IMP_PARAM, ) return self.sendLine(payload) Notifications.AddNotificationWithID( NOTIFICATIONID, MessageBox, text=data, type=MessageBox.TYPE_INFO, timeout=5, close_on_any_key=True, ) payload = "%d Message queued" % (CODE_OK, ) self.sendLine(payload)
def finish(self, *args, **kwargs): if not Screens.Standby.inStandby and not config.plugins.epgrefresh.background and config.plugins.epgrefresh.enablemessage.value: Notifications.AddPopup(_("EPG refresh finished."), MessageBox.TYPE_INFO, 4, NOTIFICATIONID) self.forcedScan = False epgrefreshtimer.cleanup() self.maybeStopAdapter() # shutdown if we're supposed to go to deepstandby and not recording if not self.forcedScan and config.plugins.epgrefresh.afterevent.value \ and not Screens.Standby.inTryQuitMainloop: if Screens.Standby.inStandby: self.session.open(Screens.Standby.TryQuitMainloop, 1) else: Notifications.AddNotificationWithID("Shutdown", Screens.Standby.TryQuitMainloop, 1)
def Scheduleautostart(reason, session=None, **kwargs): # # This gets called twice at start up,once by WHERE_AUTOSTART without session, # and once by WHERE_SESSIONSTART with session. WHERE_AUTOSTART is needed though # as it is used to wake from deep standby. We need to read from session so if # session is not set just return and wait for the second call to this function. # # Called with reason=1 during /sbin/shutdown.sysvinit, and with reason=0 at startup. # Called with reason=1 only happens when using WHERE_AUTOSTART. # If only using WHERE_SESSIONSTART there is no call to this function on shutdown. # schedulename = "ABM-Scheduler" configname = config.autobouquetsmaker print("[%s][Scheduleautostart] reason(%d), session" % (schedulename, reason), session, file=log) if reason == 0 and session is None: return global autoScheduleTimer global wasScheduleTimerWakeup wasScheduleTimerWakeup = False if reason == 0: # check if box was woken up by a timer, if so, check if this plugin set this timer. This is not conclusive. wasScheduleTimerWakeup = session.nav.wasTimerWakeup( ) and configname.schedule.value and configname.schedulewakefromdeep.value and abs( configname.nextscheduletime.value - time()) <= 450 if wasScheduleTimerWakeup: # if box is not in standby do it now from Screens.Standby import Standby, inStandby if not inStandby: # hack alert: session requires "pipshown" to avoid a crash in standby.py if not hasattr(session, "pipshown"): session.pipshown = False from Tools import Notifications Notifications.AddNotificationWithID("Standby", Standby) print("[%s][Scheduleautostart] AutoStart Enabled" % schedulename, file=log) if autoScheduleTimer is None: autoScheduleTimer = AutoScheduleTimer(session) else: print("[%s][Scheduleautostart] Stop" % schedulename, file=log) if autoScheduleTimer is not None: autoScheduleTimer.schedulestop()
def autostart(reason, **kwargs): if reason == 0 and "session" in kwargs: session = kwargs["session"] epgrefresh.session = session if config.plugins.epgrefresh.enabled.value: # check if box was woken up by a timer, if so, check if epgrefresh set this timer if session.nav.wasTimerWakeup() and config.misc.prev_wakeup_time.value == config.plugins.epgrefresh.wakeup_time.value: # if box is not in idle mode, do that from Screens.Standby import Standby, inStandby if not inStandby: from Tools import Notifications Notifications.AddNotificationWithID("Standby", Standby) epgrefresh.start() elif reason == 1: epgrefresh.stop()
def __init__(self, session): Screen.__init__(self, session) print pluginPrintname, "Starting up Version", elektro_pluginversion self.session = session # Make sure wakeup time is set. self.setNextWakeuptime() # If we didn't wake up by a timer we don't want to go to sleep any more. # Unforturnately it is not possible to use getFPWasTimerWakeup() # Therfore we're checking wheter there is a recording starting within # the next five min automatic_wakeup = self.session.nav.wasTimerWakeup( ) # woken by any timer self.dontsleep = False #Let's assume we got woken up manually timerWakeup = automatic_wakeup # If the was a manual wakeup: Don't go to sleep if timerWakeup == False: self.dontsleep = True #Check whether we should try to sleep: trysleep = config.plugins.elektro.standbyOnBoot.value #Don't go to sleep when this was a manual wakeup and the box shouldn't go to standby if timerWakeup == False and config.plugins.elektro.standbyOnManualBoot.value == False: trysleep = False #if waken up by timer and configured ask whether to go to sleep. if trysleep: print pluginPrintname, "add standby notification" Notifications.AddNotificationWithID("Standby", Standby.Standby) self.TimerSleep = eTimer() self.TimerSleep.callback.append(self.CheckElektro) self.TimerSleep.startLongTimer(elektrostarttime) print pluginPrintname, "Set up sleep timer" if debug: print pluginPrintname, "Translation test:", _("Standby on boot")
def lineReceived(self, data): if self.client or not self.transport: return Len = len(data) if Len < 23 or not data[:23] == "type=SNP#?version=1.0#?": return items = data[23:].split('#?') title = '' description = '' timeout = 5 for item in items: key, value = item.split('=') if key == "action": if value == "unregister": payload = "SNP/1.0/0/OK" self.sendLine(payload) self.transport.loseConnection() return elif value != "notification": # NOTE: we pretend to handle&accept pretty much everything one throws at us payload = "SNP/1.0/0/OK" self.sendLine(payload) return elif key == "title": title = value elif key == "text": description = value elif key == "timeout": timeout = int(value) Notifications.AddNotificationWithID( NOTIFICATIONID, MessageBox, text = title + '\n' + description, type = MessageBox.TYPE_INFO, timeout = timeout, close_on_any_key = True, ) # return ok payload = "SNP/1.0/0/OK" self.sendLine(payload)
def afterAuto(self): if config.plugins.epgShare.afterAuto.value == 1: #self.msgCallback("gehe in Standby") colorprint("gehe in Standby") Notifications.AddNotification(Screens.Standby.Standby) elif config.plugins.epgShare.afterAuto.value == "2": if not NavigationInstance.instance.RecordTimer.isRecording(): #self.msgCallback("gehe in Deep-Standby") colorprint("gehe in Deep-Standby") if Screens.Standby.inStandby: RecordTimerEntry.TryQuitMainloop() else: Notifications.AddNotificationWithID( "Shutdown", Screens.Standby.TryQuitMainloop, 1) else: #self.msgCallback("Eine laufenden Aufnahme verhindert den Deep-Standby") colorprint( "Eine laufenden Aufnahme verhindert den Deep-Standby")
def datagramReceived(self, data, addr): if not self.host.enable_incoming.value: return Len = len(data) if Len < 16: return # ver == GROWL_PROTOCOL_VERSION if data[0] != '\x01': return # type == GROWL_TYPE_NOTIFICATION if data[1] == '\x01': digest = data[-16:] password = self.host.password.value checksum = md5() checksum.update(data[:-16]) if password: checksum.update(password) if digest != checksum.digest(): return nlen, tlen, dlen, alen = unpack("!HHHH", str(data[4:12])) notification, title, description = unpack( "%ds%ds%ds" % (nlen, tlen, dlen), data[12:Len - alen - 16]) # type == GROWL_TYPE_NOTIFICATION_NOAUTH elif data[1] == '\x05': nlen, tlen, dlen, alen = unpack("!HHHH", str(data[4:12])) notification, title, description = unpack( "%ds%ds%ds" % (nlen, tlen, dlen), data[12:Len - alen]) else: # don't handle any other packet yet return Notifications.AddNotificationWithID( NOTIFICATIONID, MessageBox, text=title + '\n' + description, type=MessageBox.TYPE_INFO, timeout=5, close_on_any_key=True, )
def gotoDeepStandby(self, answer): if answer: if config.plugins.serienRec.afterAutocheck.value == "2": if not NavigationInstance.instance.RecordTimer.isRecording(): for each in self.messageList: Notifications.RemovePopup(each[3]) print "[SerienRecorder] gehe in Deep-Standby" SRLogger.writeLog("gehe in Deep-Standby") if Screens.Standby.inStandby: from RecordTimer import RecordTimerEntry RecordTimerEntry.TryQuitMainloop() else: Notifications.AddNotificationWithID("Shutdown", Screens.Standby.TryQuitMainloop, 1) else: print "[SerienRecorder] Eine laufende Aufnahme verhindert den Deep-Standby" SRLogger.writeLog("Eine laufende Aufnahme verhindert den Deep-Standby") else: print "[SerienRecorder] gehe in Standby" SRLogger.writeLog("gehe in Standby") Notifications.AddNotification(Screens.Standby.Standby)
def datagramReceived(self, data, addr): if not self.host.enable_incoming.value: return Len = len(data) # NOTE: since we're capable of handling longer messages, lets just do so # even if they do not comply to the protocol #if Len > 1024: # invalid according to rfc # return # read prio field prio, data = data.split('>', 1) prio = int(prio[1:]) facility, severity = divmod(prio, 8) # just the ids #facility = reverse(FACILITY)[facility] type = reverse(SEVERITYMAP).get(severity, MessageBox.TYPE_ERROR) # parse remaining header try: # try to parse timestamp to determine validity timestamp = strptime(data[:15], '%b %d %H:%M:%S') except ValueError: message = data else: hostname, body = data[16:].split(' ', 1) # NOTE: we could re-process timestamp to get a customized display format, # but lets just keep this for now message = hostname + ' @ ' + data[:15] + ': ' + body Notifications.AddNotificationWithID( NOTIFICATIONID, MessageBox, text=message, type=type, timeout=10, # XXX: un-hardcode timeout? close_on_any_key=True, )
def sessionstart(reason, session=None): print "[StartupToStandby] autostart" if config.plugins.startuptostandby.enabled.value and reason == 0 and not inStandby: Notifications.AddNotificationWithID("Standby", Standby)
def standby(self, answer): if answer is not None: if answer and not Screens.Standby.inStandby: Notifications.AddNotificationWithID("Standby", Screens.Standby.Standby, domain="SleepTimer")
def sendStandbyNotification(self, answer): if answer: Notifications.AddNotificationWithID("Standby", Screens.Standby.Standby, domain="RecordTimer")
def sendStandbyNotification(self, answer): if answer: Notifications.AddNotificationWithID("Standby", Screens.Standby.Standby, domain=NOTIFICATIONDOMAIN)