Ejemplo n.º 1
0
	def finishedEdit(self, answer):
		print "[TimerEditList] finished edit"

		if answer[0]:
			print "[TimerEditList] edited timer"
			entry = answer[1]
			timersanitycheck = TimerSanityCheck(self.session.nav.RecordTimer.timer_list, entry)
			success = False
			if not timersanitycheck.check():
				simulTimerList = timersanitycheck.getSimulTimerList()
				if simulTimerList is not None:
					for x in simulTimerList:
						if x.setAutoincreaseEnd(entry):
							self.session.nav.RecordTimer.timeChanged(x)
					if not timersanitycheck.check():
						simulTimerList = timersanitycheck.getSimulTimerList()
						if simulTimerList is not None:
							self.session.openWithCallback(self.finishedEdit, TimerSanityConflict, timersanitycheck.getSimulTimerList())
					else:
						success = True
			else:
				success = True
			if success:
				print "[TimerEditList] sanity check passed"
				self.session.nav.RecordTimer.timeChanged(entry)

			self.fillTimerList()
			self.updateState()
		else:
			print "[TimerEditList] timer edit aborted"
Ejemplo n.º 2
0
	def record(self, entry, ignoreTSC=False, dosave=True, loadtimer=False):
		check_timer_list = self.timer_list[:]
		timersanitycheck = TimerSanityCheck(check_timer_list,entry)
		answer = None
		if not timersanitycheck.check():
			if not ignoreTSC:
				print "[RecordTimer] timer conflict detected!"
				print timersanitycheck.getSimulTimerList()
				return timersanitycheck.getSimulTimerList()
			else:
				print "[RecordTimer] ignore timer conflict..."
				if not dosave and loadtimer:
					simulTimerList = timersanitycheck.getSimulTimerList()
					if entry in simulTimerList:
						entry.disabled = True
						if entry in check_timer_list:
							check_timer_list.remove(entry)
					answer = simulTimerList
		elif timersanitycheck.doubleCheck():
			print "[RecordTimer] ignore double timer..."
			return None
		entry.timeChanged()
		print "[Timer] Record " + str(entry)
		entry.Timer = self
		self.addTimerEntry(entry)
		if dosave:
			self.saveTimer()
		return answer
Ejemplo n.º 3
0
	def record(self, entry, ignoreTSC=False, dosave=True, loadtimer=False):
		check_timer_list = self.timer_list[:]
		timersanitycheck = TimerSanityCheck(check_timer_list,entry)
		answer = None
		if not timersanitycheck.check():
			if not ignoreTSC:
				print "[RecordTimer] timer conflict detected!"
				print timersanitycheck.getSimulTimerList()
				return timersanitycheck.getSimulTimerList()
			else:
				print "[RecordTimer] ignore timer conflict..."
				if not dosave and loadtimer:
					simulTimerList = timersanitycheck.getSimulTimerList()
					if entry in simulTimerList:
						entry.disabled = True
						if entry in check_timer_list:
							check_timer_list.remove(entry)
					answer = simulTimerList
		elif timersanitycheck.doubleCheck():
			print "[RecordTimer] ignore double timer..."
			return None
		elif not loadtimer and not entry.disabled and not entry.justplay and entry.state == 0 and not (entry.service_ref and '%3a//' in entry.service_ref.ref.toString()):
			for x in check_timer_list:
				if x.begin == entry.begin and not x.disabled and not x.justplay and not (x.service_ref and '%3a//' in x.service_ref.ref.toString()):
					entry.begin += 1
		entry.timeChanged()
		print "[Timer] Record " + str(entry)
		entry.Timer = self
		self.addTimerEntry(entry)
		if dosave:
			self.saveTimer()
		return answer
Ejemplo n.º 4
0
def editTimer(session, serviceref, begin, end, name, description, disabled, justplay, afterEvent, dirname, tags, repeated, channelOld, beginOld, endOld, vpsinfo, always_zap):
	# TODO: exception handling
	serviceref = unquote(serviceref)
	channelOld_str =  ':'.join(str(channelOld).split(':')[:11])
	rt = session.nav.RecordTimer
	for timer in rt.timer_list + rt.processed_timers:
		needed_ref = ':'.join(timer.service_ref.ref.toString().split(':')[:11]) == channelOld_str
		if needed_ref and int(timer.begin) == beginOld and int(timer.end) == endOld:
			timer.service_ref = ServiceReference(serviceref)
			# TODO: start end time check
			timer.begin = int(float(begin))
			timer.end = int(float(end))
			timer.name = name
			timer.description = description
			# TODO : EIT
			#timer.eit = eit
			timer.disabled = disabled
			timer.justplay = justplay
			timer.afterEvent = afterEvent
			timer.dirname = dirname
			timer.tags = tags
			timer.repeated = repeated
			timer.processRepeated()
			if vpsinfo is not None:
				timer.vpsplugin_enabled = vpsinfo["vpsplugin_enabled"]
				timer.vpsplugin_overwrite = vpsinfo["vpsplugin_overwrite"]
				timer.vpsplugin_time = vpsinfo["vpsplugin_time"]

			if always_zap <> -1:
				if hasattr(timer,"always_zap"):
					timer.always_zap = always_zap == 1

			# TODO: multi tuner test
			sanity = TimerSanityCheck(rt.timer_list, timer)
			conflicts = None
			if not sanity.check():
				conflicts = sanity.getSimulTimerList()
				if conflicts is not None:
					for conflict in conflicts:
						if conflict.setAutoincreaseEnd(entry):
							rt.timeChanged(conflict)
							if not sanity.check():
								conflicts = sanity.getSimulTimerList()
			if conflicts is None:
				rt.timeChanged(timer)
				return {
					"result": True,
					"message": _("Timer '%s' changed") % name
				}
			else:
				return {
					"result": False,
					"message": _("Timer '%s' not saved while Conflict") % name
				}

	return {
		"result": False,
		"message": _("Could not find timer '%s' with given start and end time!") % name
	}
Ejemplo n.º 5
0
	def toggleDisabledState(self):
		cur=self["timerlist"].getCurrent()
		if cur:
			t = cur
			if t.disabled:
