コード例 #1
0
 def displayPlayedName(self, ref, index, n):
     from Tools import Notifications
     Notifications.AddPopup(text=_("%s/%s: %s") %
                            (index, n, self.ref2HumanName(ref)),
                            type=MessageBox.TYPE_INFO,
                            timeout=5)
コード例 #2
0
	def _autotimerErrback(self, failure):
		print("[EPGRefresh] Debug: AutoTimer failed:" + str(failure))
		if config.plugins.epgrefresh.enablemessage.value:
			Notifications.AddPopup(_("AutoTimer failed with error %s") % (str(failure)),
				MessageBox.TYPE_ERROR, 100)
		self._nextTodo()
コード例 #3
0
	def _onDBusError(self, error):
		Log.w("DBUS ERROR! %s" %(error,))
		Notifications.AddPopup("%s" %(error,), MessageBox.TYPE_ERROR, -1, domain=NOTIFICATION_DOMAIN_STREAMSERVER)
コード例 #4
0
ファイル: RecordTimer.py プロジェクト: takitr/enigma2
	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
コード例 #5
0
	def activate(self):
		next_state = self.state + 1
		self.log(5, "activating state %d" % next_state)

		if next_state == self.StatePrepared:
			if not self.justplay and not self.freespace():
				Notifications.AddPopup(text = _("Write error while recording. Disk full?\n%s") % self.name, type = MessageBox.TYPE_ERROR, timeout = 5, id = "DiskFullMessage")
				self.failed = True
				self.next_activation = time()
				self.end = time() + 5
				self.backoff = 0
				return True

			if self.always_zap:
				if Screens.Standby.inStandby:
					self.wasInStandby = True
					eActionMap.getInstance().bindAction('', -maxint - 1, self.keypress)
					#set service to zap after standby
					Screens.Standby.inStandby.prev_running_service = self.service_ref.ref
					Screens.Standby.inStandby.paused_service = None
					#wakeup standby
					Screens.Standby.inStandby.Power()
					self.log(5, "wakeup and zap to recording service")
				else:
					cur_zap_ref = NavigationInstance.instance.getCurrentlyPlayingServiceReference()
					if cur_zap_ref and not cur_zap_ref.getPath():# we do not zap away if it is no live service
						Notifications.AddNotification(MessageBox, _("In order to record a timer, the TV was switched to the recording service!\n"), type=MessageBox.TYPE_INFO, timeout=20)
						self.failureCB(True)
						self.log(5, "zap to recording service")

			if self.tryPrepare():
				self.log(6, "prepare ok, waiting for begin")
				# create file to "reserve" the filename
				# because another recording at the same time on another service can try to record the same event
				# i.e. cable / sat.. then the second recording needs an own extension... when we create the file
				# here than calculateFilename is happy
				if not self.justplay:
					open(self.Filename + ".ts", "w").close()
					# Give the Trashcan a chance to clean up
					try:
						Trashcan.instance.cleanIfIdle()
					except Exception, e:
						print "[TIMER] Failed to call Trashcan.instance.cleanIfIdle()"
						print "[TIMER] Error:", e
				# fine. it worked, resources are allocated.
				self.next_activation = self.begin
				self.backoff = 0
				return True

			self.log(7, "prepare failed")
			if self.first_try_prepare:
				self.first_try_prepare = False
				cur_ref = NavigationInstance.instance.getCurrentlyPlayingServiceReference()
				if cur_ref and not cur_ref.getPath():
					if not config.recording.asktozap.value:
						self.log(8, "asking user to zap away")
						Notifications.AddNotificationWithCallback(self.failureCB, MessageBox, _("A timer failed to record!\nDisable TV and try again?\n"), timeout=20)
					else: # zap without asking
						self.log(9, "zap without asking")
						Notifications.AddNotification(MessageBox, _("In order to record a timer, the TV was switched to the recording service!\n"), type=MessageBox.TYPE_INFO, timeout=20)
						self.failureCB(True)
				elif cur_ref:
					self.log(8, "currently running service is not a live service.. so stop it makes no sense")
				else:
					self.log(8, "currently no service running... so we dont need to stop it")
			return False
