예제 #1
0
	def __init__(self, session):
		Screen.__init__(self, session)
		self.setTitle(_("Streaming clients info"))

		if ClientsStreaming("NUMBER").getText() == "0":
			self["total"] = StaticText( _("No stream clients") )
			text = ""
		else:
			self["total"] = StaticText( _("Total Clients streaming: ") + ClientsStreaming("NUMBER").getText())
			text = ClientsStreaming("EXTRA_INFO").getText()
			clients = ClientsStreaming("INFO_RESOLVE")
			text = clients.getText()

		self["liste"] = StaticText(text)
		self["ScrollLabel"] = ScrollLabel(text)

		self["key_red"] = Button(_("Close"))
		self["actions"] = ActionMap(["ColorActions", "SetupActions", "DirectionActions"],
			{
				"cancel": self.close,
				"ok": self.close,
				"red": self.close,
				"up": self["ScrollLabel"].pageUp,
				"down": self["ScrollLabel"].pageDown
			})
    def __init__(self, session, menu_path=""):
        Screen.__init__(self, session)
        screentitle = _("Streaming clients info")
        menu_path += screentitle
        if config.usage.show_menupath.value == 'large':
            title = menu_path
            self["menu_path_compressed"] = StaticText("")
        elif config.usage.show_menupath.value == 'small':
            title = screentitle
            self["menu_path_compressed"] = StaticText(
                menu_path +
                " >" if not menu_path.endswith(' / ') else menu_path[:-3] +
                " >" or "")
        else:
            title = screentitle
            self["menu_path_compressed"] = StaticText("")
        Screen.setTitle(self, title)
        clients = ClientsStreaming("INFO_RESOLVE")
        text = clients.getText()

        self["ScrollLabel"] = ScrollLabel(text or _("No stream clients"))

        self["key_red"] = Button(_("Close"))
        self["actions"] = ActionMap(
            ["ColorActions", "SetupActions", "DirectionActions"], {
                "cancel": self.close,
                "ok": self.close,
                "red": self.close,
                "up": self["ScrollLabel"].pageUp,
                "down": self["ScrollLabel"].pageDown
            })
예제 #3
0
	def __init__(self, session, menu_path = ""):
		Screen.__init__(self, session)
		screentitle = _("Streaming clients info")
		menu_path += screentitle
		if config.usage.show_menupath.value == 'large':
			title = menu_path
			self["menu_path_compressed"] = StaticText("")
		elif config.usage.show_menupath.value == 'small':
			title = screentitle
			self["menu_path_compressed"] = StaticText(menu_path + " >" if not menu_path.endswith(' / ') else menu_path[:-3] + " >" or "")
		else:
			title = screentitle
			self["menu_path_compressed"] = StaticText("")
		Screen.setTitle(self, title)
		clients = ClientsStreaming("INFO_RESOLVE")
		text = clients.getText()

		self["ScrollLabel"] = ScrollLabel(text or _("No stream clients"))

		self["actions"] = ActionMap(["ColorActions", "SetupActions", "DirectionActions"],
		{
			"cancel": self.close,
			"ok": self.close,
			"up": self["ScrollLabel"].pageUp,
			"down": self["ScrollLabel"].pageDown
		})