# 				print "try to ENABLE timer"
				t.enable()
				timersanitycheck = TimerSanityCheck(self.session.nav.RecordTimer.timer_list, cur)
				if not timersanitycheck.check():
					t.disable()
					print "Sanity check failed"
					simulTimerList = timersanitycheck.getSimulTimerList()
					if simulTimerList is not None:
						self.session.openWithCallback(self.finishedEdit, TimerSanityConflict, simulTimerList)
				else:
					print "Sanity check passed"
					if timersanitycheck.doubleCheck():
						t.disable()
			else:
				if t.isRunning():
					if t.repeated:
						list = (
							(_("Stop current event but not coming events"), "stoponlycurrent"),
							(_("Stop current event and disable coming events"), "stopall"),
							(_("Don't stop current event but disable coming events"), "stoponlycoming")
						)
						self.session.openWithCallback(boundFunction(self.runningEventCallback, t), ChoiceBox, title=_("Repeating event currently recording... What do you want to do?"), list = list)
				else:
					t.disable()
			self.session.nav.RecordTimer.timeChanged(t)
			self.refill()
			self.updateState()
Ejemplo n.º 6
0
 def toggleDisabledState(self):
     cur = self['timerlist'].getCurrent()
     if cur:
         t = cur
         if t.disabled:
             t.enable()
             timersanitycheck = TimerSanityCheck(self.session.nav.RecordTimer.timer_list, cur)
             if not timersanitycheck.check():
                 t.disable()
                 print '[TimerEdit] Sanity check failed'
                 simulTimerList = timersanitycheck.getSimulTimerList()
                 if simulTimerList is not None:
                     self.session.openWithCallback(self.finishedEdit, TimerSanityConflict, simulTimerList)
             else:
                 print '[TimerEdit] Sanity check passed'
                 if timersanitycheck.doubleCheck():
                     t.disable()
         elif t.isRunning():
             if t.repeated:
                 list = ((_('Stop current event but not future events'), 'stoponlycurrent'), (_('Stop current event and disable future events'), 'stopall'), (_("Don't stop current event but disable future events"), 'stoponlycoming'))
                 self.session.openWithCallback(boundFunction(self.runningEventCallback, t), ChoiceBox, title=_('Repeating event currently recording... What do you want to do?'), list=list)
         else:
             t.disable()
         self.session.nav.RecordTimer.timeChanged(t)
         self.refill()
         self.updateState()
     return
Ejemplo n.º 7
0
    def setAutoincreaseEnd(self, entry=None):
        if not self.autoincrease:
            return False
        if entry is None:
            new_end = int(time()) + self.autoincreasetime
        else:
            new_end = entry.begin - 30

        dummyentry = RecordTimerEntry(
            self.service_ref,
            self.begin,
            new_end,
            self.name,
            self.description,
            self.eit,
            disabled=True,
            justplay=self.justplay,
            afterEvent=self.afterEvent,
            dirname=self.dirname,
            tags=self.tags,
        )
        dummyentry.disabled = self.disabled
        timersanitycheck = TimerSanityCheck(NavigationInstance.instance.RecordTimer.timer_list, dummyentry)
        if not timersanitycheck.check():
            simulTimerList = timersanitycheck.getSimulTimerList()
            if simulTimerList is not None and len(simulTimerList) > 1:
                new_end = simulTimerList[1].begin
                new_end -= 30  # 30 Sekunden Prepare-Zeit lassen
        if new_end <= time():
            return False
        self.end = new_end
        return True
Ejemplo n.º 8
0
	def reloadTimerList(self, recordHandler):
		doLog("[AutoTimer] Start reload timers list after search")
		# checking and deleting duplicate timers
		disabled_at = removed_at = 0
		check_timer_list = recordHandler.timer_list[:]
		for timer in check_timer_list:
			check_timer_list.remove(timer)
			timersanitycheck = TimerSanityCheck(check_timer_list, timer)
			if not timersanitycheck.check():
				simulTimerList = timersanitycheck.getSimulTimerList()
				if simulTimerList and timer in simulTimerList and "autotimer" in timer.flags and not timer.isRunning():
					timer.disabled = True
					recordHandler.timeChanged(timer)
					disabled_at += 1
					conflictString += ' / '.join(["%s (%s)" % (x.name, strftime("%Y%m%d %H%M", localtime(x.begin))) for x in simulTimerList])
					doLog("[AutoTimer-reload] Timer %s disabled because of conflicts with %s." % (timer.name, conflictString))
			elif timersanitycheck.doubleCheck() and "autotimer" in timer.flags and not timer.isRunning():
				try:
					recordHandler.removeEntry(timer)
					removed_at += 1
					doLog("[AutoTimer-reload] Remove double timer %s."% (timer.name))
				except:
					doLog("[AutoTimer-reload] Error for remove double timer %s."% (timer.name))
		if config.plugins.autotimer.remove_double_and_conflicts_timers.value == "yes_notify":
			if Standby.inStandby is None and (disabled_at or removed_at):
				AddPopup(_("Reload timers list.\n%d autotimer(s) disabled because conflict.\n%d double autotimer(s) removed.\n") % (disabled_at, removed_at), MessageBox.TYPE_INFO, config.plugins.autotimer.popup_timeout.value, CONFLICTINGDOUBLEID)
Ejemplo n.º 9
0
	def record(self, entry, ignoreTSC=False, dosave=True): #wird von loadTimer mit dosave=False aufgerufen
		if not ignoreTSC:
			timersanitycheck = TimerSanityCheck(self.timer_list,entry)
			if not timersanitycheck.check():
				print "timer conflict detected!"
				print timersanitycheck.getSimulTimerList()
				return timersanitycheck.getSimulTimerList()
			elif timersanitycheck.doubleCheck():
				print "ignore double timer"
				return None
		entry.timeChanged()
		print "[Timer] Record " + str(entry)
		entry.Timer = self
		self.addTimerEntry(entry)
		if dosave:
			self.saveTimer()
		return None