コード例 #6
0
	def startCheck(self):
		self.database = SRDatabase(serienRecDataBaseFilePath)
		global autoCheckFinished
		autoCheckFinished = False

		print "[SerienRecorder] settings:"
		print "[SerienRecorder] manuell:", self.manuell
		print "[SerienRecorder] tvplaner_manuell:", self.tvplaner_manuell
		print "[SerienRecorder] uhrzeit check:", config.plugins.serienRec.timeUpdate.value

		lt = time.localtime()
		self.uhrzeit = time.strftime("%d.%m.%Y - %H:%M:%S", lt)

		global refreshTimer
		global refreshTimerConnection

		SRLogger.checkFileAccess()

		SRLogger.writeLog("\n---------' %s '---------" % self.uhrzeit, True)

		if not self.manuell and not initDB():
			self.askForDSB()
			return

		if not self.database.hasMarkers() and not config.plugins.serienRec.tvplaner and not config.plugins.serienRec.tvplaner_create_marker:
			SRLogger.writeLog("\n---------' Starte Auto-Check um %s '---------" % self.uhrzeit, True)
			print "[SerienRecorder] check: Tabelle SerienMarker leer."
			SRLogger.writeLog("Es sind keine Serien-Marker vorhanden - Auto-Check kann nicht ausgeführt werden.", True)
			SRLogger.writeLog("---------' Auto-Check beendet '---------", True)
			self.askForDSB()
			return

		if not self.database.hasChannels():
			SRLogger.writeLog("\n---------' Starte Auto-Check um %s '---------" % self.uhrzeit, True)
			print "[SerienRecorder] check: Tabelle Channels leer."
			SRLogger.writeLog("Es wurden keine Sender zugeordnet - Auto-Check kann nicht ausgeführt werden.", True)
			SRLogger.writeLog("---------' Auto-Check beendet '---------", True)
			self.askForDSB()
			return

		if refreshTimer:
			refreshTimer.stop()
			refreshTimer = None

			if refreshTimerConnection:
				refreshTimerConnection = None

			print "[SerienRecorder] Auto-Check Timer stop."
			SRLogger.writeLog("Auto-Check stop.", True)

		if config.plugins.serienRec.autochecktype.value == "1" and config.plugins.serienRec.timeUpdate.value:
			deltatime = self.getNextAutoCheckTimer(lt)
			refreshTimer = eTimer()
			if isDreamOS():
				refreshTimerConnection = refreshTimer.timeout.connect(self.startCheck)
			else:
				refreshTimer.callback.append(self.startCheck)
			refreshTimer.start(((deltatime * 60) + random.randint(0, int(config.plugins.serienRec.maxDelayForAutocheck.value)*60)) * 1000, True)

			print "[SerienRecorder] Auto-Check Uhrzeit-Timer gestartet."
			print "[SerienRecorder] Verbleibende Zeit: %s Stunden" % (TimeHelpers.td2HHMMstr(datetime.timedelta(minutes=deltatime+int(config.plugins.serienRec.maxDelayForAutocheck.value))))
			SRLogger.writeLog("Auto-Check Uhrzeit-Timer gestartet.", True)
			SRLogger.writeLog("Verbleibende Zeit: %s Stunden" % TimeHelpers.td2HHMMstr(datetime.timedelta(minutes=deltatime+int(config.plugins.serienRec.maxDelayForAutocheck.value))), True)

		if config.plugins.serienRec.AutoBackup.value == "before":
			createBackup()

		SRLogger.reset()
		from SerienRecorderTVPlaner import resetTVPlanerHTMLBackup
		resetTVPlanerHTMLBackup()
		self.database.removeExpiredTimerConflicts()

		if self.tvplaner_manuell and config.plugins.serienRec.tvplaner.value:
			print "\n---------' Starte Check um %s (TV-Planer manuell) '---------" % self.uhrzeit
			SRLogger.writeLog("\n---------' Starte Check um %s (TV-Planer manuell) '---------\n" % self.uhrzeit, True)
		elif self.manuell:
			print "\n---------' Starte Check um %s (manuell) '---------" % self.uhrzeit
			SRLogger.writeLog("\n---------' Starte Check um %s (manuell) '---------\n" % self.uhrzeit, True)
		elif config.plugins.serienRec.tvplaner.value:
			print "\n---------' Starte Auto-Check um %s (TV-Planer auto) '---------" % self.uhrzeit
			SRLogger.writeLog("\n---------' Starte Auto-Check um %s (TV-Planer auto) '---------\n" % self.uhrzeit, True)
		else:
			print "\n---------' Starte Auto-Check um %s (auto)'---------" % self.uhrzeit
			SRLogger.writeLog("\n---------' Starte Auto-Check um %s (auto)'---------\n" % self.uhrzeit, True)
			if config.plugins.serienRec.showNotification.value in ("1", "3"):
				Notifications.AddPopup("SerienRecorder Suchlauf nach neuen Timern wurde gestartet.", MessageBox.TYPE_INFO, timeout=3, id="Suchlauf wurde gestartet")

		if config.plugins.serienRec.writeLogVersion.value:
			SRLogger.writeLog("STB Type: %s\nImage: %s" % (STBHelpers.getSTBType(), STBHelpers.getImageVersionString()), True)
			SRLogger.writeLog("SR Version: %s\nDatenbank Version: %s" % (config.plugins.serienRec.showversion.value, str(self.database.getVersion())), True)
			SRLogger.writeLog("Skin Auflösung: %s x %s" % (str(getDesktop(0).size().width()), str(getDesktop(0).size().height())), True)

		sMsg = "\nDEBUG Filter: "
		if config.plugins.serienRec.writeLogChannels.value:
			sMsg += "Senderliste "
		if config.plugins.serienRec.writeLogAllowedEpisodes.value:
			sMsg += "Episoden "
		if config.plugins.serienRec.writeLogAdded.value:
			sMsg += "Added "
		if config.plugins.serienRec.writeLogDisk.value:
			sMsg += "Disk "
		if config.plugins.serienRec.writeLogTimeRange.value:
			sMsg += "Tageszeit "
		if config.plugins.serienRec.writeLogTimeLimit.value:
			sMsg += "Zeitlimit "
		if config.plugins.serienRec.writeLogTimerDebug.value:
			sMsg += "Timer "
			SRLogger.writeLog(sMsg, True)

		self.markers = []
		self.messageList = []
		self.speedStartTime = time.clock()

		# teste Verbindung ins Internet
		if not testWebConnection():
			SRLogger.writeLog("\nKeine Verbindung ins Internet. Check wurde abgebrochen!!\n", True)

			# Statistik
			self.speedEndTime = time.clock()
			speedTime = (self.speedEndTime - self.speedStartTime)
			SRLogger.writeLog("---------' Auto-Check beendet ( Ausführungsdauer: %3.2f Sek.)'---------" % speedTime, True)
			print "[SerienRecorder] ---------' Auto-Check beendet ( Ausführungsdauer: %3.2f Sek.)'---------" % speedTime

			from SerienRecorderTVPlaner import backupTVPlanerHTML
			backupTVPlanerHTML()

			global autoCheckFinished
			autoCheckFinished = True

			if config.plugins.serienRec.AutoBackup.value == "after":
				createBackup()

			# in den deep-standby fahren.
			self.askForDSB()
			return

		# Versuche Verzeichnisse zu erreichen
		try:
			SRLogger.writeLog("\nPrüfe konfigurierte Aufnahmeverzeichnisse:", True)
			recordDirectories = self.database.getRecordDirectories(config.plugins.serienRec.savetopath.value)
			for directory in recordDirectories:
				SRLogger.writeLog("   %s" % directory, True)
				os.path.exists(directory)
		except:
			SRLogger.writeLog("Es konnten nicht alle Aufnahmeverzeichnisse gefunden werden", True)

		# suche nach neuen Serien, Covern und Planer-Cache
		from twisted.internet import reactor
		from SerienRecorderSeriesPlanner import serienRecSeriesPlanner
		seriesPlanner = serienRecSeriesPlanner(self.manuell)
		reactor.callFromThread(seriesPlanner.updatePlanerData())

		#if config.plugins.serienRec.downloadCover.value:
		#	reactor.callFromThread(self.getMarkerCover())

		self.startCheckTransmissions()