예제 #4
0
 def doPowerOffRun(self):
     if self.session:
         if self.wait_nextday:
             if time() >= self.nextday_time:
                 print "[PowerOffTimer] Cancel waiting shutdown, over limit, set next day."
                 self.powerStateTimerChanged()
                 return
         try_poweroff = True
         if isExternalToolsRunning():
             try_poweroff = False
         if RecordTimerEntry.wasInDeepStandby:
             try_poweroff = False
         if try_poweroff:
             if not self.session.nav.getRecordings():
                 rec_time = self.session.nav.RecordTimer.getNextRecordingTime(
                 )
                 if rec_time > 0 and (rec_time - time()) < 360:
                     try_poweroff = False
             else:
                 try_poweroff = False
         if try_poweroff:
             jobs = len(job_manager.getPendingJobs())
             if Standby.inStandby is None:
                 if not config.usage.poweroff_force.value:
                     try_poweroff = False
             elif jobs or self.session.screen[
                     "TunerInfo"].tuner_use_mask or internalHDDNotSleeping(
                     ):
                 try_poweroff = False
         if try_poweroff:
             if Standby.inStandby is None:
                 reason = _("Power off timer") + '\n\n'
                 if jobs:
                     if jobs == 1:
                         job = job_manager.getPendingJobs()[0]
                         reason += "%s: %s (%d%%)\n" % (
                             job.getStatustext(), job.name,
                             int(100 * job.progress / float(job.end)))
                     else:
                         reason += (ngettext(
                             "%d job is running in the background!",
                             "%d jobs are running in the background!", jobs)
                                    % jobs) + '\n'
                 if self.session.nav.getClientsStreaming():
                     clients = ClientsStreaming("SHORT_ALL")
                     reason += clients.getText() + '\n'
                 self.session.openWithCallback(self.doPowerOffAnswer,
                                               MessageBox,
                                               reason +
                                               _("Really shutdown now?"),
                                               type=MessageBox.TYPE_YESNO,
                                               timeout=180)
             else:
                 self.doPowerOffAnswer(True)
         else:
             print "[PowerOffTimer] Don't shutdown, box in use. Wait 5 min..."
             self.doPowerOffTimer.start(self.wait_nextday_time * 1000, True)
             self.wait_nextday = True
예제 #5
0
    def __init__(self, session):
        Screen.__init__(self, session)
        self.setTitle(_("Streaming clients info"))
        clients = ClientsStreaming("INFO_RESOLVE")
        text = clients.getText()

        self["ScrollLabel"] = ScrollLabel(text)

        self["actions"] = ActionMap(
            ["ColorActions", "SetupActions", "DirectionActions"], {
                "cancel": self.close,
                "ok": self.close,
                "up": self["ScrollLabel"].pageUp,
                "down": self["ScrollLabel"].pageDown
            })
예제 #6
0
	def __init__(self, session):
		Screen.__init__(self, session)
		self.setTitle(_("Streaming clients info"))
		clients = ClientsStreaming("INFO_RESOLVE")
		text = clients.getText()

		self["ScrollLabel"] = ScrollLabel(text or _("No stream clients"))

		self["actions"] = ActionMap(["ColorActions", "SetupActions", "DirectionActions"],
		{
			"cancel": self.close,
			"ok": self.close,
			"up": self["ScrollLabel"].pageUp,
			"down": self["ScrollLabel"].pageDown
		})
예제 #7
0
		def __init__(self, session):
			Screen.__init__(self, session)
			self.setTitle(_("Streaming clients info"))
			if ClientsStreaming("NUMBER").getText() == "0":
				self["total"] = StaticText(_("No streaming Channel from this STB at this moment"))
				text = ""
			else:
				self["total"] = StaticText(_("Total Clients streaming: ") + ClientsStreaming("NUMBER").getText())
				text = ClientsStreaming("EXTRA_INFO").getText()

			self["liste"] = StaticText(text)
			self["actions"] = ActionMap(["ColorActions", "SetupActions", "DirectionActions"],
			{
				"cancel": self.close,
				"ok": self.close
			})
예제 #8
0
    def __init__(self, session):
        Screen.__init__(self, session)
        self.setTitle(_("Streaming clients info"))

        clients = ClientsStreaming("INFO_RESOLVE")
        text = clients.getText()

        self["ScrollLabel"] = ScrollLabel(text or _("No stream clients"))
        self["key_red"] = Button(text and _("Stop Streams") or "")

        self["actions"] = ActionMap(
            ["ColorActions", "SetupActions", "DirectionActions"], {
                "cancel": self.close,
                "ok": self.close,
                "red": self.stopStreams,
                "up": self["ScrollLabel"].pageUp,
                "down": self["ScrollLabel"].pageDown
            })