Ejemplo n.º 10
0
	def finishedEdit(self, answer):
		print "[TimerEditList] finished edit"
		if answer[0]:
			entry = answer[1]
			if entry.external_prev != entry.external:
				def removeEditTimer():
					entry.service_ref, entry.begin, entry.end, entry.external = entry.service_ref_prev, entry.begin_prev, entry.end_prev, entry.external_prev
					self.removeTimer()
				def moveEditTimerError():
					entry.external = entry.external_prev
					self.refill()
				if entry.external:
					self.fallbackTimer.addTimer(entry, removeEditTimer, moveEditTimerError)
				else:
					newentry = createRecordTimerEntry(entry)
					entry.service_ref, entry.begin, entry.end = entry.service_ref_prev, entry.begin_prev, entry.end_prev
					self.fallbackTimer.removeTimer(entry, boundFunction(self.finishedAdd, (True, newentry)), moveEditTimerError)
			elif entry.external:
				self.fallbackTimer.editTimer(entry, self.refill)
			else:
				timersanitycheck = TimerSanityCheck(self.session.nav.RecordTimer.timer_list, entry)
				success = False
				if not timersanitycheck.check():
					simulTimerList = timersanitycheck.getSimulTimerList()
					if simulTimerList is not None:
						for x in simulTimerList:
							if x.setAutoincreaseEnd(entry):
								self.session.nav.RecordTimer.timeChanged(x)
						if not timersanitycheck.check():
							simulTimerList = timersanitycheck.getSimulTimerList()
							if simulTimerList is not None:
								self.session.openWithCallback(self.finishedEdit, TimerSanityConflict, timersanitycheck.getSimulTimerList())
						else:
							success = True
				else:
					success = True
				if success:
					print "[TimerEditList] sanity check passed"
					self.session.nav.RecordTimer.timeChanged(entry)
				self.fillTimerList()
Ejemplo n.º 11
0
	def isResolvedConflict(self):
		timersanitycheck = TimerSanityCheck(self.session.nav.RecordTimer.timer_list, self.timer[0])
		success = False
		if not timersanitycheck.check():
			simulTimerList = timersanitycheck.getSimulTimerList()
			if simulTimerList is not None:
				for x in simulTimerList:
					if x.setAutoincreaseEnd(self.timer[0]):
						self.session.nav.RecordTimer.timeChanged(x)
				if timersanitycheck.check():
					success = True
		else:
			success = True
		return success
Ejemplo n.º 12
0
 def isResolvedConflict(self):
     timersanitycheck = TimerSanityCheck(
         self.session.nav.RecordTimer.timer_list, self.timer[0])
     success = False
     if not timersanitycheck.check():
         simulTimerList = timersanitycheck.getSimulTimerList()
         if simulTimerList is not None:
             for x in simulTimerList:
                 if x.setAutoincreaseEnd(self.timer[0]):
                     self.session.nav.RecordTimer.timeChanged(x)
             if timersanitycheck.check():
                 success = True
     else:
         success = True
     return success
Ejemplo n.º 13
0
 def modifyTimer(self, timer):
     timersanitycheck = TimerSanityCheck(_session.nav.RecordTimer.timer_list, timer)
     success = False
     if not timersanitycheck.check():
         simulTimerList = timersanitycheck.getSimulTimerList()
         if simulTimerList is not None:
             for x in simulTimerList:
                 if x.setAutoincreaseEnd(timer):
                     self.session.nav.RecordTimer.timeChanged(x)
             if timersanitycheck.check():
                 success = True
     else:
         success = True
     if success:
         _session.nav.RecordTimer.timeChanged(timer)
     return success
Ejemplo n.º 14
0
 def toggleDisabledState(self):
     cur = self["timerlist"].getCurrent()
     if cur:
         t = cur
         if t.disabled and t.repeated and t.isRunning() and not t.justplay:
             return
         if t.disabled:
             # 				print "try to ENABLE timer"
             t.enable()
             timersanitycheck = TimerSanityCheck(
                 self.session.nav.RecordTimer.timer_list, cur)
             if not timersanitycheck.check():
                 t.disable()
                 print "Sanity check failed"
                 simulTimerList = timersanitycheck.getSimulTimerList()
                 if simulTimerList is not None:
                     self.session.openWithCallback(self.finishedEdit,
                                                   TimerSanityConflict,
                                                   simulTimerList)
             else:
                 print "Sanity check passed"
                 if timersanitycheck.doubleCheck():
                     t.disable()
         else:
             if t.isRunning():
                 if t.repeated:
                     list = ((
                         _("Stop current event but not coming events"),
                         "stoponlycurrent"
                     ), (
                         _("Stop current event and disable coming events"),
                         "stopall"
                     ), (_(
                         "Don't stop current event but disable coming events"
                     ), "stoponlycoming"))
                     self.session.openWithCallback(
                         boundFunction(self.runningEventCallback, t),
                         ChoiceBox,
                         title=
                         _("Repeating event currently recording... What do you want to do?"
                           ),
                         list=list)
             else:
                 t.disable()
         self.session.nav.RecordTimer.timeChanged(t)
         self.refill()
         self.updateState()
Ejemplo n.º 15
0
 def modifyTimer(self, timer):
     timersanitycheck = TimerSanityCheck(
         _session.nav.RecordTimer.timer_list, timer)
     success = False
     if not timersanitycheck.check():
         simulTimerList = timersanitycheck.getSimulTimerList()
         if simulTimerList is not None:
             for x in simulTimerList:
                 if x.setAutoincreaseEnd(timer):
                     self.session.nav.RecordTimer.timeChanged(x)
             if timersanitycheck.check():
                 success = True
     else:
         success = True
     if success:
         _session.nav.RecordTimer.timeChanged(timer)
     return success
Ejemplo n.º 16
0
	def record(self, entry, ignoreTSC=False, dosave=True): # is called by loadTimer with argument dosave=False
		timersanitycheck = TimerSanityCheck(self.timer_list,entry)
		if not timersanitycheck.check():
			if not ignoreTSC:
				print "timer conflict detected!"
				return timersanitycheck.getSimulTimerList()
			else:
				print "ignore timer conflict"
		elif timersanitycheck.doubleCheck():
			print "ignore double timer"
			return None
		entry.timeChanged()
		print "[Timer] Record " + str(entry)
		entry.Timer = self
		self.addTimerEntry(entry)
		if dosave:
			self.saveTimer()
		return None
Ejemplo n.º 17
0
	def record(self, entry, ignoreTSC=False, dosave=True): # wird von loadTimer mit dosave=False aufgerufen
		timersanitycheck = TimerSanityCheck(self.timer_list,entry)
		if not timersanitycheck.check():
			if not ignoreTSC:
				print "timer conflict detected!"
				return timersanitycheck.getSimulTimerList()
			else:
				print "ignore timer conflict"
		elif timersanitycheck.doubleCheck():
			print "ignore double timer"
			return None
		entry.timeChanged()
		print "[Timer] Record " + str(entry)
		entry.Timer = self
		self.addTimerEntry(entry)
		if dosave:
			self.saveTimer()
		return None