コード例 #7
0
class RecordTimerEntry(timer.TimerEntry, object):
######### the following static methods and members are only in use when the box is in (soft) standby
	wasInStandby = False
	wasInDeepStandby = False
	receiveRecordEvents = False

	@staticmethod
	def keypress(key=None, flag=1):
		if flag and (RecordTimerEntry.wasInStandby or RecordTimerEntry.wasInDeepStandby):
			RecordTimerEntry.wasInStandby = False
			RecordTimerEntry.wasInDeepStandby = False
			eActionMap.getInstance().unbindAction('', RecordTimerEntry.keypress)

	@staticmethod
	def setWasInDeepStandby():
		RecordTimerEntry.wasInDeepStandby = True
		eActionMap.getInstance().bindAction('', -maxint - 1, RecordTimerEntry.keypress)

	@staticmethod
	def setWasInStandby():
		if not RecordTimerEntry.wasInStandby:
			if not RecordTimerEntry.wasInDeepStandby:
				eActionMap.getInstance().bindAction('', -maxint - 1, RecordTimerEntry.keypress)
			RecordTimerEntry.wasInDeepStandby = False
			RecordTimerEntry.wasInStandby = True

	@staticmethod
	def shutdown():
		quitMainloop(1)

	@staticmethod
	def staticGotRecordEvent(recservice, event):
		if event == iRecordableService.evEnd:
			print "RecordTimer.staticGotRecordEvent(iRecordableService.evEnd)"
			if not checkForRecordings():
				print "No recordings busy of sceduled within 6 minutes so shutdown"
				RecordTimerEntry.shutdown() # immediate shutdown
		elif event == iRecordableService.evStart:
			print "RecordTimer.staticGotRecordEvent(iRecordableService.evStart)"

	@staticmethod
	def stopTryQuitMainloop():
		print "RecordTimer.stopTryQuitMainloop"
		NavigationInstance.instance.record_event.remove(RecordTimerEntry.staticGotRecordEvent)
		RecordTimerEntry.receiveRecordEvents = False

	@staticmethod
	def TryQuitMainloop():
		if not RecordTimerEntry.receiveRecordEvents and Screens.Standby.inStandby:
			print "RecordTimer.TryQuitMainloop"
			NavigationInstance.instance.record_event.append(RecordTimerEntry.staticGotRecordEvent)
			RecordTimerEntry.receiveRecordEvents = True
			# send fake event.. to check if another recordings are running or
			# other timers start in a few seconds
			RecordTimerEntry.staticGotRecordEvent(None, iRecordableService.evEnd)
