def rebootQuestionAnswered(ret): if ret: from enigma import quitMainloop quitMainloop(3) try: self.close() except: pass return
def rebootQuestionAnswered(ret): if ret: from enigma import quitMainloop quitMainloop(2) self.quit() return
def doInstantiateDialog(self, screen, arguments, kwargs, desktop): # create dialog z = None if "zPosition" in kwargs: z = kwargs["zPosition"] del kwargs["zPosition"] try: dlg = self.create(screen, arguments, **kwargs) except: print 'EXCEPTION IN DIALOG INIT CODE, ABORTING:' print '-'*60 print_exc(file=stdout) quitMainloop(5) print '-'*60 if dlg is None: return # read skin data readSkin(dlg, None, dlg.skinName, desktop) # create GUI view of this dialog assert desktop is not None dlg.setZPosition(z) dlg.setDesktop(desktop) dlg.applySkin() return dlg
def reboot(self, val = 2): # 2 - reboot self.hide() from enigma import quitMainloop from Screens.Standby import QuitMainloopScreen self.quitScreen = self.session.instantiateDialog(QuitMainloopScreen, retvalue=val) self.quitScreen.show() quitMainloop(val)
def doInstantiateDialog(self, screen, arguments, kwargs, desktop): # create dialog z = None if "zPosition" in kwargs: z = kwargs["zPosition"] del kwargs["zPosition"] try: dlg = self.create(screen, arguments, **kwargs) except Exception as e: print 'EXCEPTION IN DIALOG INIT CODE, ABORTING:' print '-'*60 print_exc(file=stdout) if isinstance(e, SkinError): print "SKIN ERROR", e print "defaulting to standard skin..." config.skin.primary_skin.value = "skin.xml" config.skin.primary_skin.save() configfile.save() quitMainloop(5) print '-'*60 if dlg is None: return # read skin data readSkin(dlg, None, dlg.skinName, desktop) # create GUI view of this dialog assert desktop is not None if z != None: dlg.setZPosition(z) dlg.setDesktop(desktop) dlg.applySkin() return dlg
def simulate(self): if not self.running: quitMainloop(6) return #update time returned by self.seconds e2reactor._now = monotonic_time() self._wakeupPending = False self._insimulate = True self.runUntilCurrent() if self._crashCall is not None: self._crashCall.reset(0) self._insertNewDelayedCalls() pendingTimedCalls = self._pendingTimedCalls if pendingTimedCalls: nextTimeout = pendingTimedCalls[0].time if nextTimeout != self.savedTimeout: self.savedTimeout = nextTimeout timeout = max(0, nextTimeout - self.seconds()) self._timer.start(int(timeout * 1010), True) else: self._timer.stop() self._insimulate = False
def close(self, value): if self.connected: self.connected=False self.session.nav.record_event.remove(self.getRecordEvent) if value: self.hide() if self.retval == 1: config.misc.DeepStandby.value = True if os.path.exists("/usr/scripts/standby_enter.sh"): Console().ePopen("/usr/scripts/standby_enter.sh") self.session.nav.stopService() self.quitScreen = self.session.instantiateDialog(QuitMainloopScreen,retvalue=self.retval) self.quitScreen.show() print "[Standby] quitMainloop #1" quitMainloopCode = self.retval if SystemInfo["Display"] and SystemInfo["LCDMiniTV"]: # set LCDminiTV off / fix a deep-standby-crash on some boxes / gb4k print "[Standby] LCDminiTV off" setLCDMiniTVMode("0") if getBoxType() == "vusolo4k": #workaround for white display flash f = open("/proc/stb/fp/oled_brightness", "w") f.write("0") f.close() quitMainloop(self.retval) else: MessageBox.close(self, True)
def keyCancelEnd(self, ret): #some cleaning just in case with open("/proc/sys/vm/drop_caches", "w") as f: f.write("1\n") self.LocalFileName = None self.list = None self['list'].setList([]) self["list"].setIndex(0) self["whatUPDATED"].setText("") self.SelectedIndex=None self.packages = None self.installedpackages = None self.upgradeablepackages = None self.Console = None self.divpng = None self.goinstalledpng = None self.goremovepng = None self.gousbpng = None self.installedpng = None self.upgradeablepng = None if ret == True: from Components.config import config try: # this is for openPLI to NOT put tuner into sleep mode config.misc.RestartUI.value = True config.misc.RestartUI.save() except: pass from enigma import quitMainloop quitMainloop(2) else: self.close()
def doInstantiateDialog(self, screen, arguments, kwargs, desktop): # create dialog try: dlg = self.create(screen, arguments, **kwargs) except: print 'EXCEPTION IN DIALOG INIT CODE, ABORTING:' print '-'*60 print_exc(file=stdout) print "[mytest.py] quitMainloop #2" enigma.quitMainloop(5) print '-'*60 if dlg is None: return # read skin data readSkin(dlg, None, dlg.skinName, desktop) # create GUI view of this dialog assert desktop is not None dlg.setDesktop(desktop) dlg.applySkin() return dlg
def quitMainloop(self): if self.retval == 3: config.misc.RestartUI.value = True config.misc.RestartUI.save() self.session.nav.stopService() self.quitScreen = self.session.instantiateDialog(QuitMainloopScreen, retvalue=self.retval) self.quitScreen.show() quitMainloop(self.retval)
def close(self, value): if self.connected: self.conntected=False self.session.nav.record_event.remove(self.getRecordEvent) if value: quitMainloop(self.retval) else: MessageBox.close(self, True)
def doRestart(self, *args): try: msgtxt = _("Please remember that you use this plugin at your own risk.") self.session.open(MessageBox, _("E2 GUI restart after IPTVPlayer update to version[%s].\n\n") % self.serversList[self.currServIdx]['version'] + msgtxt, type = MessageBox.TYPE_INFO, timeout = 5 ) from enigma import quitMainloop quitMainloop(3) except: printExc() self.session.open(MessageBox, _("Restart GUI failed. \nPlease restart STB manually."), type = MessageBox.TYPE_INFO, timeout=5 )
def keyCancelEnd(self, ret): if ret == True: from Components.config import config config.misc.RestartUI.value = True config.misc.RestartUI.save() from enigma import quitMainloop quitMainloop(2) else: self.close()
def create(self, screen, arguments, **kwargs): # creates an instance of 'screen' (which is a class) try: return screen(self, *arguments, **kwargs) except: errstr = "Screen %s(%s, %s): %s" % (str(screen), str(arguments), str(kwargs), exc_info()[0]) print errstr print_exc(file=stdout) quitMainloop(5)
def quitMainloopScreen(self, ret): retval = {"cancel factory reset":None, "do factory reset":65, "do full factory reset":64} if retval[ret[0]]: from Screens.Standby import QuitMainloopScreen from enigma import quitMainloop self.quitScreen = self.session.instantiateDialog(QuitMainloopScreen,retvalue=retval[ret[0]]) self.quitScreen.show() quitMainloop(retval[ret[0]]) self.close()
def close(self, value): if self.connected: self.conntected=False self.session.nav.record_event.remove(self.getRecordEvent) if value: if self.retval == 1: config.misc.DeepStandby.value = True quitMainloop(self.retval) else: MessageBox.close(self, True)
def runNextScreen(session, screensToRun, *result): if result: enigma.quitMainloop(*result) return screen = screensToRun[0][1] args = screensToRun[0][2:] if screensToRun: session.openWithCallback(boundFunction(runNextScreen, session, screensToRun[1:]), screen, *args) else: # FIXME: This is patently wrong. Getting screen/args would have caused an exception, if screensToRun was false session.open(screen, *args) # FIXME: Both lines can probably be deleted.
def runNextScreen(session, screensToRun, *result): if result: enigma.quitMainloop(*result) return screen = screensToRun[0][1] args = screensToRun[0][2:] if screensToRun: session.openWithCallback(boundFunction(runNextScreen, session, screensToRun[1:]), screen, *args) else: session.open(screen, *args)
def Stage6(self, result=None, retval=None, extra_args=None): self.Stage1Completed = True self.Stage2Completed = True self.Stage3Completed = True self.Stage4Completed = True self.Stage5Completed = True if self.didPluginsRestore or self.didSettingsRestore: print '[BackupManager] Restoring Completed rebooting' quitMainloop(2) else: print '[BackupManager] Restoring failed or canceled' self.close()
def ok(self): if (self.isinstalled): # self.[text] = Label(_("Starting Kodi...")) # self["text"].hide() # self["text"].show() # StartKodi2.already_shown = False # StartKodi2.hide(self) # StartKodi2.show(self) # StartKodi2.update(self) os.system("touch /etc/.kodistart") quitMainloop(3) else: self.close()
def buildList(self, action): if self.NextStep is 'reboot': quitMainloop(2) elif self.NextStep is 'settingsquestion' or self.NextStep is 'settingsrestore' or self.NextStep is 'pluginsquestion' or self.NextStep is 'pluginsrestoredevice' or self.NextStep is 'end' or self.NextStep is 'noplugins': self.buildListfinishedCB(False) elif self.NextStep is 'settingrestorestarted': self.Console.ePopen('tar -xzvf ' + self.fullbackupfilename + ' tmp/ExtraInstalledPlugins tmp/backupkernelversion tmp/backupimageversion -C /', self.settingsRestore_Started) self.buildListRef = self.session.openWithCallback(self.buildListfinishedCB, MessageBox, _('Please wait while the system gathers information...'), type=MessageBox.TYPE_INFO, enable_input=False, wizard=True) self.buildListRef.setTitle(_('Restore Wizard')) elif self.NextStep is 'plugindetection': print '[RestoreWizard] Stage 2: Restoring plugins' self.Console.ePopen('tar -xzvf ' + self.fullbackupfilename + ' tmp/ExtraInstalledPlugins tmp/backupkernelversion tmp/backupimageversion -C /', self.pluginsRestore_Started) self.buildListRef = self.session.openWithCallback(self.buildListfinishedCB, MessageBox, _('Please wait while the system gathers information...'), type=MessageBox.TYPE_INFO, enable_input=False, wizard=True) self.buildListRef.setTitle(_('Restore Wizard')) elif self.NextStep is 'pluginrestore': if self.feeds == 'OK': print '[RestoreWizard] Stage 6: Feeds OK, Restoring Plugins' self.Console.ePopen('opkg install ' + self.pluginslist + ' ' + self.pluginslist2, self.pluginsRestore_Finished) self.buildListRef = self.session.openWithCallback(self.buildListfinishedCB, MessageBox, _('Please wait while plugins restore completes...'), type=MessageBox.TYPE_INFO, enable_input=False, wizard=True) self.buildListRef.setTitle(_('Restore Wizard')) elif self.feeds == 'DOWN': print '[RestoreWizard] Stage 6: Feeds Down' config.misc.restorewizardrun.setValue(True) config.misc.restorewizardrun.save() configfile.save() self.didPluginRestore = True self.NextStep = 'reboot' self.buildListRef = self.session.openWithCallback(self.buildListfinishedCB, MessageBox, _('Sorry the feeds are down for maintenance, Please try using Backup Manager to restore plugins later.'), type=MessageBox.TYPE_INFO, timeout=30, wizard=True) self.buildListRef.setTitle(_('Restore Wizard')) elif self.feeds == 'BAD': print '[RestoreWizard] Stage 6: No Network' config.misc.restorewizardrun.setValue(True) config.misc.restorewizardrun.save() configfile.save() self.didPluginRestore = True self.NextStep = 'reboot' self.buildListRef = self.session.openWithCallback(self.buildListfinishedCB, MessageBox, _('Your %s %s is not connected to the internet, Please try using Backup Manager to restore plugins later.') % (getMachineBrand(), getMachineName()), type=MessageBox.TYPE_INFO, timeout=30, wizard=True) self.buildListRef.setTitle(_('Restore Wizard')) elif self.feeds == 'ERROR': self.NextStep = 'pluginrestore' self.buildListRef = self.session.openWithCallback(self.buildListfinishedCB, MessageBox, _('A background update check is in progress, please try again.'), type=MessageBox.TYPE_INFO, timeout=10, wizard=True) self.buildListRef.setTitle(_('Restore Wizard')) elif self.feeds == 'SPACE': print '[RestoreWizard] Stage 6: No space in disk' config.misc.restorewizardrun.setValue(True) config.misc.restorewizardrun.save() configfile.save() self.didPluginRestore = True self.NextStep = 'reboot' self.buildListRef = self.session.openWithCallback(self.buildListfinishedCB, MessageBox, _('Your %s %s have a FULL flash memory, please free memory or expand in USB') % (getMachineBrand(), getMachineName()), type=MessageBox.TYPE_INFO, timeout=30, close_on_any_key=True) self.buildListRef.setTitle(_('Restore Wizard'))
def close(self, value): if self.connected: self.conntected=False self.session.nav.record_event.remove(self.getRecordEvent) if value: self.hide() if self.retval == 1: config.misc.DeepStandby.value = True self.session.nav.stopService() self.quitScreen = self.session.instantiateDialog(QuitMainloopScreen,retvalue=self.retval) self.quitScreen.show() quitMainloop(self.retval) else: MessageBox.close(self, True)
def quitMainloopScreen(self, ret): retval = {"cancel factory reset":None, "do factory reset":65, "do full factory reset":64} #if retval[ret[0]]: # if "full" in ret[0]: # from enigma import SR # SR.getInstance().modeOff() from Screens.Standby import QuitMainloopScreen from enigma import quitMainloop # [IQON : fix cancel factory reset hangup : by knuth if retval[ret[0]] == None: self.close(False) else: self.quitScreen = self.session.instantiateDialog(QuitMainloopScreen,retvalue=retval[ret[0]]) self.quitScreen.show() quitMainloop(retval[ret[0]]) self.close()
def close(self, value): if self.connected: self.conntected=False self.session.nav.record_event.remove(self.getRecordEvent) if value: self.hide() if self.retval == 1: config.misc.DeepStandby.value = True self.session.nav.stopService() self.quitScreen = self.session.instantiateDialog(QuitMainloopScreen,retvalue=self.retval) self.quitScreen.show() if getBoxType() == "vusolo4k": #workaround for white display flash open("/proc/stb/fp/oled_brightness", "w").write("0") quitMainloop(self.retval) else: MessageBox.close(self, True)
def keyUpdate(self): self.save() #aktualizacja from tools import UpdateIPTV_from_GIT as iptvtools_UpdateIPTV_from_GIT, FreeSpace as iptvtools_FreeSpace WersjaGIT=self.iptvtools_GetGITversion msgtxt = "Autors don't take any responsibility for issues with tunners when using this plugin and using it to illegal download of the files" StatusUpdate = iptvtools_UpdateIPTV_from_GIT('/tmp') if StatusUpdate == "OK": self.session.open(MessageBox, "Restart oPLI po aktualizacji wtyczki do wersji %s...\n Czytałeś już licencję?\nJeśli tak, to wiesz, że\n\n" % WersjaGIT + msgtxt, type = MessageBox.TYPE_INFO, timeout = 5 ) from enigma import quitMainloop quitMainloop(3) else: self.session.open(MessageBox, "Błąd aktualizacji wtyczki, spróbuj ponownie za jakiś czas.\n Status: %s \n\n Dla przypomnienia -\n\n" % StatusUpdate + msgtxt, type = MessageBox.TYPE_INFO, timeout = 10 ) return
def confirm(self, confirmed): if not confirmed: print "not confirmed" return else: if self.enableConfigEntry.value is True: SR.getInstance().modeOn() else: SR.getInstance().modeOff() self.keySave() self.close() from enigma import quitMainloop from Screens.Standby import QuitMainloopScreen self.quitScreen = self.session.instantiateDialog(QuitMainloopScreen, retvalue=2) self.quitScreen.show() quitMainloop(2)
def quit(self, mode): self.networkMonitor.stop() self.smartcardMonitor.stop() self.ciMonitor.stop() self.storageMonitor.stop() self.hide() if mode == 1: os.system("rm /etc/enigma2 -rf") self.hide() self.quitScreen = self.session.instantiateDialog(QuitMainloopScreen,retvalue=mode) self.quitScreen.show() quitMainloop(mode) elif mode == 3: os.system("rm /etc/.run_factory_test -f; rm /etc/enigma2 -rf") if HardwareInfo().get_device_name() == "mediabox": os.system("tar xvf /etc/var.tar -C /; opkg install /tmp/enigma2-plugin-channel.non.motorized-techsat-17-29-57_20130610_all.ipk") os.system("killall enigma2")
def close(self, value): if self.connected: self.conntected=False self.session.nav.record_event.remove(self.getRecordEvent) if value: self.hide() if self.retval ==1: config.misc.DeepStandbyOn.value=True # WARNING HACK !! Black Hole dirty hack if self.retval == 1 or self.retval == 2: system("umount -a -f -t nfs,smbfs,cifs,ncpfs") #end self.session.nav.stopService() self.quitScreen = self.session.instantiateDialog(QuitMainloopScreen,retvalue=self.retval) self.quitScreen.show() quitMainloop(self.retval) else: MessageBox.close(self, True)
def close(self, value): if self.connected: self.connected=False self.session.nav.record_event.remove(self.getRecordEvent) if value: self.hide() if self.retval == 1: config.misc.DeepStandby.value = True if os.path.exists("/usr/script/Standby.sh"): Console().ePopen("/usr/script/Standby.sh off") if os.path.exists("/usr/script/standby_enter.sh"): Console().ePopen("/usr/script/standby_enter.sh") self.session.nav.stopService() self.quitScreen = self.session.instantiateDialog(QuitMainloopScreen,retvalue=self.retval) self.quitScreen.show() quitMainloop(self.retval) else: MessageBox.close(self, True)
def close(self, value): if self.connected: self.connected=False self.session.nav.record_event.remove(self.getRecordEvent) if value: self.hide() if self.retval == 1: config.misc.DeepStandby.value = True if os.path.exists("/etc/cron/standby_on"): Console().ePopen("/bin/run-parts /etc/cron/standby_on") elif not inStandby: config.misc.RestartUI.value = True config.misc.RestartUI.save() self.session.nav.stopService() self.quitScreen = self.session.instantiateDialog(QuitMainloopScreen,retvalue=self.retval) self.quitScreen.show() quitMainloop(self.retval) else: MessageBox.close(self, True)
def exitRestart(self, result): if result: quitMainloop(3) self.close()
def setScreen(self): self.list = [] if self.step == 1: self["introduction"].setText( _("The overscan wizard helps you to setup your TV in the correct way.\n\n" "For the majority of TV's, the factory default is to have overscan enabled. " "This means you are always watching a \"zoomed in\" picture instead of real HD, and parts of the user inferface (skin) may be invisible.\n\n" "The yellow area means a 5% border area of a full HD picture will be invisible.\n" "The green area means a 10% border area of a full HD picture will be invisible.\n\n" "In other words, if the yellow box touches all four sides of your screen, you have at least 5% overscan on all sides.\n\n" "If you see the tips of all eight arrowheads, then your TV has overscan disabled.\n\n" "Test Pattern by TigerDave - www.tigerdave.com/ht_menu.htm")) self.yes_no = ConfigYesNo(default=True, graphic=False) self.list.append( getConfigListEntry(_("Did you see all eight arrow heads?"), self.yes_no)) self.save_new_position = False setPosition(0, 720, 0, 576) elif self.step == 2: self.Timer.stop() self["title"].setText(_("Overscan wizard")) self["introduction"].setText( _("It seems you did not see all the eight arrow heads. This means your TV " "has overscan enabled, and is not configured properly.\n\n" "Please refer to your TV's manual to find how you can disable overscan on your TV. Look for terms like 'Just fit', 'Full width', etc. " "If you can't find it, ask other users at http://forums.openpli.org.\n\n" )) self.list.append( getConfigListEntry(_("Did you see all eight arrow heads?"), self.yes_no)) self.yes_no.value = True self.save_new_position = False setPosition(0, 720, 0, 576) elif self.step == 3: self["introduction"].setText( _("You did not see all eight arrow heads. This means your TV has overscan enabled " "and presents you with a zoomed-in picture, causing you to loose part of a full HD screen. In addition to this " "you may also miss parts of the user interface, for example volume bars and more.\n\n" "You can now try to resize and change the position of the user interface until you see the eight arrow heads.\n\n" "When done press OK.\n\n")) self.dst_left = ConfigSlider( default=config.plugins.OSDPositionSetup.dst_left.value, increment=1, limits=(0, 720)) self.dst_right = ConfigSlider( default=config.plugins.OSDPositionSetup.dst_left.value + config.plugins.OSDPositionSetup.dst_width.value, increment=1, limits=(0, 720)) self.dst_top = ConfigSlider( default=config.plugins.OSDPositionSetup.dst_top.value, increment=1, limits=(0, 576)) self.dst_bottom = ConfigSlider( default=config.plugins.OSDPositionSetup.dst_top.value + config.plugins.OSDPositionSetup.dst_height.value, increment=1, limits=(0, 576)) self.list.append(getConfigListEntry(_("left"), self.dst_left)) self.list.append(getConfigListEntry(_("right"), self.dst_right)) self.list.append(getConfigListEntry(_("top"), self.dst_top)) self.list.append(getConfigListEntry(_("bottom"), self.dst_bottom)) setConfiguredPosition() elif self.step == 4: self["introduction"].setText( _("You did not see all eight arrow heads. This means your TV has overscan enabled " "and presents you with a zoomed-in picture, causing you to loose part of a full HD screen. In addition this " "you may also miss parts of the user interface, for example volume bars and more.\n\n" "Unfortunately, your model of receiver is not capable to adjust the dimensions of the user interface. " "If not everything is visible, you should change the installed skin to one that supports the overscan area of your TV.\n\n" "When you select a different skin, the user interface of your receiver will restart.\n\n" "Note: you can always start the Overscan wizard later, via\n\nmenu->installation->system->Overscan wizard" )) self.yes_no.value = False self.list.append( getConfigListEntry( _("Do you want to select a different skin?"), self.yes_no)) elif self.step == 5: self.Timer.stop() self["title"].setText(_("Overscan wizard")) self["introduction"].setText( _("The overscan wizard has been completed.\n\n" "Note: you can always start the Overscan wizard later, via\n\nMenu->Installation->System->Audio/Video->Overscan wizard" )) self.yes_no.value = True self.list.append( getConfigListEntry( _("Do you want to quit the overscan wizard?"), self.yes_no)) elif self.step == 6: config.skin.primary_skin.value = "PLi-HD/skin.xml" config.save() self["introduction"].setText( _("The user interface of the receiver will now restart to select the selected skin" )) quitMainloop(3) self["config"].list = self.list self["config"].l.setList(self.list) if self["config"].instance: self.__layoutFinished()
def quitMainloop(self): self.session.nav.stopService() self.quitScreen = self.session.instantiateDialog(QuitMainloopScreen, retvalue=self.retval) self.quitScreen.show() quitMainloop(self.retval)
def shutdown(): quitMainloop(1)
def __restartGUI__(self, callback=None): if callback == True: quitMainloop(3) elif callback == False: pass
def exitAnswer(self, result): if result != None and result: quitMainloop(2) self.close() return
def update_now_zip(self, cItem): restart = cItem.get('retstart', True) printDBG('TSIplayer: Start Update') tmpDir = GetTmpDir() source = os_path.join(tmpDir, 'archive.zip') dest = os_path.join(tmpDir, '') _url = 'https://gitlab.com/Rgysoft/iptv-host-e2iplayer/repository/archive.zip' try: output = open(source, 'wb') output.write(self.cm.getPage(_url)[1]) output.close() os_system('sync') printDBG('TSIplayer: Download archive.zip OK') except: if os_path.exists(source): os_remove(source) printDBG('TSIplayer: Download Error archive.zip') return '' cmd = 'unzip -o "%s" -d "%s"' % (source, dest) try: os_system(cmd) os_system('sync') printDBG('TSIplayer(zip): Unpacking OK') except: printDBG('TSIplayer(zip): Unpacking Error') os_system('rm -f %s' % source) os_system('rm -rf /tmp/iptv-host-e2iplayer*/IPTVPlayer') return '' try: os_system( 'cp -rf /tmp/iptv-host-e2iplayer*/IPTVPlayer /usr/lib/enigma2/python/Plugins/Extensions' ) os_system('sync') printDBG('TSIplayer(Zip): Copy OK') except: printDBG('TSIplayer(Zip): Copy Error') os_system('rm -f %s' % source) os_system('rm -rf /tmp/iptv-host-e2iplayer*/IPTVPlayer') return '' printDBG('TSIplayer: Deleting temporary files') os_system('rm -f %s' % source) os_system('rm -rf /tmp/iptv-host-e2iplayer*/IPTVPlayer') if restart: try: from enigma import quitMainloop quitMainloop(3) except Exception as e: printDBG('TSIplayer: Erreur=' + str(e)) pass params = { 'category': 'none', 'title': 'Update End. Please manual restart enigma2', 'name': 'update' } self.addDir(params) return ''
def ok(self): if (self.isinstalled): quitMainloop(3) else: self.close()
def activate(self): global RSsave, RBsave, DSsave, aeDSsave, wasTimerWakeup 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: # return True elif self.timerType == TIMERTYPE.WAKEUPTOSTANDBY or self.timerType == TIMERTYPE.STANDBY: if debug: if self.timerType == TIMERTYPE.WAKEUPTOSTANDBY: print "self.timerType == TIMERTYPE.WAKEUPTOSTANDBY:" else: 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 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 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 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: 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 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: 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 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: 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 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: 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() resetTimerWakeup() return True
def messageBoxCallback(answer=False): if answer == True: quitMainloop(3)
def activate(self): next_state = self.state + 1 self.log(5, "activating state %d" % next_state) if next_state == 1 and (self.timerType == TIMERTYPE.AUTOSTANDBY or self.timerType == TIMERTYPE.AUTODEEPSTANDBY): 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 or has failed, # 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.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 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 = 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: if (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 self.begin = time() + self.backoff if self.end <= self.begin: self.end = self.begin return False if not Screens.Standby.inTryQuitMainloop: # The shutdown messagebox is not open if Screens.Standby.inStandby: # In standby 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 = 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 self.begin = time() + self.backoff if self.end <= self.begin: self.end = self.begin return False if not Screens.Standby.inTryQuitMainloop: # The shutdown messagebox is not open if Screens.Standby.inStandby: # In standby quitMainloop(1) else: Notifications.AddNotificationWithCallback(self.sendTryQuitMainloopNotification, 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 self.begin = time() + self.backoff if self.end <= self.begin: self.end = self.begin return False if not Screens.Standby.inTryQuitMainloop: # The shutdown messagebox is not open if Screens.Standby.inStandby: # In standby quitMainloop(2) else: Notifications.AddNotificationWithCallback(self.sendTryToRebootNotification, 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 self.begin = time() + self.backoff if self.end <= self.begin: self.end = self.begin return False if not Screens.Standby.inTryQuitMainloop: # The shutdown messagebox is not open if Screens.Standby.inStandby: # In standby quitMainloop(3) else: Notifications.AddNotificationWithCallback(self.sendTryToRestartNotification, MessageBox, _("A finished powertimer wants to restart the user interface.\nDo that now?"), timeout=180) return True elif next_state == self.StateEnded: NavigationInstance.instance.PowerTimer.saveTimer() if 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 NavigationInstance.instance.RecordTimer.isRecording() or abs(NavigationInstance.instance.RecordTimer.getNextRecordingTime() - time()) <= 900 or abs(NavigationInstance.instance.RecordTimer.getNextZapTime() - time()) <= 900: self.do_backoff() # Retry self.begin = time() + self.backoff if self.end <= self.begin: self.end = self.begin return False if not Screens.Standby.inTryQuitMainloop: # The shutdown messagebox is not open if Screens.Standby.inStandby: # In standby quitMainloop(1) else: Notifications.AddNotificationWithCallback(self.sendTryQuitMainloopNotification, MessageBox, _("A finished power timer wants to shut down\nyour %s %s. Shutdown now?") % (getMachineBrand(), getMachineName()), timeout=180) return True
def doRestart(self, answer): if answer is not None: if answer: quitMainloop(3)
def update_now_tar(self, cItem): restart = cItem.get('retstart', True) printDBG('TSIplayer: Start Update') #crc='' #_url = 'https://gitlab.com/Rgysoft/iptv-host-e2iplayer' #try: # crc_data = re.findall('/Rgysoft/iptv-host-e2iplayer/commit/([^"^\']+?)[\'"]',self.cm.getPage(_url)[1], re.S) # if crc_data: # crc=crc_data[0] # printDBG('TSIplayer: crc = '+crc) # else: printDBG('TSIplayer: crc not found') #except: # printDBG('TSIplayer: Get Main URL Error') # return '' crc = '' _url = 'https://gitlab.com/Rgysoft/iptv-host-e2iplayer/-/refs/master/logs_tree/?format=json&o' try: crc_data = re.findall('commit.*?id":"(.*?)"', self.cm.getPage(_url)[1], re.S) if crc_data: crc = crc_data[0] printDBG('TSIplayer: crc = ' + crc) else: printDBG('TSIplayer: crc not found') except: printDBG('TSIplayer: Get Main URL Error') return '' tmpDir = GetTmpDir() source = os_path.join(tmpDir, 'iptv-host-e2iplayer.tar.gz') dest = os_path.join(tmpDir, '') _url = 'https://gitlab.com/Rgysoft/iptv-host-e2iplayer/repository/archive.tar.gz?ref=master' try: output = open(source, 'wb') output.write(self.getPage(_url)[1]) output.close() os_system('sync') printDBG('TSIplayer: Download iptv-host-e2iplayer.tar.gz OK') except: if os_path.exists(source): os_remove(source) printDBG('TSIplayer: Download Error iptv-host-e2iplayer.tar.gz') return '' cmd = 'tar -xzf "%s" -C "%s" 2>&1' % (source, dest) try: os_system(cmd) os_system('sync') printDBG('TSIplayer: Unpacking OK') except: printDBG('TSIplayer: Unpacking Error') os_system('rm -f %s' % source) os_system('rm -rf %siptv-host-e2iplayer-%s' % (dest, crc)) return '' try: od = '%siptv-host-e2iplayer-master-%s/' % (dest, crc) do = resolveFilename(SCOPE_PLUGINS, 'Extensions/') cmd = 'cp -rf "%s"/* "%s"/ 2>&1' % (os_path.join( od, 'IPTVPlayer'), os_path.join(do, 'IPTVPlayer')) printDBG('<<<<<<<<<<<<<<<<<<<<<<<<<<cmd=' + cmd) os_system(cmd) os_system('sync') printDBG('TSIplayer: Copy OK') except: printDBG('TSIplayer: Copy Error') os_system('rm -f %s' % source) os_system('rm -rf %siptv-host-e2iplayer-master-%s' % (dest, crc)) return '' printDBG('TSIplayer: Deleting temporary files') os_system('rm -f %s' % source) os_system('rm -rf %siptv-host-e2iplayer-master-%s' % (dest, crc)) if restart: try: from enigma import quitMainloop quitMainloop(3) except Exception as e: printDBG('TSIplayer: Erreur=' + str(e)) pass params = { 'category': 'none', 'title': 'Update End. Please manual restart enigma2', 'name': 'update' } self.addDir(params) return ''
def __closed(self): quitMainloop(self.retval)
def buildList(self, action): if self.NextStep is 'reboot': quitMainloop(2) elif self.NextStep is 'settingsquestion' or self.NextStep is 'settingsrestore' or self.NextStep is 'pluginsquestion' or self.NextStep is 'pluginsrestoredevice' or self.NextStep is 'end' or self.NextStep is 'noplugins': self.buildListfinishedCB(False) elif self.NextStep is 'settingrestorestarted': self.Console.ePopen( "tar -xzvf " + self.fullbackupfilename + " tmp/ExtraInstalledPlugins tmp/backupkernelversion tmp/backupimageversion -C /", self.settingsRestore_Started) self.buildListRef = self.session.openWithCallback( self.buildListfinishedCB, MessageBox, _("Please wait while the system gathers information..."), type=MessageBox.TYPE_INFO, enable_input=False, wizard=True) self.buildListRef.setTitle(_("Restore Wizard")) elif self.NextStep is 'plugindetection': print '[RestoreWizard] Stage 2: Restoring plugins' self.Console.ePopen( "tar -xzvf " + self.fullbackupfilename + " tmp/ExtraInstalledPlugins tmp/backupkernelversion tmp/backupimageversion -C /", self.pluginsRestore_Started) self.buildListRef = self.session.openWithCallback( self.buildListfinishedCB, MessageBox, _("Please wait while the system gathers information..."), type=MessageBox.TYPE_INFO, enable_input=False, wizard=True) self.buildListRef.setTitle(_("Restore Wizard")) elif self.NextStep is 'pluginrestore': if self.feeds == 'OK': print '[RestoreWizard] Stage 6: Feeds OK, Restoring Plugins' print '[RestoreWizard] Console command: ', 'opkg install ' + self.pluginslist + ' ' + self.pluginslist2 self.Console.ePopen( "opkg install " + self.pluginslist + ' ' + self.pluginslist2, self.pluginsRestore_Finished) self.buildListRef = self.session.openWithCallback( self.buildListfinishedCB, MessageBox, _("Please wait while plugins restore completes..."), type=MessageBox.TYPE_INFO, enable_input=False, wizard=True) self.buildListRef.setTitle(_("Restore Wizard")) elif self.feeds == 'DOWN': print '[RestoreWizard] Stage 6: Feeds Down' config.misc.restorewizardrun.setValue(True) config.misc.restorewizardrun.save() configfile.save() self.didPluginRestore = True self.NextStep = 'reboot' self.buildListRef = self.session.openWithCallback( self.buildListfinishedCB, MessageBox, _("Sorry the feeds are down for maintenance, Please try using Backup Manager to restore plugins later." ), type=MessageBox.TYPE_INFO, timeout=30, wizard=True) self.buildListRef.setTitle(_("Restore Wizard")) elif self.feeds == 'BAD': print '[RestoreWizard] Stage 6: No Network' config.misc.restorewizardrun.setValue(True) config.misc.restorewizardrun.save() configfile.save() self.didPluginRestore = True self.NextStep = 'reboot' self.buildListRef = self.session.openWithCallback( self.buildListfinishedCB, MessageBox, _("Your %s %s is not connected to the internet, Please try using Backup Manager to restore plugins later." ) % (getMachineBrand(), getMachineName()), type=MessageBox.TYPE_INFO, timeout=30, wizard=True) self.buildListRef.setTitle(_("Restore Wizard")) elif self.feeds == 'ERROR': self.NextStep = 'pluginrestore' self.buildListRef = self.session.openWithCallback( self.buildListfinishedCB, MessageBox, _("A background update check is in progress, please try again." ), type=MessageBox.TYPE_INFO, timeout=10, wizard=True) self.buildListRef.setTitle(_("Restore Wizard"))
def __confCallback(self, data): if data == False: self.Exit() else: self.close() quitMainloop(2)
import Components.SetupDevices Components.SetupDevices.InitSetupDevices() profile("RFMod") import Components.RFmod Components.RFmod.InitRFmod() profile("Init:CI") import Screens.Ci Screens.Ci.InitCiConfig() #from enigma import dump_malloc_stats #t = eTimer() #t.callback.append(dump_malloc_stats) #t.start(1000) # first, setup a screen try: runScreenTest() plugins.shutdown() from Components.ParentalControl import parentalControl parentalControl.save() except: print 'EXCEPTION IN PYTHON STARTUP CODE:' print '-' * 60 print_exc(file=stdout) quitMainloop(5) print '-' * 60
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("", -maxsize - 1, 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 okay, waiting for begin.") self.next_activation = self.begin self.backoff = 0 return True elif next_state == self.StateRunning: self.wasPowerTimerWakeup = False if exists("/tmp/was_powertimer_wakeup"): self.wasPowerTimerWakeup = int(open("/tmp/was_powertimer_wakeup", "r").read()) and True or False 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. AddNotificationWithUniqueIDCallback(self.sendStandbyNotification, "PT_StateChange", MessageBox, _("A finished powertimer wants to set your receiver to standby. Do that now?"), 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. AddNotificationWithUniqueIDCallback(self.sendStandbyNotification, "PT_StateChange", MessageBox, _("A finished powertimer wants to set your receiver to standby. Do that now?"), 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: AddNotificationWithUniqueIDCallback(self.sendTryQuitMainloopNotification, "PT_StateChange", MessageBox, _("A finished powertimer wants to shutdown your receiver. Do that now?"), 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: AddNotificationWithUniqueIDCallback(self.sendTryQuitMainloopNotification, "PT_StateChange", MessageBox, _("A finished powertimer wants to shutdown your receiver. Do that now?"), 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: AddNotificationWithUniqueIDCallback(self.sendTryToRebootNotification, "PT_StateChange", MessageBox, _("A finished powertimer wants to reboot your receiver. Do that now?"), 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: 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.saveTimers() if self.afterEvent == AFTEREVENT.STANDBY: if not Screens.Standby.inStandby: # Not already in standby. AddNotificationWithUniqueIDCallback(self.sendStandbyNotification, "PT_StateChange", MessageBox, _("A finished powertimer wants to set your receiver to standby. Do that now?"), 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: AddNotificationWithUniqueIDCallback(self.sendTryQuitMainloopNotification, "PT_StateChange", MessageBox, _("A finished powertimer wants to shutdown your receiver. Do that now?"), timeout=180) return True
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 quitMainloop(1) else: Notifications.AddNotificationWithCallback(self.sendTryQuitMainloopNotification, MessageBox, _("A finished record timer wants to shut down\nyour %s %s. Shutdown now?") % (getMachineBrand(), getMachineName()), timeout = 180) return True def keypress(self, key=None, flag=1): if flag and self.wasInStandby: self.wasInStandby = False eActionMap.getInstance().unbindAction('', self.keypress) def setAutoincreaseEnd(self, entry = None): if not self.autoincrease: return False if entry is None: new_end = int(time()) + self.autoincreasetime else:
def ExecuteRestart(self, result): if result: quitMainloop(3)
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 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 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 restartgui(self): quitMainloop(3)
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): 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 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: Notifications.AddNotificationWithUniqueIDCallback( self.sendStandbyNotification, "PT_StateChange", MessageBox, _("A finished powertimer wants to set your receiver to standby. Do that now?" ), 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() return False if not Screens.Standby.inStandby: Notifications.AddNotificationWithUniqueIDCallback( self.sendStandbyNotification, "PT_StateChange", MessageBox, _("A finished powertimer wants to set your receiver to standby. Do that now?" ), 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: 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() return False if not Screens.Standby.inTryQuitMainloop: if Screens.Standby.inStandby: quitMainloop(1) return True else: Notifications.AddNotificationWithUniqueIDCallback( self.sendTryQuitMainloopNotification, "PT_StateChange", MessageBox, _("A finished powertimer wants to shutdown your receiver. Do that now?" ), 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() return False if not Screens.Standby.inTryQuitMainloop: if Screens.Standby.inStandby: quitMainloop(1) else: Notifications.AddNotificationWithUniqueIDCallback( self.sendTryQuitMainloopNotification, "PT_StateChange", MessageBox, _("A finished powertimer wants to shutdown your receiver. Do that now?" ), 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() return False if not Screens.Standby.inTryQuitMainloop: if Screens.Standby.inStandby: quitMainloop(2) else: Notifications.AddNotificationWithUniqueIDCallback( self.sendTryToRebootNotification, "PT_StateChange", MessageBox, _("A finished powertimer wants to reboot your receiver. Do that now?" ), 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() return False if not Screens.Standby.inTryQuitMainloop: if Screens.Standby.inStandby: 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: Notifications.AddNotificationWithUniqueIDCallback( self.sendStandbyNotification, "PT_StateChange", MessageBox, _("A finished powertimer wants to set your receiver to standby. Do that now?" ), 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() return False if not Screens.Standby.inTryQuitMainloop: if Screens.Standby.inStandby: quitMainloop(1) else: Notifications.AddNotificationWithUniqueIDCallback( self.sendTryQuitMainloopNotification, "PT_StateChange", MessageBox, _("A finished powertimer wants to shutdown your receiver. Do that now?" ), timeout=180) return True
profile("RFMod") import Components.RFmod Components.RFmod.InitRFmod() profile("Init:CI") import Screens.Ci Screens.Ci.InitCiConfig() profile("RcModel") import Components.RcModel #from enigma import dump_malloc_stats #t = eTimer() #t.callback.append(dump_malloc_stats) #t.start(1000) # first, setup a screen try: runScreenTest() plugins.shutdown() Components.ParentalControl.parentalControl.save() except: print 'EXCEPTION IN PYTHON STARTUP CODE:' print '-' * 60 print_exc(file=stdout) print "[mytest.py] quitMainloop #4" enigma.quitMainloop(5) print '-' * 60
def activate(self): global DSsave, RSsave, RBsave, aeDSsave, wasPowerTimerWakeup, wakeupEnd next_state = self.state + 1 self.log(5, "activating state %d" % next_state) if next_state == 1 and (self.timerType == TIMERTYPE.AUTOSTANDBY or self.timerType == TIMERTYPE.AUTODEEPSTANDBY): 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: if os.path.exists( "/tmp/was_powertimer_wakeup") and not wasPowerTimerWakeup: wasPowerTimerWakeup = int( open("/tmp/was_powertimer_wakeup", "r").read()) and True or False if wasPowerTimerWakeup and time() >= wakeupEnd: resetTimerWakeup() # 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.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 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 = 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: if self.getNetworkTraffic() or wasPowerTimerWakeup or ( NavigationInstance.instance.RecordTimer.isRecording() or abs(NavigationInstance.instance.RecordTimer. getNextRecordingTime() - time()) <= 900 or abs(NavigationInstance.instance.RecordTimer. getNextZapTime() - time()) <= 900) or ( (self.autosleepinstandbyonly == 'yesNWno' or self.autosleepinstandbyonly == 'yes') and not Screens.Standby.inStandby): self.do_backoff() # retry self.begin = time() + self.backoff if self.end <= self.begin: self.end = self.begin return False if 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 = time() + int(self.autosleepdelay) * 60 if self.end <= self.begin: self.end = self.begin elif self.timerType == TIMERTYPE.DEEPSTANDBY: if wasPowerTimerWakeup or NavigationInstance.instance.RecordTimer.isRecording( ) or abs(NavigationInstance.instance.RecordTimer. getNextRecordingTime() - time()) <= 900 or abs(NavigationInstance.instance. RecordTimer.getNextZapTime() - time()) <= 900: if int(self.repeated) > 0 and not DSsave: self.DSbegin = self.begin self.DSend = self.end DSsave = True self.do_backoff() # retry self.begin = time() + self.backoff if self.end <= self.begin: self.end = self.begin return False if not Screens.Standby.inTryQuitMainloop: # not a shutdown messagebox is open if DSsave: DSsave = False self.begin = self.DSbegin self.end = self.DSend 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) return True elif self.timerType == TIMERTYPE.REBOOT: if wasPowerTimerWakeup or NavigationInstance.instance.RecordTimer.isRecording( ) or abs(NavigationInstance.instance.RecordTimer. getNextRecordingTime() - time()) <= 900 or abs(NavigationInstance.instance. RecordTimer.getNextZapTime() - time()) <= 900: if int(self.repeated) > 0 and not RBsave: self.RBbegin = self.begin self.RBend = self.end RBsave = True self.do_backoff() # retry self.begin = time() + self.backoff if self.end <= self.begin: self.end = self.begin return False if not Screens.Standby.inTryQuitMainloop: # not a shutdown messagebox is open if RBsave: RBsave = False self.begin = self.RBbegin self.end = self.RBend 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) return True elif self.timerType == TIMERTYPE.RESTART: if wasPowerTimerWakeup or NavigationInstance.instance.RecordTimer.isRecording( ) or abs(NavigationInstance.instance.RecordTimer. getNextRecordingTime() - time()) <= 900 or abs(NavigationInstance.instance. RecordTimer.getNextZapTime() - time()) <= 900: if int(self.repeated) > 0 and not RSsave: self.RSbegin = self.begin self.RSend = self.end RSsave = True self.do_backoff() # retry self.begin = time() + self.backoff if self.end <= self.begin: self.end = self.begin return False if not Screens.Standby.inTryQuitMainloop: # not a shutdown messagebox is open if RSsave: RSsave = False self.begin = self.RSbegin self.end = self.RSend 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) return True elif next_state == self.StateEnded: resetTimerWakeup() NavigationInstance.instance.PowerTimer.saveTimer() if 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 NavigationInstance.instance.RecordTimer.isRecording( ) or abs(NavigationInstance.instance.RecordTimer. getNextRecordingTime() - time()) <= 900 or abs(NavigationInstance.instance. RecordTimer.getNextZapTime() - time()) <= 900: if int(self.repeated) > 0 and not aeDSsave: self.aeDSbegin = self.begin self.aeDSend = self.end aeDSsave = True self.do_backoff() # retry self.begin = time() + self.backoff if self.end <= self.begin: self.end = self.begin return False if not Screens.Standby.inTryQuitMainloop: # not a shutdown messagebox is open if aeDSsave: aeDSsave = False self.begin = self.aeDSbegin self.end = self.aeDSend if Screens.Standby.inStandby: # in standby print "[PowerTimer] quitMainloop #5" quitMainloop(1) else: Notifications.AddNotificationWithCallback( self.sendTryQuitMainloopNotification, MessageBox, _("A finished power timer wants to shut down\nyour %s %s. Shutdown now?" ) % (getMachineBrand(), getMachineName()), timeout=180) return True
def restartCallback(self, result): quitMainloop(3)
def exitReboot(self, result): if result: quitMainloop(2) self.close()
def rebootconfirm(self, answer): if answer is not None and answer: from enigma import quitMainloop quitMainloop(3)
def exitAnswer(self, result): if result is not None and result: quitMainloop(2) self.close()