Ejemplo n.º 18
0
	def setAutoincreaseEnd(self, entry=None):
		if not self.autoincrease:
			return False
		if entry is None:
			new_end = int(time()) + self.autoincreasetime
		else:
			new_end = entry.begin - 30
		dummyentry = PowerTimerEntry(self.begin, new_end, disabled=True, afterEvent=self.afterEvent, timerType=self.timerType)
		dummyentry.disabled = self.disabled
		timersanitycheck = TimerSanityCheck(NavigationInstance.instance.PowerManager.timer_list, dummyentry)
		if not timersanitycheck.check():
			simulTimerList = timersanitycheck.getSimulTimerList()
			if simulTimerList is not None and len(simulTimerList) > 1:
				new_end = simulTimerList[1].begin
				new_end -= 30
		if new_end <= time():
			return False
		self.end = new_end
		return True
Ejemplo n.º 19
0
 def toggleDisabledState(self):
     cur = self['timerlist'].getCurrent()
     if cur:
         t = cur
         if t.disabled:
             t.enable()
             timersanitycheck = TimerSanityCheck(
                 self.session.nav.RecordTimer.timer_list, cur)
             if not timersanitycheck.check():
                 t.disable()
                 print '[TimerEdit] Sanity check failed'
                 simulTimerList = timersanitycheck.getSimulTimerList()
                 if simulTimerList is not None:
                     self.session.openWithCallback(self.finishedEdit,
                                                   TimerSanityConflict,
                                                   simulTimerList)
             else:
                 print '[TimerEdit] Sanity check passed'
                 if timersanitycheck.doubleCheck():
                     t.disable()
         elif t.isRunning():
             if t.repeated:
                 list = (
                     (_('Stop current event but not future events'),
                      'stoponlycurrent'),
                     (_('Stop current event and disable future events'),
                      'stopall'),
                     (_("Don't stop current event but disable future events"
                        ), 'stoponlycoming'))
                 self.session.openWithCallback(
                     boundFunction(self.runningEventCallback, t),
                     ChoiceBox,
                     title=
                     _('Repeating event currently recording... What do you want to do?'
                       ),
                     list=list)
         else:
             t.disable()
         self.session.nav.RecordTimer.timeChanged(t)
         self.refill()
         self.updateState()
     return
Ejemplo n.º 20
0
	def setAutoincreaseEnd(self, entry = None):
		if not self.autoincrease:
			return False
		if entry is None:
			new_end =  int(time()) + self.autoincreasetime
		else:
			new_end = entry.begin -30

		dummyentry = PowerTimerEntry(self.begin, new_end, disabled=True, afterEvent = self.afterEvent, timerType = self.timerType)
		dummyentry.disabled = self.disabled
		timersanitycheck = TimerSanityCheck(NavigationInstance.instance.PowerManager.timer_list, dummyentry)
		if not timersanitycheck.check():
			simulTimerList = timersanitycheck.getSimulTimerList()
			if simulTimerList is not None and len(simulTimerList) > 1:
				new_end = simulTimerList[1].begin
				new_end -= 30				# 30 Sekunden Prepare-Zeit lassen
		if new_end <= time():
			return False
		self.end = new_end
		return True
Ejemplo n.º 21
0
	def setAutoincreaseEnd(self, entry = None):
		if not self.autoincrease:
			return False
		if entry is None:
			new_end =  int(time()) + self.autoincreasetime
		else:
			new_end = entry.begin -30

		dummyentry = RecordTimerEntry(self.service_ref, self.begin, new_end, self.name, self.description, self.eit, disabled=True, justplay = self.justplay, afterEvent = self.afterEvent, dirname = self.dirname, tags = self.tags)
		dummyentry.disabled = self.disabled
		timersanitycheck = TimerSanityCheck(NavigationInstance.instance.RecordTimer.timer_list, dummyentry)
		if not timersanitycheck.check():
			simulTimerList = timersanitycheck.getSimulTimerList()
			if simulTimerList is not None and len(simulTimerList) > 1:
				new_end = simulTimerList[1].begin
				new_end -= 30				# 30 Sekunden Prepare-Zeit lassen
		if new_end <= time():
			return False
		self.end = new_end
		return True
Ejemplo n.º 22
0
	def toggleDisabledState(self):
		cur = self["timerlist"].getCurrent()
		timer_changed = True
		if cur:
			t = cur
			if t.external:
				self.fallbackTimer.toggleTimer(t, self.refill)
			else:
				stateRunning = t.state in (1, 2)
				if t.disabled and t.repeated and stateRunning and not t.justplay:
					return
				if t.disabled:
					print "[TimerEditList] try to ENABLE timer"
					t.enable()
					timersanitycheck = TimerSanityCheck(self.session.nav.RecordTimer.timer_list, cur)
					if not timersanitycheck.check():
						t.disable()
						print "[TimerEditList] sanity check failed"
						simulTimerList = timersanitycheck.getSimulTimerList()
						if simulTimerList is not None:
							self.session.openWithCallback(self.finishedEdit, TimerSanityConflict, simulTimerList)
							timer_changed = False
					else:
						print "[TimerEditList] sanity check passed"
						if timersanitycheck.doubleCheck():
							t.disable()
				else:
					if stateRunning:
						if t.isRunning() and t.repeated:
							list = (
								(_("Stop current event but not coming events"), "stoponlycurrent"),
								(_("Stop current event and disable coming events"), "stopall"),
								(_("Don't stop current event but disable coming events"), "stoponlycoming")
							)
							self.session.openWithCallback(boundFunction(self.runningEventCallback, t), ChoiceBox, title=_("Repeating event currently recording... What do you want to do?"), list = list)
							timer_changed = False
					else:
						t.disable()
				if timer_changed:
					self.session.nav.RecordTimer.timeChanged(t)
			self.refill()