#################################################################

	def __init__(self, serviceref, begin, end, name, description, eit, disabled = False, justplay = False, afterEvent = AFTEREVENT.AUTO, checkOldTimers = False, dirname = None, tags = None, descramble = True, record_ecm = False, always_zap = False, zap_wakeup = "always", rename_repeat = True, conflict_detection = True, pipzap = False):
		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

		assert isinstance(serviceref, ServiceReference)

		if serviceref and serviceref.isRecordable():
			self.service_ref = serviceref
		else:
			self.service_ref = ServiceReference(None)
		self.eit = eit
		self.dontSave = False
		self.name = name
		self.description = description
		self.disabled = disabled
		self.timer = None
		self.__record_service = None
		self.start_prepare = 0
		self.justplay = justplay
		self.always_zap = always_zap
		self.zap_wakeup = zap_wakeup
		self.pipzap = pipzap
		self.afterEvent = afterEvent
		self.dirname = dirname
		self.dirnameHadToFallback = False
		self.autoincrease = False
		self.autoincreasetime = 3600 * 24 # 1 day
		self.tags = tags or []
		self.descramble = descramble
		self.record_ecm = record_ecm
		self.rename_repeat = rename_repeat
		self.conflict_detection = conflict_detection
		self.external = self.external_prev = False
		self.setAdvancedPriorityFrontend = None
		if SystemInfo["priority_tuner_available"] and (SystemInfo["DVB-T_priority_tuner_available"] or SystemInfo["DVB-C_priority_tuner_available"] or SystemInfo["DVB-S_priority_tuner_available"] or SystemInfo["ATSC_priority_tuner_available"]):
			rec_ref = self.service_ref and self.service_ref.ref
			str_service = rec_ref and rec_ref.toString()
			if str_service and '%3a//' not in str_service and not str_service.rsplit(":", 1)[1].startswith("/"):
				type_service = rec_ref.getUnsignedData(4) >> 16
				if type_service == 0xEEEE:
					if SystemInfo["DVB-T_priority_tuner_available"] and config.usage.recording_frontend_priority_dvbt.value != "-2":
						if config.usage.recording_frontend_priority_dvbt.value != config.usage.frontend_priority.value:
							self.setAdvancedPriorityFrontend = config.usage.recording_frontend_priority_dvbt.value
					if SystemInfo["ATSC_priority_tuner_available"] and config.usage.recording_frontend_priority_atsc.value != "-2":
						if config.usage.recording_frontend_priority_atsc.value != config.usage.frontend_priority.value:
							self.setAdvancedPriorityFrontend = config.usage.recording_frontend_priority_atsc.value
				elif type_service == 0xFFFF:
					if SystemInfo["DVB-C_priority_tuner_available"] and config.usage.recording_frontend_priority_dvbc.value != "-2":
						if config.usage.recording_frontend_priority_dvbc.value != config.usage.frontend_priority.value:
							self.setAdvancedPriorityFrontend = config.usage.recording_frontend_priority_dvbc.value
					if SystemInfo["ATSC_priority_tuner_available"] and config.usage.recording_frontend_priority_atsc.value != "-2":
						if config.usage.recording_frontend_priority_atsc.value != config.usage.frontend_priority.value:
							self.setAdvancedPriorityFrontend = config.usage.recording_frontend_priority_atsc.value
				else:
					if SystemInfo["DVB-S_priority_tuner_available"] and config.usage.recording_frontend_priority_dvbs.value != "-2":
						if config.usage.recording_frontend_priority_dvbs.value != config.usage.frontend_priority.value:
							self.setAdvancedPriorityFrontend = config.usage.recording_frontend_priority_dvbs.value
		self.needChangePriorityFrontend = self.setAdvancedPriorityFrontend is not None or config.usage.recording_frontend_priority.value != "-2" and config.usage.recording_frontend_priority.value != config.usage.frontend_priority.value
		self.change_frontend = False
		self.InfoBarInstance = Screens.InfoBar.InfoBar.instance
		self.ts_dialog = None
		self.log_entries = []
		self.flags = set()
		self.resetState()

	def __repr__(self):
		return "RecordTimerEntry(name=%s, begin=%s, serviceref=%s, justplay=%s)" % (self.name, ctime(self.begin), self.service_ref, self.justplay)

	def log(self, code, msg):
		self.log_entries.append((int(time()), code, msg))
		print "[TIMER]", msg

	def calculateFilename(self, name=None):
		service_name = self.service_ref.getServiceName()
		begin_date = strftime("%Y%m%d %H%M", localtime(self.begin))
		name = name or self.name
		filename = begin_date + " - " + service_name
		if name:
			if config.recording.filename_composition.value == "event":
				filename = name + ' - ' + begin_date + "_" + service_name
			elif config.recording.filename_composition.value == "short":
				filename = strftime("%Y%m%d", localtime(self.begin)) + " - " + name
			elif config.recording.filename_composition.value == "long":
				filename += " - " + name + " - " + self.description
			else:
				filename += " - " + name # standard

		if config.recording.ascii_filenames.value:
			filename = ASCIItranslit.legacyEncode(filename)
		if not self.dirname:
			dirname = findSafeRecordPath(defaultMoviePath())
		else:
			dirname = findSafeRecordPath(self.dirname)
			if dirname is None:
				dirname = findSafeRecordPath(defaultMoviePath())
				self.dirnameHadToFallback = True
		if not dirname:
			return None
		self.Filename = Directories.getRecordingFilename(filename, dirname)
		self.log(0, "Filename calculated as: '%s'" % self.Filename)
		return self.Filename

	def tryPrepare(self):
		if self.justplay:
			return True
		else:
			if not self.calculateFilename():
				self.do_backoff()
				self.start_prepare = time() + self.backoff
				return False
			rec_ref = self.service_ref and self.service_ref.ref
			if rec_ref and rec_ref.flags & eServiceReference.isGroup:
				rec_ref = getBestPlayableServiceReference(rec_ref, eServiceReference())
				if not rec_ref:
					self.log(1, "'get best playable service for group... record' failed")
					return False
			self.setRecordingPreferredTuner()
			self.record_service = rec_ref and NavigationInstance.instance.recordService(rec_ref)

			if not self.record_service:
				self.log(1, "'record service' failed")
				self.setRecordingPreferredTuner(setdefault=True)
				return False

			name = self.name
			description = self.description
			if self.repeated:
				epgcache = eEPGCache.getInstance()
				queryTime=self.begin+(self.end-self.begin)/2
				evt = epgcache.lookupEventTime(rec_ref, queryTime)
				if evt:
					if self.rename_repeat:
						event_description = evt.getShortDescription()
						if not event_description:
							event_description = evt.getExtendedDescription()
						if event_description and event_description != description:
							description = event_description
						event_name = evt.getEventName()
						if event_name and event_name != name:
							name = event_name
							if not self.calculateFilename(event_name):
								self.do_backoff()
								self.start_prepare = time() + self.backoff
								return False
					event_id = evt.getEventId()
				else:
					event_id = -1
			else:
				event_id = self.eit
				if event_id is None:
					event_id = -1

			prep_res=self.record_service.prepare(self.Filename + self.record_service.getFilenameExtension(), self.begin, self.end, event_id, name.replace("\n", ""), description.replace("\n", ""), ' '.join(self.tags), bool(self.descramble), bool(self.record_ecm))
			if prep_res:
				if prep_res == -255:
					self.log(4, "failed to write meta information")
				else:
					self.log(2, "'prepare' failed: error %d" % prep_res)

				# we must calc nur start time before stopRecordService call because in Screens/Standby.py TryQuitMainloop tries to get
				# the next start time in evEnd event handler...
				self.do_backoff()
				self.start_prepare = time() + self.backoff

				NavigationInstance.instance.stopRecordService(self.record_service)
				self.record_service = None
				self.setRecordingPreferredTuner(setdefault=True)
				return False
			return True

	def do_backoff(self):
		if self.backoff == 0:
			self.backoff = 5
		else:
			self.backoff *= 2
			if self.backoff > 100:
				self.backoff = 100
		self.log(10, "backoff: retry in %d seconds" % self.backoff)

	def sendactivesource(self):
		if SystemInfo["HasHDMI-CEC"] and config.hdmicec.enabled.value and config.hdmicec.sourceactive_zaptimers.value:
			import Components.HdmiCec
			Components.HdmiCec.hdmi_cec.sendMessage(0, "sourceactive")
			print "[TIMER] sourceactive was send"

	def activate(self):
		next_state = self.state + 1
		self.log(5, "activating state %d" % next_state)

		if next_state == 1:
			if self.always_zap:
				if Screens.Standby.inStandby:
					self.log(5, "wakeup and zap to recording service")
					RecordTimerEntry.setWasInStandby()
					#set service to zap after standby
					Screens.Standby.inStandby.prev_running_service = self.service_ref.ref
					Screens.Standby.inStandby.paused_service = None
					#wakeup standby
					Screens.Standby.inStandby.Power()
				else:
					self.sendactivesource()
					if RecordTimerEntry.wasInDeepStandby:
						RecordTimerEntry.setWasInStandby()
					cur_ref = NavigationInstance.instance.getCurrentlyPlayingServiceReference()
					if not cur_ref or not cur_ref.getPath():
						if self.checkingTimeshiftRunning():
							if self.ts_dialog is None:
								self.openChoiceActionBeforeZap()
						else:
							Notifications.AddNotification(MessageBox, _("In order to record a timer, the TV was switched to the recording service!\n"), type=MessageBox.TYPE_INFO, timeout=20)
							self.setRecordingPreferredTuner()
							self.failureCB(True)
							self.log(5, "zap to recording service")

		if next_state == self.StatePrepared:
			if self.tryPrepare():
				self.log(6, "prepare ok, waiting for begin")
				# create file to "reserve" the filename
				# because another recording at the same time on another service can try to record the same event
				# i.e. cable / sat.. then the second recording needs an own extension... when we create the file
				# here than calculateFilename is happy
				if not self.justplay:
					open(self.Filename + self.record_service.getFilenameExtension(), "w").close()
					# Give the Trashcan a chance to clean up
					try:
						Trashcan.instance.cleanIfIdle(self.Filename)
					except Exception, e:
						 print "[TIMER] Failed to call Trashcan.instance.cleanIfIdle()"
						 print "[TIMER] Error:", e
				# fine. it worked, resources are allocated.
				self.next_activation = self.begin
				self.backoff = 0
				return True
			self.log(7, "prepare failed")
			if eStreamServer.getInstance().getConnectedClients():
				eStreamServer.getInstance().stopStream()
				return False
			if self.first_try_prepare or (self.ts_dialog is not None and not self.checkingTimeshiftRunning()):
				self.first_try_prepare = False
				cur_ref = NavigationInstance.instance.getCurrentlyPlayingServiceReference()
				if cur_ref and not cur_ref.getPath():
					if self.always_zap:
						return False
					if Screens.Standby.inStandby:
						self.setRecordingPreferredTuner()
						self.failureCB(True)
					elif self.checkingTimeshiftRunning():
						if self.ts_dialog is None:
							self.openChoiceActionBeforeZap()
					elif not config.recording.asktozap.value:
						self.log(8, "asking user to zap away")
						Notifications.AddNotificationWithCallback(self.failureCB, MessageBox, _("A timer failed to record!\nDisable TV and try again?\n"), timeout=20, default=True)
					else: # zap without asking
						self.log(9, "zap without asking")
						Notifications.AddNotification(MessageBox, _("In order to record a timer, the TV was switched to the recording service!\n"), type=MessageBox.TYPE_INFO, timeout=20)
						self.setRecordingPreferredTuner()
						self.failureCB(True)
				elif cur_ref:
					self.log(8, "currently running service is not a live service.. so stop it makes no sense")
				else:
					self.log(8, "currently no service running... so we dont need to stop it")
			return False

		elif next_state == self.StateRunning:
			# if this timer has been cancelled, just go to "end" state.
			if self.cancelled:
				return True
			if self.justplay:
				if Screens.Standby.inStandby:
					if RecordTimerEntry.wasInDeepStandby and self.zap_wakeup in ("always", "from_deep_standby") or self.zap_wakeup in ("always", "from_standby"):
						self.log(11, "wakeup and zap")
						RecordTimerEntry.setWasInStandby()
						#set service to zap after standby
						Screens.Standby.inStandby.prev_running_service = self.service_ref.ref
						Screens.Standby.inStandby.paused_service = None
						#wakeup standby
						Screens.Standby.inStandby.Power()
				else:
					self.sendactivesource()
					if RecordTimerEntry.wasInDeepStandby:
						RecordTimerEntry.setWasInStandby()
					notify = config.usage.show_message_when_recording_starts.value and self.InfoBarInstance and self.InfoBarInstance.execing
					if self.pipzap:
						cur_ref = NavigationInstance.instance.getCurrentlyPlayingServiceOrGroup()
						if cur_ref and cur_ref != self.service_ref.ref and self.InfoBarInstance and hasattr(self.InfoBarInstance.session, 'pipshown') and not Components.ParentalControl.parentalControl.isProtected(self.service_ref.ref):
							if self.InfoBarInstance.session.pipshown:
								hasattr(self.InfoBarInstance, "showPiP") and self.InfoBarInstance.showPiP()
							if hasattr(self.InfoBarInstance.session, 'pip'):
								del self.InfoBarInstance.session.pip
								self.InfoBarInstance.session.pipshown = False
							self.InfoBarInstance.session.pip = self.InfoBarInstance.session.instantiateDialog(PictureInPicture)
							self.InfoBarInstance.session.pip.show()
							if self.InfoBarInstance.session.pip.playService(self.service_ref.ref):
								self.InfoBarInstance.session.pipshown = True
								self.InfoBarInstance.session.pip.servicePath = self.InfoBarInstance.servicelist and self.InfoBarInstance.servicelist.getCurrentServicePath()
								self.log(11, "zapping as PiP")
								if notify:
									Notifications.AddPopup(text=_("Zapped to timer service %s as PiP!") % self.service_ref.getServiceName(), type=MessageBox.TYPE_INFO, timeout=5)
								return True
							else:
								del self.InfoBarInstance.session.pip
								self.InfoBarInstance.session.pipshown = False
					if self.checkingTimeshiftRunning():
						if self.ts_dialog is None:
							self.openChoiceActionBeforeZap()
					else:
						self.log(11, "zapping")
						NavigationInstance.instance.playService(self.service_ref.ref)
						if notify:
							Notifications.AddPopup(text=_("Zapped to timer service %s!") % self.service_ref.getServiceName(), type=MessageBox.TYPE_INFO, timeout=5)
				return True
			else:
				if RecordTimerEntry.wasInDeepStandby:
					RecordTimerEntry.keypress()
					if Screens.Standby.inStandby: #In case some plugin did put the receiver already in standby
						config.misc.standbyCounter.value = 0
					else:
						Notifications.AddNotification(Screens.Standby.Standby, StandbyCounterIncrease=False)
				record_res = self.record_service.start()
				self.setRecordingPreferredTuner(setdefault=True)
				if record_res:
					self.log(13, "start recording error: %d" % record_res)
					self.do_backoff()
					# retry
					self.begin = time() + self.backoff
					return False

				# Tell the trashcan we started recording. The trashcan gets events,
				# but cannot tell what the associated path is.
				Trashcan.instance.markDirty(self.Filename)
				self.log_tuner(11, "start")
				return True