예제 #9
0
    def __init__(self, session):
        Screen.__init__(self, session)
        self.setTitle(_("Streaming clients info"))

        if ClientsStreaming("NUMBER").getText() == "0":
            self["total"] = StaticText(_("No stream clients"))
            text = ""
        else:
            self["total"] = StaticText(
                _("Total Clients streaming: ") +
                ClientsStreaming("NUMBER").getText())
            text = ClientsStreaming("EXTRA_INFO").getText()
            clients = ClientsStreaming("INFO_RESOLVE")
            text = clients.getText()

        self["liste"] = StaticText(text)
        self["ScrollLabel"] = ScrollLabel(text)

        self["key_red"] = Button(_("Close"))
        self["actions"] = ActionMap(
            ["ColorActions", "SetupActions", "DirectionActions"], {
                "cancel": self.close,
                "ok": self.close,
                "red": self.close,
                "up": self["ScrollLabel"].pageUp,
                "down": self["ScrollLabel"].pageDown
            })
예제 #10
0
	def update_info(self):
		clients = ClientsStreaming("SHORT_ALL")
		clients2 = ClientsStreaming("INFO")
		text = clients.getText()
		text2 = clients2.getText()
		self["ScrollLabel"].setText(text or _("No clients streaming"))
		self["ScrollLabel2"].setText(text2 or _("No clients streaming"))
		self["key_blue"].setText(text and _("Stop Streams") or "")
		self.timer.startLongTimer(5)
예제 #11
0
	def update_info(self):
		clients = ClientsStreaming("SHORT_ALL")
		clients2 = ClientsStreaming("EXTRA_INFO")
		#clients3 = ClientsStreaming("SHORT_ALL")
		text = clients.getText()
		text2 = clients2.getText()
		self["ScrollLabel"].setText(text or _("Currently nothing is streamed to clients"))
		self["ScrollLabel2"].setText(text2 or _("Currently nothing is streamed to clients"))
		self["key_blue"].setText(text and _("Stop Streams") or "")
		self.timer.startLongTimer(5)
예제 #12
0
    def update_info(self):
        self.clients = []
        if self.streamServer:
            for x in self.streamServer.getConnectedClients():
                service_name = ServiceReference(
                    x[1]).getServiceName() or "(unknown service)"
                ip = x[0]
                if int(x[2]) == 0:
                    strtype = "S"
                else:
                    strtype = "T"
                try:
                    raw = socket.gethostbyaddr(ip)
                    ip = raw[0]
                except:
                    pass
                info = ("%s %-8s %s") % (strtype, ip, service_name)
                self.clients.append((info, (x[0], x[1])))
        if StreamServiceList and streamList:
            for x in StreamServiceList:
                ip = "ip n/a"
                service_name = "(unknown service)"
                for stream in streamList:
                    if hasattr(stream, 'getService') and stream.getService(
                    ) and stream.getService().__deref__() == x:
                        service_name = ServiceReference(
                            stream.ref.toString()).getServiceName()
                        ip = stream.clientIP or ip
            info = ("T %s %s") % (ip, service_name)
            self.clients.append((info, (-1, x)))

        self["total"].setText(
            _("Total Clients streaming: ") +
            str(ClientsStreaming("NUMBER").getText()))
        myclients = ClientsStreaming("EXTRA_INFO")
        text = myclients.getText()

        clients = ClientsStreaming("INFO_RESOLVE")
        text = clients.getText()
        self["menu"].setList(self.clients)
        if self.clients:
            self["info"].setText("")
            self["key_blue"].setText(text and _("Stop Streams") or "")
        else:
            self["info"].setText(text or _("No stream clients"))
        self.DynamicTimer.start(4000)
예제 #13
0
	def update_info(self):
		clients = ClientsStreaming("INFO_RESOLVE")
		text = clients.getText()
		self["ScrollLabel"].setText(text or _("No clients streaming"))
		self["key_blue"].setText(text and _("Stop Streams") or "")
		self.timer.startLongTimer(5)