Ejemplo n.º 23
0
	def toggleDisabledState(self):
		cur = self["timerlist"].getCurrent()
		timer_changed = True
		if cur:
			t = cur
			if t.external:
				self.fallbackTimer.toggleTimer(t, self.refill)
			else:
				stateRunning = t.state in (1, 2)
				if t.disabled and t.repeated and stateRunning and not t.justplay:
					return
				if t.disabled:
					print "[TimerEditList] try to ENABLE timer"
					t.enable()
					timersanitycheck = TimerSanityCheck(self.session.nav.RecordTimer.timer_list, cur)
					if not timersanitycheck.check():
						t.disable()
						print "[TimerEditList] sanity check failed"
						simulTimerList = timersanitycheck.getSimulTimerList()
						if simulTimerList is not None:
							self.session.openWithCallback(self.finishedEdit, TimerSanityConflict, simulTimerList)
							timer_changed = False
					else:
						print "[TimerEditList] sanity check passed"
						if timersanitycheck.doubleCheck():
							t.disable()
				else:
					if stateRunning:
						if t.isRunning() and t.repeated:
							list = (
								(_("Stop current event but not coming events"), "stoponlycurrent"),
								(_("Stop current event and disable coming events"), "stopall"),
								(_("Don't stop current event but disable coming events"), "stoponlycoming")
							)
							self.session.openWithCallback(boundFunction(self.runningEventCallback, t), ChoiceBox, title=_("A repeating event is currently recording. What would you like to do?"), list=list)
							timer_changed = False
					else:
						t.disable()
				if timer_changed:
					self.session.nav.RecordTimer.timeChanged(t)
			self.refill()
Ejemplo n.º 24
0
	def toggleTimerState(self, timer, disableTimer, instant_toggle):
		if disableTimer:
			timer.disable()
			self.session.nav.RecordTimer.timeChanged(timer)
			self["key_green"].setText(_("Remove") + "\n" + _("Enable timer"))
			self.key_green_choice = self.ENABLE_TIMER
		else:
			timer.enable()
			timersanitycheck = TimerSanityCheck(self.session.nav.RecordTimer.timer_list, timer)
			if not timersanitycheck.check():
				timer.disable()
				self["key_green"].setText("")
				self.key_green_choice = self.EMPTY
				simulTimerList = timersanitycheck.getSimulTimerList()
				if simulTimerList is not None:
					self.session.openWithCallback(self.finishedEdit, TimerSanityConflict, simulTimerList)
			else:
				if timersanitycheck.doubleCheck():
					timer.disable()
					self["key_green"].setText(_("Remove") + "\n" + _("Enable timer"))
					self.key_green_choice = self.REMOVE_TIMER
			self.session.nav.RecordTimer.timeChanged(timer)
		self.updateList()