コード例 #8
0
 def startedConnecting(self, connector):
     Notifications.AddPopup(text=_("Connecting to Fritz!Box..."),
                            type=MessageBox.TYPE_INFO,
                            timeout=2,
                            id="FritzCallConnect")
コード例 #9
0
def initDB():
	# type: () -> object
	global serienRecDataBaseFilePath

	# If database is at old default location (SerienRecorder plugin folder) we have to move the db to new default location
	if fileExists("%sSerienRecorder.db" % serienRecMainPath):
		shutil.move("%sSerienRecorder.db" % serienRecMainPath, serienRecDataBaseFilePath)

	if not fileExists(serienRecDataBaseFilePath):
		config.plugins.serienRec.databasePath.value = "/etc/enigma2/"
		config.plugins.serienRec.databasePath.save()
		configfile.save()
		SRLogger.writeLog("Datenbankpfad nicht gefunden, auf Standardpfad zurückgesetzt!")
		print "[SerienRecorder] Datenbankpfad nicht gefunden, auf Standardpfad zurückgesetzt!"
		Notifications.AddPopup(
			"SerienRecorder Datenbank wurde nicht gefunden.\nDer Standardpfad für die Datenbank wurde wiederhergestellt!",
			MessageBox.TYPE_INFO, timeout=10)
		serienRecDataBaseFilePath = "%sSerienRecorder.db" % config.plugins.serienRec.databasePath.value

	try:
		database = SRDatabase(serienRecDataBaseFilePath)
	except:
		SRLogger.writeLog("Fehler beim Initialisieren der Datenbank")
		print "[SerienRecorder] Fehler beim Initialisieren der Datenbank"
		Notifications.AddPopup("SerienRecorder Datenbank kann nicht initialisiert werden.\nSerienRecorder wurde beendet!", MessageBox.TYPE_INFO, timeout=10)
		return False

	if os.path.getsize(serienRecDataBaseFilePath) == 0:
		database.initialize(config.plugins.serienRec.dbversion.value)
	else:
		dbVersionMatch = False
		dbIncompatible = False

		dbVersion = database.getVersion()
		if dbVersion:
			if dbVersion == config.plugins.serienRec.dbversion.value:
				dbVersionMatch = True
			elif dbVersion > config.plugins.serienRec.dbversion.value:
				SRLogger.writeLog("Datenbankversion nicht kompatibel: SerienRecorder Version muss mindestens %s sein." % dbVersion)
				Notifications.AddPopup("Die SerienRecorder Datenbank ist mit dieser Version nicht kompatibel.\nAktualisieren Sie mindestens auf die SerienRecorder Version %s!" % dbVersion, MessageBox.TYPE_INFO, timeout=10)
				dbIncompatible = True
		else:
			dbIncompatible = True

		mode = os.R_OK | os.W_OK
		if not os.access(serienRecDataBaseFilePath, mode):
			SRLogger.writeLog("Datenbankdatei hat nicht die richtigen Berechtigungen - es müssen Lese- und Schreibrechte gesetzt sein.")
			Notifications.AddPopup("Datenbankdatei hat nicht die richtigen Berechtigungen - es müssen Lese- und Schreibrechte gesetzt sein.", MessageBox.TYPE_INFO, timeout=10)
			dbIncompatible = True

		# Database incompatible - do cleanup
		if dbIncompatible:
			database.close()
			return False

		if not dbVersionMatch:
			SRLogger.writeLog("Datenbank ist zu alt - sie muss aktualisiert werden...", True)
			database.close()
			backupSerienRecDataBaseFilePath = "%sSerienRecorder_old.db" % config.plugins.serienRec.databasePath.value
			SRLogger.writeLog("Erstelle Datenbank Backup - es kann nach erfolgreichem Update gelöscht werden: %s" % backupSerienRecDataBaseFilePath, True)
			shutil.copy(serienRecDataBaseFilePath, backupSerienRecDataBaseFilePath)
			database = SRDatabase(serienRecDataBaseFilePath)
			if database.update(config.plugins.serienRec.dbversion.value):
				SRLogger.writeLog("Datenbank von Version %s auf Version %s aktualisiert" % (dbVersion, config.plugins.serienRec.dbversion.value), True)
			else:
				database.close()
				Notifications.AddPopup("SerienRecorder Datenbank konnte nicht aktualisiert werden. Fehler wurden in die Logdatei geschrieben.\nSerienRecorder wurde beendet!", MessageBox.TYPE_INFO, timeout=10)
				return False

	# Analyze database for query optimizer
	try:
		database.optimize()
	except Exception as e:
		database.close()
		SRLogger.writeLog("Fehler beim Zugriff auf die Datenbank [%s]" % str(e))
		Notifications.AddPopup("Fehler beim Zugriff auf die Datenbank!\n%s" % str(e), MessageBox.TYPE_INFO, timeout=10)
		return False

	database.close()
	return True
