def failureCB_pip(self, answer): if answer: self.log(13, "ok, disable PIP") from Screens.InfoBar import InfoBar from Screens.InfoBarGenerics import InfoBarPiP from Components.ServiceEventTracker import InfoBarCount InfoBarInstance = InfoBarCount == 1 and InfoBar.instance if InfoBarInstance: InfoBarPiP.showPiP(InfoBarInstance) self.messageString += _("Disabled PIP.\n") else: self.log(14, "tried to disable PIP, suddenly found no InfoBar.instance") self.messageString += _("Tried to disable PIP, suddenly found no InfoBar.instance.\n") if config.recording.ask_to_abort_pip.value in ("ask", "abort_msg"): self.messageStringShow = True self.justTriedFreeingTuner = True else: self.log(14, "user didn't want to disable PIP, try other methods of freeing a tuner") self.messageBoxAnswerPending = False
def movePiP(self): if self.session.pipshown: InfoBarPiP.movePiP(self)
def activate(self): global wasRecTimerWakeup if os.path.exists("/tmp/was_rectimer_wakeup") and not wasRecTimerWakeup: wasRecTimerWakeup = int(open("/tmp/was_rectimer_wakeup", "r").read()) and True or False next_state = self.state + 1 if debug: self.log(5, "activating state %d" % next_state) # print "[TIMER] activate called",time(),next_state,self.first_try_prepare,' pending ',self.messageBoxAnswerPending,' justTried ',self.justTriedFreeingTuner,' show ',self.messageStringShow,self.messageString #TODO remove if next_state == self.StatePrepared: if self.messageBoxAnswerPending: self.start_prepare = time() + 1 # call again in 1 second return False if self.justTriedFreeingTuner: self.start_prepare = time() + 5 # tryPrepare in 5 seconds self.justTriedFreeingTuner = False return False if not self.justplay and not self.freespace(): Notifications.AddPopup(text = _("Write error while recording. Disk full?\n%s") % self.name, type = MessageBox.TYPE_ERROR, timeout = 5, id = "DiskFullMessage") self.failed = True self.next_activation = time() self.end = time() + 5 self.backoff = 0 return True if self.always_zap: if Screens.Standby.inStandby: self.wasInStandby = True #eActionMap.getInstance().bindAction('', -maxint - 1, self.keypress) #set service to zap after standby Screens.Standby.inStandby.prev_running_service = self.service_ref.ref Screens.Standby.inStandby.paused_service = None #wakeup standby Screens.Standby.inStandby.Power() self.log(5, "wakeup and zap to recording service") else: cur_zap_ref = NavigationInstance.instance.getCurrentlyPlayingServiceReference() if cur_zap_ref and not cur_zap_ref.getPath():# we do not zap away if it is no live service self.messageString += _("The TV was switched to the recording service!\n") self.messageStringShow = True self.setRecordingPreferredTuner() self.failureCB(True) self.log(5, "zap to recording service") if self.tryPrepare(): if debug: self.log(6, "prepare ok, waiting for begin") if self.messageStringShow: Notifications.AddNotification(MessageBox, _("In order to record a timer, a tuner was freed successfully:\n\n") + self.messageString, type=MessageBox.TYPE_INFO, timeout=20) # create file to "reserve" the filename # because another recording at the same time on another service can try to record the same event # i.e. cable / sat.. then the second recording needs an own extension... when we create the file # here then calculateFilename is happy if not self.justplay: open(self.Filename + ".ts", "w").close() # give the Trashcan a chance to clean up try: Trashcan.instance.cleanIfIdle() except Exception, e: print "[TIMER] Failed to call Trashcan.instance.cleanIfIdle()" print "[TIMER] Error:", e # fine. it worked, resources are allocated. self.next_activation = self.begin self.backoff = 0 return True self.log(7, "prepare failed") if self.first_try_prepare == 0: # (0) try to make a tuner available by disabling PIP self.first_try_prepare += 1 from Screens.InfoBar import InfoBar from Screens.InfoBarGenerics import InfoBarPiP from Components.ServiceEventTracker import InfoBarCount InfoBarInstance = InfoBarCount == 1 and InfoBar.instance if InfoBarInstance and InfoBarPiP.pipShown(InfoBarInstance) == True: if config.recording.ask_to_abort_pip.value == "ask": self.log(8, "asking user to disable PIP") self.messageBoxAnswerPending = True Notifications.AddNotificationWithCallback(self.failureCB_pip, MessageBox, _("A timer failed to record!\nDisable PIP and try again?\n"), timeout=20) elif config.recording.ask_to_abort_pip.value in ("abort_no_msg", "abort_msg"): self.log(8, "disable PIP without asking") self.setRecordingPreferredTuner() self.failureCB_pip(True) return False else: self.log(8, "currently no PIP active... so we dont need to stop it") if self.first_try_prepare == 1: # (1) try to make a tuner available by aborting pseudo recordings self.first_try_prepare += 1 self.backoff = 0 if len(NavigationInstance.instance.getRecordings(False,pNavigation.isPseudoRecording)) > 0: if config.recording.ask_to_abort_pseudo_rec.value == "ask": self.log(8, "asking user to abort pseudo recordings") self.messageBoxAnswerPending = True Notifications.AddNotificationWithCallback(self.failureCB_pseudo_rec, MessageBox, _("A timer failed to record!\nAbort pseudo recordings (e.g. EPG refresh) and try again?\n"), timeout=20) elif config.recording.ask_to_abort_pseudo_rec.value in ("abort_no_msg", "abort_msg"): self.log(8, "abort pseudo recordings without asking") self.setRecordingPreferredTuner() self.failureCB_pseudo_rec(True) return False else: self.log(8, "currently no pseudo recordings active... so we dont need to stop it") if self.first_try_prepare == 2: # (2) try to make a tuner available by aborting streaming self.first_try_prepare += 1 self.backoff = 0 if len(NavigationInstance.instance.getRecordings(False,pNavigation.isStreaming)) > 0: if config.recording.ask_to_abort_streaming.value == "ask": self.log(8, "asking user to abort streaming") self.messageBoxAnswerPending = True Notifications.AddNotificationWithCallback(self.failureCB_streaming, MessageBox, _("A timer failed to record!\nAbort streaming and try again?\n"), timeout=20) elif config.recording.ask_to_abort_streaming.value in ("abort_no_msg", "abort_msg"): self.log(8, "abort streaming without asking") self.setRecordingPreferredTuner() self.failureCB_streaming(True) return False else: self.log(8, "currently no streaming active... so we dont need to stop it") if self.first_try_prepare == 3: # (3) try to make a tuner available by switching live TV to the recording service self.first_try_prepare += 1 self.backoff = 0 cur_ref = NavigationInstance.instance.getCurrentlyPlayingServiceReference() if cur_ref and not cur_ref.getPath(): if Screens.Standby.inStandby: self.setRecordingPreferredTuner() self.failureCB(True) elif not config.recording.asktozap.value: self.log(8, "asking user to zap away") self.messageBoxAnswerPending = True Notifications.AddNotificationWithCallback(self.failureCB, MessageBox, _("A timer failed to record!\nDisable TV and try again?\n"), timeout=20) else: # zap without asking self.log(9, "zap without asking") self.setRecordingPreferredTuner() self.failureCB(True) return False elif cur_ref: self.log(8, "currently running service is not a live service.. so stopping it makes no sense") else: self.log(8, "currently no service running... so we dont need to stop it") if self.first_try_prepare == 4: # (4) freeing a tuner failed self.first_try_prepare += 1 self.log(8, "freeing a tuner failed") if self.messageString: Notifications.AddNotification(MessageBox, _("No tuner is available for recording a timer!\n\nThe following methods of freeing a tuner were tried without success:\n\n") + self.messageString, type=MessageBox.TYPE_INFO, timeout=20) else: Notifications.AddNotification(MessageBox, _("No tuner is available for recording a timer!\n"), type=MessageBox.TYPE_INFO, timeout=20) return False
def activate(self): global wasRecTimerWakeup next_state = self.state + 1 self.log(5, "activating state %d" % next_state) # print "[TIMER] activate called",time(),next_state,self.first_try_prepare,' pending ',self.messageBoxAnswerPending,' justTried ',self.justTriedFreeingTuner,' show ',self.messageStringShow,self.messageString #TODO remove if next_state == self.StatePrepared: if self.messageBoxAnswerPending: self.start_prepare = time() + 1 # call again in 1 second return False if self.justTriedFreeingTuner: self.start_prepare = time() + 5 # tryPrepare in 5 seconds self.justTriedFreeingTuner = False return False if not self.justplay and not self.freespace(): Notifications.AddPopup(text = _("Write error while recording. Disk full?\n%s") % self.name, type = MessageBox.TYPE_ERROR, timeout = 5, id = "DiskFullMessage") self.failed = True self.next_activation = time() self.end = time() + 5 self.backoff = 0 return True if self.always_zap: if Screens.Standby.inStandby: self.wasInStandby = True eActionMap.getInstance().bindAction('', -maxint - 1, self.keypress) #set service to zap after standby Screens.Standby.inStandby.prev_running_service = self.service_ref.ref Screens.Standby.inStandby.paused_service = None #wakeup standby Screens.Standby.inStandby.Power() self.log(5, "wakeup and zap to recording service") else: cur_zap_ref = NavigationInstance.instance.getCurrentlyPlayingServiceReference() if cur_zap_ref and not cur_zap_ref.getPath():# we do not zap away if it is no live service self.messageString += _("The TV was switched to the recording service!\n") self.messageStringShow = True self.setRecordingPreferredTuner() self.failureCB(True) self.log(5, "zap to recording service") if self.tryPrepare(): self.log(6, "prepare ok, waiting for begin") if self.messageStringShow: Notifications.AddNotification(MessageBox, _("In order to record a timer, a tuner was freed successfully:\n\n") + self.messageString, type=MessageBox.TYPE_INFO, timeout=20) # create file to "reserve" the filename # because another recording at the same time on another service can try to record the same event # i.e. cable / sat.. then the second recording needs an own extension... when we create the file # here then calculateFilename is happy if not self.justplay: open(self.Filename + ".ts", "w").close() # give the Trashcan a chance to clean up try: Trashcan.instance.cleanIfIdle() except Exception, e: print "[TIMER] Failed to call Trashcan.instance.cleanIfIdle()" print "[TIMER] Error:", e # fine. it worked, resources are allocated. self.next_activation = self.begin self.backoff = 0 return True self.log(7, "prepare failed") if self.first_try_prepare == 0: # (0) try to make a tuner available by disabling PIP self.first_try_prepare += 1 from Screens.InfoBar import InfoBar from Screens.InfoBarGenerics import InfoBarPiP from Components.ServiceEventTracker import InfoBarCount InfoBarInstance = InfoBarCount == 1 and InfoBar.instance if InfoBarInstance and InfoBarPiP.pipShown(InfoBarInstance) == True: if config.recording.ask_to_abort_pip.value == "ask": self.log(8, "asking user to disable PIP") self.messageBoxAnswerPending = True Notifications.AddNotificationWithCallback(self.failureCB_pip, MessageBox, _("A timer failed to record!\nDisable PIP and try again?\n"), timeout=20) elif config.recording.ask_to_abort_pip.value in ("abort_no_msg", "abort_msg"): self.log(8, "disable PIP without asking") self.setRecordingPreferredTuner() self.failureCB_pip(True) return False else: self.log(8, "currently no PIP active... so we dont need to stop it") if self.first_try_prepare == 1: # (1) try to make a tuner available by aborting pseudo recordings self.first_try_prepare += 1 self.backoff = 0 if len(NavigationInstance.instance.getRecordings(False,pNavigation.isPseudoRecording)) > 0: if config.recording.ask_to_abort_pseudo_rec.value == "ask": self.log(8, "asking user to abort pseudo recordings") self.messageBoxAnswerPending = True Notifications.AddNotificationWithCallback(self.failureCB_pseudo_rec, MessageBox, _("A timer failed to record!\nAbort pseudo recordings (e.g. EPG refresh) and try again?\n"), timeout=20) elif config.recording.ask_to_abort_pseudo_rec.value in ("abort_no_msg", "abort_msg"): self.log(8, "abort pseudo recordings without asking") self.setRecordingPreferredTuner() self.failureCB_pseudo_rec(True) return False else: self.log(8, "currently no pseudo recordings active... so we dont need to stop it") if self.first_try_prepare == 2: # (2) try to make a tuner available by aborting streaming self.first_try_prepare += 1 self.backoff = 0 if len(NavigationInstance.instance.getRecordings(False,pNavigation.isStreaming)) > 0: if config.recording.ask_to_abort_streaming.value == "ask": self.log(8, "asking user to abort streaming") self.messageBoxAnswerPending = True Notifications.AddNotificationWithCallback(self.failureCB_streaming, MessageBox, _("A timer failed to record!\nAbort streaming and try again?\n"), timeout=20) elif config.recording.ask_to_abort_streaming.value in ("abort_no_msg", "abort_msg"): self.log(8, "abort streaming without asking") self.setRecordingPreferredTuner() self.failureCB_streaming(True) return False else: self.log(8, "currently no streaming active... so we dont need to stop it") if self.first_try_prepare == 3: # (3) try to make a tuner available by switching live TV to the recording service self.first_try_prepare += 1 self.backoff = 0 cur_ref = NavigationInstance.instance.getCurrentlyPlayingServiceReference() if cur_ref and not cur_ref.getPath(): if Screens.Standby.inStandby: self.setRecordingPreferredTuner() self.failureCB(True) elif not config.recording.asktozap.value: self.log(8, "asking user to zap away") self.messageBoxAnswerPending = True Notifications.AddNotificationWithCallback(self.failureCB, MessageBox, _("A timer failed to record!\nDisable TV and try again?\n"), timeout=20) else: # zap without asking self.log(9, "zap without asking") self.setRecordingPreferredTuner() self.failureCB(True) return False elif cur_ref: self.log(8, "currently running service is not a live service.. so stopping it makes no sense") else: self.log(8, "currently no service running... so we dont need to stop it") if self.first_try_prepare == 4: # (4) freeing a tuner failed self.first_try_prepare += 1 self.log(8, "freeing a tuner failed") if self.messageString: Notifications.AddNotification(MessageBox, _("No tuner is available for recording a timer!\n\nThe following methods of freeing a tuner were tried without success:\n\n") + self.messageString, type=MessageBox.TYPE_INFO, timeout=20) else: Notifications.AddNotification(MessageBox, _("No tuner is available for recording a timer!\n"), type=MessageBox.TYPE_INFO, timeout=20) return False