Ejemplo n.º 25
0
		try:
			httprequest = urllib2.urlopen(baseurl + '/web/timeradd?' + args)
			xmldoc = minidom.parseString(httprequest.read())
			status = xmldoc.getElementsByTagName('e2simplexmlresult')[0]
			success = getValueFromNode(status, 'e2state') == "True"
		except Exception, e:
			print "[GBIpboxRemoteTimer]", e
			return None

		self.getTimers()

		if not success:
			timersanitycheck = TimerSanityCheck(self._timer_list,entry)
			if not timersanitycheck.check():
				print "timer conflict detected!"
				print timersanitycheck.getSimulTimerList()
				return timersanitycheck.getSimulTimerList()

		return None

	def timeChanged(self, entry):
		print "[GBIpboxRemoteTimer] timer changed ", str(entry)

		entry.service_ref = ServiceReference(":".join(str(entry.service_ref).split(":")[:10]))
		args = urllib.urlencode({
				'sRef': str(entry.service_ref),
				'begin': str(entry.begin),
				'end': str(entry.end),
				'channelOld': str(entry.orig.service_ref),
				'beginOld': str(entry.orig.begin),
				'endOld': str(entry.orig.end),
Ejemplo n.º 26
0
def editTimer(session, serviceref, begin, end, name, description, disabled,
              justplay, afterEvent, dirname, tags, repeated, channelOld,
              beginOld, endOld, recordingtype, vpsinfo, always_zap, pipzap,
              allow_duplicate, autoadjust):
    channelOld_str = ':'.join(str(channelOld).split(':')[:11])
    rt = session.nav.RecordTimer
    for timer in rt.timer_list + rt.processed_timers:
        needed_ref = ':'.join(
            timer.service_ref.ref.toString().split(':')[:11]) == channelOld_str
        if needed_ref and int(timer.begin) == beginOld and int(
                timer.end) == endOld:
            timer.service_ref = ServiceReference(serviceref)
            # TODO: start end time check
            timer.begin = int(float(begin))
            timer.end = int(float(end))
            timer.name = name
            timer.description = description
            # TODO : EIT
            # timer.eit = eit
            timer.disabled = disabled
            timer.justplay = justplay
            timer.afterEvent = afterEvent
            timer.dirname = dirname
            timer.tags = tags
            timer.repeated = repeated
            timer.processRepeated()
            if vpsinfo is not None:
                timer.vpsplugin_enabled = vpsinfo["vpsplugin_enabled"]
                timer.vpsplugin_overwrite = vpsinfo["vpsplugin_overwrite"]
                timer.vpsplugin_time = vpsinfo["vpsplugin_time"]

            if always_zap != -1:
                if hasattr(timer, "always_zap"):
                    timer.always_zap = always_zap == 1
                if hasattr(timer, "zapbeforerecord"):
                    timer.zapbeforerecord = always_zap == 1

            if pipzap != -1:
                if hasattr(timer, "pipzap"):
                    timer.pipzap = pipzap == 1

            if hasattr(timer, "allow_duplicate"):
                timer.allow_duplicate = allow_duplicate

            if hasattr(timer, "autoadjust"):
                if autoadjust == -1:
                    autoadjust = config.recording.adjust_time_to_event.value and 1 or 0
                timer.autoadjust = autoadjust

            if recordingtype:
                timer.descramble = {
                    "normal": True,
                    "descrambled": True,
                    "scrambled": False,
                }[recordingtype]
                timer.record_ecm = {
                    "normal": False,
                    "descrambled": True,
                    "scrambled": True,
                }[recordingtype]

            # TODO: multi tuner test
            sanity = TimerSanityCheck(rt.timer_list, timer)
            conflicts = None
            if not sanity.check():
                conflicts = sanity.getSimulTimerList()
                if conflicts is not None:
                    for conflict in conflicts:
                        if conflict.setAutoincreaseEnd(timer):
                            rt.timeChanged(conflict)
                            if not sanity.check():
                                conflicts = sanity.getSimulTimerList()
            if conflicts is None:
                rt.timeChanged(timer)
                return {
                    "result": True,
                    "message": _("Timer '%s' changed") % name
                }
            else:
                errors = []
                conflictinfo = []
                for conflict in conflicts:
                    errors.append(conflict.name)
                    conflictinfo.append({
                        "serviceref":
                        str(conflict.service_ref),
                        "servicename":
                        removeBad(conflict.service_ref.getServiceName()),
                        "name":
                        conflict.name,
                        "begin":
                        conflict.begin,
                        "end":
                        conflict.end,
                        "realbegin":
                        strftime(_("%d.%m.%Y %H:%M"),
                                 (localtime(float(conflict.begin)))),
                        "realend":
                        strftime(_("%d.%m.%Y %H:%M"),
                                 (localtime(float(conflict.end))))
                    })

                return {
                    "result": False,
                    "message": _("Timer '%s' not saved while Conflict") % name,
                    "conflicts": conflictinfo
                }

    return {
        "result":
        False,
        "message":
        _("Could not find timer '%s' with given start and end time!") % name
    }
Ejemplo n.º 27
0
	def editTimer(self, param):
		print "[WebComponents.Timer] editTimer"

		#OK first we need to parse all of your Parameters
		#For some of them (like afterEvent or justplay) we can use default values
		#for others (the serviceReference or the Begin/End time of the timer
		#we have to quit if they are not set/have illegal values

		if 'sRef' not in param:
			return ( False, _("Missing Parameter: sRef") )
		service_ref = ServiceReference(param['sRef'])

		repeated = int(param.get('repeated') or 0)

		if 'begin' not in param:
			return ( False, _("Missing Parameter: begin") )
		begin = int(float(param['begin']))

		if 'end' not in param:
			return ( False, _("Missing Parameter: end") )
		end = int(float(param['end']))

		tm = int( time() )
		if tm <= begin:
			pass
		elif tm > begin and tm < end and repeated == 0:
			pass
		elif repeated == 0:
			return ( False, _("Illegal Parameter value for Parameter begin : '%s'") % begin )

		if 'applyMargin' in param:
			if param['applyMargin'] == "1":
				begin -= config.recording.margin_before.value * 60
				end += config.recording.margin_after.value * 60

		if 'name' not in param:
			return ( False, _("Missing Parameter: name") )
		name = param['name']

		if 'description' not in param:
			return ( False, _("Missing Parameter: description") )
		description = param['description'].replace("\n", " ")

		eit = param.get("eit", None)
		if eit is None or eit.strip() == "":
			eit = 0
		else:
			try: eit = int(eit)
			except ValueError: return ( False, _("Illegal Parameter value for Parameter eit : '%s'") % eit )

		print "[WebComponents.Sources.Timer]: eit=%d" %eit
		if eit != 0:
			#check if the given event exists, if it doesn't the timer may be already running
			epgcache = eEPGCache.getInstance()
			event = epgcache.lookupEventId(eServiceReference(param['sRef']), eit)
			if event:
				eit = event.getEventId()
				#TODO add some subservice handling
			else:
				print "[WebComponents.Sources.Timer] event not found, will be ignored"

		disabled = False #Default to: Enabled
		if 'disabled' in param:
			if param['disabled'] == "1":
				disabled = True
			else:
				#TODO - maybe we can give the user some useful hint here
				pass

		justplay = False #Default to: Record
		if 'justplay' in param:
			if param['justplay'] == "1":
				justplay = True

		if not justplay and not config.misc.recording_allowed.value:
			return (False, _("Recording is currently disabled!"))

		afterEvent = 3 #Default to Afterevent: Auto
		if 'afterevent' in param:
			if (param['afterevent'] == "0") or (param['afterevent'] == "1") or (param['afterevent'] == "2"):
				afterEvent = int(param['afterevent'])

		dirname = preferredTimerPath()
		if 'dirname' in param and param['dirname']:
			dirname = param['dirname']

		tags = []
		if 'tags' in param and param['tags']:
			tags = unescape(param['tags']).split(' ')

		delold = 0
		if 'deleteOldOnSave' in param:
			delold = int(param['deleteOldOnSave'])

		#Try to edit an existing Timer
		if delold:
			if 'channelOld' in param and param['channelOld']:
				channelOld = ServiceReference(param['channelOld'])
			else:
				return ( False, _("Missing Parameter: channelOld") )
			# We do need all of the following Parameters, too, for being able of finding the Timer.
			# Therefore so we can neither use default values in this part nor can we
			# continue if a parameter is missing
			if 'beginOld' not in param:
				return ( False, _("Missing Parameter: beginOld") )
			beginOld = int(param['beginOld'])

			if 'endOld' not in param:
				return ( False, _("Missing Parameter: endOld") )
			endOld = int(param['endOld'])

			#let's try to find the timer
			try:
				for timer in self.recordtimer.timer_list + self.recordtimer.processed_timers:
					if str(timer.service_ref) == str(channelOld):
						if int(timer.begin) == beginOld:
							if int(timer.end) == endOld: #we've found the timer we've been searching for
								#set the new data
								timer.service_ref = service_ref
								timer.begin = begin
								timer.end = end
								timer.name = name
								timer.description = description
								timer.eit = eit
								timer.disabled = disabled
								timer.justplay = justplay
								timer.afterEvent = afterEvent
								timer.dirname = dirname
								timer.tags = tags
								timer.repeated = repeated
								timer.processRepeated()

								#sanity check
								timersanitycheck = TimerSanityCheck(self.session.nav.RecordTimer.timer_list, timer)
								conflicts = None
								if not timersanitycheck.check():
									conflicts = timersanitycheck.getSimulTimerList()
									if conflicts is not None:
										for x in conflicts:
											if x.setAutoincreaseEnd(entry):
												self.session.nav.RecordTimer.timeChanged(x)
										if not timersanitycheck.check():
											conflicts = timersanitycheck.getSimulTimerList()

								if conflicts is None:
									self.recordtimer.timeChanged(timer) #go and save it
									print "[WebComponents.Timer] editTimer: Timer changed!"
									return ( True, "Timer '%s' changed" %(timer.name) )
								else:
									print "[WebComponents.Timer] editTimer conflicting Timers: %s" %(conflicts)
									msg = ""
									for t in conflicts:
										msg = "%s / %s" %(msg, t.name)

									return (False, _("Conflicting Timer(s) detected! %s") %(msg))

			except Exception as e:
				#obviously some value was not good, return an error
				import traceback
				print traceback.format_exc()
				return ( False, _("Changing the timer for '%s' failed!") % name )


			return ( False, _("Could not find timer '%s' with given start and end time!") % name )

		#Try adding a new Timer

		try:
			#Create a new instance of recordtimerentry
			timer = RecordTimerEntry(service_ref, begin, end, name, description, eit, disabled, justplay, afterEvent, dirname=dirname, tags=tags)
			timer.repeated = repeated
			#add the new timer
			conflicts = self.recordtimer.record(timer)
			if conflicts is None:
				return ( True, _("Timer '%s' added") %(timer.name) )
			else:
				print "[WebComponents.Timer] editTimer conflicting Timers: %s" %(conflicts)
				msg = ""
				for timer in conflicts:
					msg = "%s / %s" %(msg, timer.name)

				return (False, _("Conflicting Timer(s) detected! %s") %(msg))

		except Exception, e:
			#something went wrong, most possibly one of the given paramater-values was wrong
			print "[WebComponents.Timer] editTimer exception: %s" %(e)
			return ( False, _("Could not add timer '%s'!") % name )
Ejemplo n.º 28
0
    def editTimer(self, param):
        print("[WebComponents.Timer] editTimer")

        #OK first we need to parse all of your Parameters
        #For some of them (like afterEvent or justplay) we can use default values
        #for others (the serviceReference or the Begin/End time of the timer
        #we have to quit if they are not set/have illegal values

        if 'sRef' not in param:
            return (False, _("Missing Parameter: sRef"))
        service_ref = ServiceReference(param['sRef'])

        repeated = int(param.get('repeated') or 0)

        if 'begin' not in param:
            return (False, _("Missing Parameter: begin"))
        begin = int(float(param['begin']))

        if 'end' not in param:
            return (False, _("Missing Parameter: end"))
        end = int(float(param['end']))

        tm = int(time())
        if tm <= begin:
            pass
        elif tm > begin and tm < end and repeated == 0:
            pass
        elif repeated == 0:
            return (False,
                    _("Illegal Parameter value for Parameter begin : '%s'") %
                    begin)

        if 'applyMargin' in param:
            if param['applyMargin'] == "1":
                begin -= config.recording.margin_before.value * 60
                end += config.recording.margin_after.value * 60

        if 'name' not in param:
            return (False, _("Missing Parameter: name"))
        name = param['name']

        if 'description' not in param:
            return (False, _("Missing Parameter: description"))
        description = param['description'].replace("\n", " ")

        eit = param.get("eit", None)
        if eit is None or eit.strip() == "":
            eit = 0
        else:
            try:
                eit = int(eit)
            except ValueError:
                return (False,
                        _("Illegal Parameter value for Parameter eit : '%s'") %
                        eit)

        print("[WebComponents.Sources.Timer]: eit=%d" % eit)
        if eit != 0:
            #check if the given event exists, if it doesn't the timer may be already running
            epgcache = eEPGCache.getInstance()
            event = epgcache.lookupEventId(eServiceReference(param['sRef']),
                                           eit)
            if event:
                eit = event.getEventId()
                #TODO add some subservice handling
            else:
                print(
                    "[WebComponents.Sources.Timer] event not found, will be ignored"
                )

        disabled = False  #Default to: Enabled
        if 'disabled' in param:
            if param['disabled'] == "1":
                disabled = True
            else:
                #TODO - maybe we can give the user some useful hint here
                pass

        justplay = False  #Default to: Record
        if 'justplay' in param:
            if param['justplay'] == "1":
                justplay = True

        afterEvent = 3  #Default to Afterevent: Auto
        if 'afterevent' in param:
            if (param['afterevent'] == "0") or (param['afterevent']
                                                == "1") or (param['afterevent']
                                                            == "2"):
                afterEvent = int(param['afterevent'])

        dirname = preferredTimerPath()
        if 'dirname' in param and param['dirname']:
            dirname = param['dirname']

        tags = []
        if 'tags' in param and param['tags']:
            tags = unescape(param['tags']).split(' ')

        delold = 0
        if 'deleteOldOnSave' in param:
            delold = int(param['deleteOldOnSave'])

        #Try to edit an existing Timer
        if delold:
            if 'channelOld' in param and param['channelOld']:
                channelOld = ServiceReference(param['channelOld'])
            else:
                return (False, _("Missing Parameter: channelOld"))
            # We do need all of the following Parameters, too, for being able of finding the Timer.
            # Therefore so we can neither use default values in this part nor can we
            # continue if a parameter is missing
            if 'beginOld' not in param:
                return (False, _("Missing Parameter: beginOld"))
            beginOld = int(param['beginOld'])

            if 'endOld' not in param:
                return (False, _("Missing Parameter: endOld"))
            endOld = int(param['endOld'])

            #let's try to find the timer
            try:
                for timer in self.recordtimer.timer_list + self.recordtimer.processed_timers:
                    if str(timer.service_ref) == str(channelOld):
                        if int(timer.begin) == beginOld:
                            if int(
                                    timer.end
                            ) == endOld:  #we've found the timer we've been searching for
                                #set the new data
                                timer.service_ref = service_ref
                                timer.begin = begin
                                timer.end = end
                                timer.name = name
                                timer.description = description
                                timer.eit = eit
                                timer.disabled = disabled
                                timer.justplay = justplay
                                timer.afterEvent = afterEvent
                                timer.dirname = dirname
                                timer.tags = tags
                                timer.repeated = repeated
                                timer.processRepeated()

                                #sanity check
                                timersanitycheck = TimerSanityCheck(
                                    self.session.nav.RecordTimer.timer_list,
                                    timer)
                                conflicts = None
                                if not timersanitycheck.check():
                                    conflicts = timersanitycheck.getSimulTimerList(
                                    )
                                    if conflicts is not None:
                                        for x in conflicts:
                                            if x.setAutoincreaseEnd(entry):
                                                self.session.nav.RecordTimer.timeChanged(
                                                    x)
                                        if not timersanitycheck.check():
                                            conflicts = timersanitycheck.getSimulTimerList(
                                            )

                                if conflicts is None:
                                    self.recordtimer.timeChanged(
                                        timer)  #go and save it
                                    print(
                                        "[WebComponents.Timer] editTimer: Timer changed!"
                                    )
                                    return (True, "Timer '%s' changed" %
                                            (timer.name))
                                else:
                                    print(
                                        "[WebComponents.Timer] editTimer conflicting Timers: %s"
                                        % (conflicts))
                                    msg = ""
                                    for t in conflicts:
                                        msg = "%s / %s" % (msg, t.name)

                                    return (
                                        False,
                                        _("Conflicting Timer(s) detected! %s")
                                        % (msg))

            except Exception as e:
                #obviously some value was not good, return an error
                import traceback
                print(traceback.format_exc())
                return (False, _("Changing the timer for '%s' failed!") % name)

            return (
                False,
                _("Could not find timer '%s' with given start and end time!") %
                name)

        #Try adding a new Timer

        try:
            #Create a new instance of recordtimerentry
            timer = RecordTimerEntry(service_ref,
                                     begin,
                                     end,
                                     name,
                                     description,
                                     eit,
                                     disabled,
                                     justplay,
                                     afterEvent,
                                     dirname=dirname,
                                     tags=tags)
            timer.repeated = repeated
            #add the new timer
            conflicts = self.recordtimer.record(timer)
            if conflicts is None:
                return (True, _("Timer '%s' added") % (timer.name))
            else:
                print(
                    "[WebComponents.Timer] editTimer conflicting Timers: %s" %
                    (conflicts))
                msg = ""
                for timer in conflicts:
                    msg = "%s / %s" % (msg, timer.name)

                return (False, _("Conflicting Timer(s) detected! %s") % (msg))

        except Exception as e:
            #something went wrong, most possibly one of the given paramater-values was wrong
            print("[WebComponents.Timer] editTimer exception: %s" % (e))
            return (False, _("Could not add timer '%s'!") % name)

        return (False, "Unexpected Error")
Ejemplo n.º 29
0
def editTimer(session, serviceref, begin, end, name, description, disabled,
              justplay, afterEvent, dirname, tags, repeated, channelOld,
              beginOld, endOld, vpsinfo, always_zap):
    # TODO: exception handling
    channelOld_str = ':'.join(str(channelOld).split(':')[:11])
    rt = session.nav.RecordTimer
    for timer in rt.timer_list + rt.processed_timers:
        needed_ref = ':'.join(
            timer.service_ref.ref.toString().split(':')[:11]) == channelOld_str
        if needed_ref and int(timer.begin) == beginOld and int(
                timer.end) == endOld:
            timer.service_ref = ServiceReference(serviceref)
            # TODO: start end time check
            timer.begin = int(float(begin))
            timer.end = int(float(end))
            timer.name = name
            timer.description = description
            # TODO : EIT
            # timer.eit = eit
            timer.disabled = disabled
            timer.justplay = justplay
            timer.afterEvent = afterEvent
            timer.dirname = dirname
            timer.tags = tags
            timer.repeated = repeated
            timer.processRepeated()
            if vpsinfo is not None:
                timer.vpsplugin_enabled = vpsinfo["vpsplugin_enabled"]
                timer.vpsplugin_overwrite = vpsinfo["vpsplugin_overwrite"]
                timer.vpsplugin_time = vpsinfo["vpsplugin_time"]

            if always_zap != -1:
                if hasattr(timer, "always_zap"):
                    timer.always_zap = always_zap == 1

            # TODO: multi tuner test
            sanity = TimerSanityCheck(rt.timer_list, timer)
            conflicts = None
            if not sanity.check():
                conflicts = sanity.getSimulTimerList()
                if conflicts is not None:
                    for conflict in conflicts:
                        if conflict.setAutoincreaseEnd(entry):
                            rt.timeChanged(conflict)
                            if not sanity.check():
                                conflicts = sanity.getSimulTimerList()
            if conflicts is None:
                rt.timeChanged(timer)
                return {
                    "result": True,
                    "message": _("Timer '%s' changed") % name
                }
            else:
                errors = []
                conflictinfo = []
                for conflict in conflicts:
                    errors.append(conflict.name)
                    conflictinfo.append({
                        "serviceref":
                        str(conflict.service_ref),
                        "servicename":
                        mangle_epg_text(conflict.service_ref.getServiceName()),
                        "name":
                        conflict.name,
                        "begin":
                        conflict.begin,
                        "end":
                        conflict.end,
                        "realbegin":
                        strftime("%d.%m.%Y %H:%M",
                                 (localtime(float(conflict.begin)))),
                        "realend":
                        strftime("%d.%m.%Y %H:%M",
                                 (localtime(float(conflict.end))))
                    })

                return {
                    "result": False,
                    "message": _("Timer '%s' not saved while Conflict") % name,
                    "conflicts": conflictinfo
                }

    msg = _("Could not find timer '%s' with given start and end time!") % name
    return {"result": False, "message": msg}
Ejemplo n.º 30
0
        try:
            httprequest = urllib2.urlopen(baseurl + '/web/timeradd?' + args)
            xmldoc = minidom.parseString(httprequest.read())
            status = xmldoc.getElementsByTagName('e2simplexmlresult')[0]
            success = getValueFromNode(status, 'e2state') == "True"
        except Exception, e:
            print "[GBIpboxRemoteTimer]", e
            return None

        self.getTimers()

        if not success:
            timersanitycheck = TimerSanityCheck(self._timer_list, entry)
            if not timersanitycheck.check():
                print "timer conflict detected!"
                print timersanitycheck.getSimulTimerList()
                return timersanitycheck.getSimulTimerList()

        return None

    def timeChanged(self, entry):
        print "[GBIpboxRemoteTimer] timer changed ", str(entry)

        entry.service_ref = ServiceReference(":".join(
            str(entry.service_ref).split(":")[:10]))
        args = urllib.urlencode({
            'sRef': str(entry.service_ref),
            'begin': str(entry.begin),
            'end': str(entry.end),
            'channelOld': str(entry.orig.service_ref),
            'beginOld': str(entry.orig.begin),