コード例 #10
0
	def prepare(self):
		if config.plugins.epgrefresh.enablemessage.value:
			Notifications.AddPopup(_("EPG refresh starts scanning channels."), MessageBox.TYPE_INFO, 4, STARTNOTIFICATIONID)
		self.previousService = self.navcore.getCurrentlyPlayingServiceReference()
		print("[EPGRefresh] DEBUG prepare.previousService=" + str(self.previousService))
		return True
コード例 #11
0
    def finish(self, *args, **kwargs):
        if self.showPendingServicesMessageShown:
            self.msg.close()
        print("[EPGRefresh] Debug: Refresh finished!")
        if config.plugins.epgrefresh.enablemessage.value:
            Notifications.AddPopup(_("EPG refresh finished."),
                                   MessageBox.TYPE_INFO,
                                   4,
                                   ENDNOTIFICATIONID,
                                   domain=NOTIFICATIONDOMAIN)
        epgrefreshtimer.cleanup()
        self.maybeStopAdapter()
        if config.plugins.epgrefresh.epgsave.value:
            Notifications.AddPopup(_("EPG refresh save."),
                                   MessageBox.TYPE_INFO,
                                   4,
                                   ENDNOTIFICATIONID,
                                   domain=NOTIFICATIONDOMAIN)
            from enigma import eEPGCache
            myEpg = None
            myEpg = eEPGCache.getInstance()
            myEpg.save()

        force_auto_shutdown = self.session.nav.wasTimerWakeup() and \
          config.plugins.epgrefresh.afterevent.value == "auto" and \
          Screens.Standby.inStandby and config.misc.standbyCounter.value == 1 and \
          config.misc.prev_wakeup_time.value == config.plugins.epgrefresh.wakeup_time.value

        if not self.forcedScan:
            # shutdown
            if config.plugins.epgrefresh.afterevent.value == "standby" or force_auto_shutdown:
                if not Screens.Standby.inTryQuitMainloop:
                    if (not config.plugins.epgrefresh.dontshutdownonabort.value
                            and self.doStopRunningRefresh
                        ) or not self.doStopRunningRefresh:
                        self.forcedScan = False
                        if Screens.Standby.inStandby:
                            RecordTimerEntry.TryQuitMainloop()
                        else:
                            Notifications.AddNotificationWithCallback(
                                self.sendTryQuitMainloopNotification,
                                MessageBox,
                                _("EPGRefresh wants to shut down\nyour Dreambox. Shutdown now?"
                                  ),
                                timeout=10,
                                domain=NOTIFICATIONDOMAIN)
            # idle
            elif config.plugins.epgrefresh.afterevent.value == "idle":
                if not Screens.Standby.inStandby:
                    Notifications.AddNotificationWithCallback(
                        self.sendStandbyNotification,
                        MessageBox,
                        _("EPGRefresh wants to set your\nDreambox to idle. Do that now?"
                          ),
                        timeout=10,
                        domain=NOTIFICATIONDOMAIN)

        self.doStopRunningRefresh = False
        self.forcedScan = False
        self.isrunning = False
        self._nextTodo()