예제 #14
0
	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
예제 #15
0
 def update_info(self):
     clients = ClientsStreaming('INFO_RESOLVE')
     text = clients.getText()
     self['ScrollLabel'].setText(text or _('No clients streaming'))
     self['key_blue'].setText(text and _('Stop Streams') or '')
     self.timer.startLongTimer(5)
예제 #16
0
    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_timer_wakeup"):
                self.wasPowerTimerWakeup = int(
                    open("/tmp/was_powertimer_wakeup",
                         "r").read()) and True or False
                os.remove("/tmp/was_powertimer_wakeup")
            # if this timer has been cancelled, just go to "end" state.
            if self.cancelled:
                return True

            if self.failed:
                return True

            if self.timerType == TIMERTYPE.WAKEUP:
                if Screens.Standby.inStandby:
                    Screens.Standby.inStandby.Power()
                return True

            elif self.timerType == TIMERTYPE.WAKEUPTOSTANDBY:
                return True

            elif self.timerType == TIMERTYPE.STANDBY:
                if not Screens.Standby.inStandby:  # not already in standby
                    Notifications.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 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
                    self.begin = time() + self.backoff
                    if self.end <= self.begin:
                        self.end = self.begin
                    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 = 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:

                # GML:2 - 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..
                #         I've also added () around the test and split them across lines
                #         to make it clearer what each test is.
                #				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())) 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()):
                #
                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
                    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 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:  # not a shutdown messagebox is 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:  # not a shutdown messagebox is 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:  # not a shutdown messagebox is 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:
            old_end = self.end
            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:  # not a shutdown messagebox is 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
예제 #17
0
    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
예제 #18
0
				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 '[RecordTimer] Recording or Recording due is next 15 mins, not return to deepstandby'
					return True

# Also check for someone streaming remotely - in which case we don't
# want DEEPSTANDBY.
# Might consider going to standby instead, but probably not worth it...
# Also might want to back off - but that is set-up for trying to start
# recordings, so has a low maximum delay.
#
				from Components.Converter.ClientsStreaming import ClientsStreaming;
				if int(ClientsStreaming("NUMBER").getText()) > 0:
					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())
							 + _("\n(DeepStandby request changed to Standby owing to there being streaming clients.)"), timeout = 180)
					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:
예제 #19
0
    def activate(self):
        next_state = self.state + 1
        self.log(5, "activating state %d" % next_state)

        if next_state == self.StatePrepared and self.timerType in (
                TIMERTYPE.AUTOSTANDBY, 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 = bool(
                    int(open("/tmp/was_powertimer_wakeup", "r").read()))
                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.AddNotificationWithUniqueIDCallback(
                        self.sendStandbyNotification,
                        "PT_StateChange",
                        MessageBox,
                        _("A power timer wants to set your %s %s to standby mode.\nGo to standby mode now?"
                          ) % (getMachineBrand(), getMachineName()),
                        timeout=180)
                return True

            elif self.timerType == TIMERTYPE.AUTOSTANDBY:
                if NavigationInstance.instance.getCurrentlyPlayingServiceReference(
                ) and ('0:0:0:0:0:0:0:0:0' in NavigationInstance.instance.
                       getCurrentlyPlayingServiceReference().toString()
                       or '4097:' in NavigationInstance.instance.
                       getCurrentlyPlayingServiceReference().toString()):
                    self.do_backoff()
                    # retry
                    self.begin = time() + self.backoff
                    if self.end <= self.begin:
                        self.end = self.begin
                    return False
                if not Screens.Standby.inStandby:  # Not already in standby
                    Notifications.AddNotificationWithUniqueIDCallback(
                        self.sendStandbyNotification,
                        "PT_StateChange",
                        MessageBox,
                        _("A power timer wants to set your %s %s to standby mode.\nGo to standby mode now?"
                          ) % (getMachineBrand(), getMachineName()),
                        timeout=180)
                    if self.autosleeprepeat == "once":
                        eActionMap.getInstance().unbindAction(
                            '', self.keyPressed)
                        return True
                    else:
                        self.begin = time() + int(self.autosleepdelay) * 60
                        if self.end <= self.begin:
                            self.end = self.begin
                else:
                    self.begin = time() + int(self.autosleepdelay) * 60
                    if self.end <= self.begin:
                        self.end = self.begin

            elif self.timerType == TIMERTYPE.AUTODEEPSTANDBY:
                # Check for there being any active
                # Movie playback or IPTV channel or
                # any streaming clients before going
                # to Deep Standby.  However, it is
                # possible to put the box into Standby
                # with the MoviePlayer still active
                # (it will play if the box is taken
                # out of Standby) - similarly for the
                # IPTV player. This should not prevent
                # a DeepStandby And check for existing
                # or imminent recordings, etc..  Also
                # added () around the test and split
                # them across lines to make it clearer
                # what each test is.
                from Components.Converter.ClientsStreaming import ClientsStreaming
                if ((not Screens.Standby.inStandby and NavigationInstance.
                     instance.getCurrentlyPlayingServiceReference() and
                     ('0:0:0:0:0:0:0:0:0' in NavigationInstance.instance.
                      getCurrentlyPlayingServiceReference().toString()
                      or '4097:' in NavigationInstance.instance.
                      getCurrentlyPlayingServiceReference().toString()) or
                     (int(ClientsStreaming("NUMBER").getText()) > 0))
                        or recordingsActive(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(Screens.Standby.QUIT_SHUTDOWN)
                        return True
                    else:
                        Notifications.AddNotificationWithUniqueIDCallback(
                            self.sendTryQuitMainloopNotification,
                            "PT_StateChange",
                            MessageBox,
                            _("A power timer wants to shut down your %s %s.\nShut down 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 recordingsActive(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(Screens.Standby.QUIT_SHUTDOWN)
                    else:
                        Notifications.AddNotificationWithUniqueIDCallback(
                            self.sendTryQuitMainloopNotification,
                            "PT_StateChange",
                            MessageBox,
                            _("A power timer wants to shut down your %s %s.\nShut down now?"
                              ) % (getMachineBrand(), getMachineName()),
                            timeout=180)
                return True

            elif self.timerType == TIMERTYPE.REBOOT:
                if recordingsActive(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(Screens.Standby.QUIT_REBOOT)
                    else:
                        Notifications.AddNotificationWithUniqueIDCallback(
                            self.sendTryToRebootNotification,
                            "PT_StateChange",
                            MessageBox,
                            _("A power timer wants to reboot your %s %s.\nReboot now?"
                              ) % (getMachineBrand(), getMachineName()),
                            timeout=180)
                return True

            elif self.timerType == TIMERTYPE.RESTART:
                if recordingsActive(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(Screens.Standby.QUIT_RESTART)
                    else:
                        Notifications.AddNotificationWithUniqueIDCallback(
                            self.sendTryToRestartNotification,
                            "PT_StateChange",
                            MessageBox,
                            _("A power timer wants to restart your %s %s user interface.\nRestart user interface now?"
                              ) % (getMachineBrand(), getMachineName()),
                            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.AddNotificationWithUniqueIDCallback(
                        self.sendStandbyNotification,
                        "PT_StateChange",
                        MessageBox,
                        _("A power timer wants to set your %s %s to standby mode.\nGo to standby mode now?"
                          ) % (getMachineBrand(), getMachineName()),
                        timeout=180)
            elif self.afterEvent == AFTEREVENT.DEEPSTANDBY:
                if recordingsActive(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(Screens.Standby.QUIT_SHUTDOWN)
                    else:
                        Notifications.AddNotificationWithUniqueIDCallback(
                            self.sendTryQuitMainloopNotification,
                            "PT_StateChange",
                            MessageBox,
                            _("A power timer wants to shut down your %s %s.\nShut down now?"
                              ) % (getMachineBrand(), getMachineName()),
                            timeout=180)
            return True