コード例 #12
0
    def run(self):
        self.starttime_unix = time.time()
        colorprint(
            "---------------------------------------------------------- START -------------------------------------------------------------------------"
        )
        colorprint("Starte EPG-Download %s" %
                   time.strftime("%d.%m.%Y - %H:%M", time.gmtime()))
        s = requests.Session()
        p = getpayload(s)
        if isinstance(p, dict):
            payload = p['payloaddata'][0]['payload']
            sessionkey = p['payloaddata'][0]['sessionkey']
            if payload > 0 and str(sessionkey) != '':
                self.isRunning = True
                colorprint("Hole EPG Daten vom Server")
                self.msgCallback("Hole EPG Daten vom Server.. Bitte warten")
                requests.packages.urllib3.disable_warnings(
                    InsecureRequestWarning)
                if config.plugins.epgShare.useimprover.value:
                    refs = getRefListJson(getextradata=True)
                else:
                    refs = getRefListJson(
                        getextradata=True)  # lasttime erstmal deaktiviert
                for ref in refs:
                    colorprint("Loading ChannelEPG: %s / %s" %
                               (str(ref['ref']), str(ref['name'])))
                    try:
                        if config.plugins.epgShare.useimprover.value:
                            data = s.post(
                                "http://timeforplanb.linevast-hosting.in/download_epg_2.php?sessionkey="
                                + sessionkey +
                                "&extradata=true&finished=false",
                                data=json.dumps(ref),
                                timeout=180).json()
                        else:
                            data = s.post(
                                "http://timeforplanb.linevast-hosting.in/download_epg_2.php?sessionkey="
                                + sessionkey +
                                "&extradata=false&finished=false",
                                data=json.dumps(ref),
                                timeout=180).json()
                        events = data['events']
                    except Exception, ex:
                        events = None
                        colorprint("Fehler beim EPG Download !!!")
                        if self.callback:
                            self.msgCallback("Fehler beim EPG Download %s" %
                                             str(ex))
                    if events is not None:
                        events_list = []
                        count_refs = len(events)
                        for event in events:
                            if not self.isRunning:
                                break
                            gotextradata = False
                            #print event
                            if 'extradata' in event:
                                if not event['extradata'] is None:
                                    gotextradata = True

                            if not gotextradata:
                                events_list.append(
                                    (long(event['starttime']),
                                     int(event['duration']), str(
                                         event['title']).encode('utf-8'),
                                     str(event['subtitle']).encode('utf-8'),
                                     str(event['handlung']).encode('utf-8'), 0,
                                     long(event['event_id'])), )
                            else:
                                title = str(event['title'])
                                #print "GotExtradata: %s" % str(event['extradata'])
                                if config.plugins.epgShare.titleSeasonEpisode.value:
                                    extradata = json.loads(event['extradata'])
                                    if 'categoryName' in str(extradata):
                                        if 'Serie' in str(extradata):
                                            if 'season' and 'episode' in str(
                                                    extradata):
                                                season = str(
                                                    extradata['season'])
                                                episode = str(
                                                    extradata['episode'])
                                                if season and episode != '':
                                                    if int(season) < 10:
                                                        season = "S0" + str(
                                                            season)
                                                    else:
                                                        season = "S" + str(
                                                            season)
                                                    if int(episode) < 10:
                                                        episode = "E0" + str(
                                                            episode)
                                                    else:
                                                        episode = "E" + str(
                                                            episode)
                                                    title = "%s - %s%s" % (
                                                        title, season, episode)
                                events_list.append(
                                    (long(event['starttime']),
                                     int(event['duration']),
                                     str(title).encode('utf-8'),
                                     str(event['subtitle']).encode('utf-8'),
                                     "%s \n<x>%s</x>" %
                                     (str(event['handlung']).encode('utf-8'),
                                      str(event['extradata']).encode('utf-8')),
                                     0, long(event['event_id'])), )
                                count_refs += 1
                        self.epgcache.importLockedEventswithID(
                            str(ref['ref']), events_list)
                        colorprint("Import %s Events for Channel: %s" %
                                   (len(events_list), str(ref['name'])))
                        if self.callback:
                            self.msgCallback(
                                "Import %s Events for Channel: %s" %
                                (len(events_list), str(ref['name'])))
                colorprint("EPG Download beendet.")
                self.epgcache.save()
                s.post(
                    "http://timeforplanb.linevast-hosting.in/download_epg_2.php?sessionkey="
                    + sessionkey + "&finished=true&extradata=false",
                    data=json.dumps(ref),
                    timeout=180)
                if self.callback:
                    self.msgCallback("EPG Download beendet.")
                else:
                    if self.autoupdate:
                        Notifications.AddPopup(
                            "Epg Share Autoupdate abgeschlossen...",
                            MessageBox.TYPE_INFO,
                            timeout=5)
                    else:
                        Notifications.AddPopup(
                            "Epg Share Update abgeschlossen...",
                            MessageBox.TYPE_INFO,
                            timeout=5)
                    self.isRunning = False
            else:
                if self.callback:
                    self.msgCallback(
                        "Maximale Downloads pro Tag erreicht. Reset erfolgt um 0 Uhr"
                    )
コード例 #13
0
	def downloadError(self):
		self.stopProgressTimer()
		Notifications.AddPopup("Der Download der neuen SerienRecorder Version ist fehlgeschlagen.\nDas Update wird abgebrochen.", type=MessageBox.TYPE_INFO, timeout=10)
		self.close()
コード例 #14
0
	def checkForUpdate(self):
		if ssl.OPENSSL_VERSION_NUMBER < 268439552:
			Notifications.AddPopup("Leider ist die Suche nach SerienRecorder Updates auf dieser Box technisch nicht möglich - die automatische Plugin-Update Funktion wird deaktiviert!", MessageBox.TYPE_INFO, timeout=0)
			config.plugins.serienRec.Autoupdate.value = False
			config.plugins.serienRec.Autoupdate.save()
			configfile.save()
			return

		def checkReleases():
			latestRelease = checkGitHubUpdate.getLastestReleaseData()
			#latestRelease = data[0]
			latestVersion = latestRelease['tag_name'][1:]

			remoteversion = latestVersion.lower().replace("-", ".").replace("beta", "-1").split(".")
			version = config.plugins.serienRec.showversion.value.lower().replace("-", ".").replace("alpha", "-1").replace("beta", "-1").split(".")
			remoteversion.extend((max([len(remoteversion), len(version)]) - len(remoteversion)) * '0')
			remoteversion = [int(x) for x in remoteversion]
			version.extend((max([len(remoteversion), len(version)]) - len(version)) * '0')
			version = [int(x) for x in version]

			if remoteversion > version:
				updateName = toStr(latestRelease['name'])
				updateInfo = toStr(latestRelease['body'])
				downloadURL = None
				downloadFileSize = 5 * 1024
				for asset in latestRelease['assets']:
					updateURL = toStr(asset['browser_download_url'])
					if PY2:
						if isDreamOS() and updateURL.endswith(".deb"):
							downloadURL = updateURL
							downloadFileSize = int(asset['size'] / 1024)
							break
						if not isDreamOS() and updateURL.endswith('.ipk'):
							downloadURL = updateURL
							downloadFileSize = int(asset['size'] / 1024)
							break
					else:
						if isDreamOS() and updateURL.endswith(".deb3"):
							downloadURL = updateURL
							downloadFileSize = int(asset['size'] / 1024)
							break
						if not isDreamOS() and updateURL.endswith('.ipk3'):
							downloadURL = updateURL
							downloadFileSize = int(asset['size'] / 1024)
							break

				if downloadURL:
					return updateName, updateInfo, downloadURL, downloadFileSize

			return None

		def onUpdateAvailable(result):
			if result:
				(updateName, updateInfo, downloadURL, downloadFileSize) = result
				self.session.open(checkGitHubUpdateScreen, updateName, updateInfo, downloadURL, downloadFileSize)

		def onUpdateCheckFailed():
			print("[SerienRecorder] Update check failed")
			self.session.open(MessageBox, "Bei der Suche nach einer neuen SerienRecorder Version ist ein Fehler aufgetreten!", MessageBox.TYPE_INFO, timeout=5)

		import twisted.python.runtime
		if twisted.python.runtime.platform.supportsThreads():
			from twisted.internet.threads import deferToThread
			deferToThread(checkReleases).addCallback(onUpdateAvailable).addErrback(onUpdateCheckFailed)
		else:
			try:
				result = checkReleases()
				onUpdateAvailable(result)
			except:
				onUpdateCheckFailed()