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
Example #2
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()
Example #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
		entry.timeChanged()
		print "[Timer] Record " + str(entry)
		entry.Timer = self
		self.addTimerEntry(entry)
		if dosave:
			self.saveTimer()
		return answer
Example #4
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)
Example #5
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)
Example #6
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
Example #7
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()
			else:
				if 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()
Example #8
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
Example #9
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()
Example #10
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
Example #11
0
	def isResolvedConflict(self, checktimer=None):
		if checktimer:
			timersanitycheck = TimerSanityCheck(NavigationInstance.instance.RecordTimer.timer_list, checktimer)
			if not timersanitycheck.check():
					return False
			elif timersanitycheck.doubleCheck():
				return False
			else:
				return True
		return False
Example #12
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("[TimerEdit] try to ENABLE timer")
                 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)
                         timer_changed = False
                 else:
                     print("[TimerEdit] 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()
def toggleTimerStatus(session, serviceref, begin, end):
    serviceref = unquote(serviceref)
    serviceref_str = ':'.join(str(serviceref).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]) == serviceref_str
        if needed_ref and int(timer.begin) == begin and int(timer.end) == end:
            if timer.disabled:
                timer.enable()
                effect = "enabled"
                sanity = TimerSanityCheck(rt.timer_list, timer)
                if not sanity.check():
                    timer.disable()
                    return {
                        "result":
                        False,
                        "message":
                        _("Timer '%s' not enabled while Conflict") %
                        (timer.name)
                    }
                elif sanity.doubleCheck():
                    timer.disable()
                    return {
                        "result": False,
                        "message":
                        _("Timer '%s' already exists!") % (timer.name)
                    }
            else:
                if timer.isRunning():
                    return {
                        "result":
                        False,
                        "message":
                        _("The timer '%s' now recorded! Not disabled!") %
                        (timer.name)
                    }
                else:
                    timer.disable()
                    effect = "disabled"
            rt.timeChanged(timer)
            return {
                "result":
                True,
                "message":
                _("The timer '%s' has been %s successfully") %
                (timer.name, effect),
                "disabled":
                timer.disabled
            }

    return {"result": False, "message": _("No matching Timer found")}
Example #14
0
	def isResolvedConflict(self, checktimer=None):
		if checktimer:
			check_timer_list = NavigationInstance.instance.RecordTimer.timer_list[:]
			if checktimer in check_timer_list:
				check_timer_list.remove(checktimer)
			timersanitycheck = TimerSanityCheck(check_timer_list, checktimer)
			if not timersanitycheck.check():
					return False
			elif timersanitycheck.doubleCheck():
				return False
			else:
				return True
		return False
Example #15
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
Example #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
Example #17
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
Example #18
0
def toggleTimerStatus(session, serviceref, begin, end):
	serviceref = unquote(serviceref)
	serviceref_str = ':'.join(str(serviceref).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]) == serviceref_str
		if needed_ref and int(timer.begin) == begin and int(timer.end) == end:
			if timer.disabled:
				timer.enable()
				effect = "enabled"
				sanity = TimerSanityCheck(rt.timer_list, timer)
				if not sanity.check():
					timer.disable()
					return {
						"result": False,
						"message": _("Timer '%s' not enabled while Conflict") % (timer.name)
					}
				elif sanity.doubleCheck():
					timer.disable()
					return {
						"result": False,
						"message": _("Timer '%s' already exists!") % (timer.name)
					}
			else:
				if timer.isRunning():
					return {
						"result": False,
						"message": _("The timer '%s' now recorded! Not disabled!") % (timer.name)
					}
				else:
					timer.disable()
					effect = "disabled"
			rt.timeChanged(timer)
			return {
				"result": True,
				"message": _("The timer '%s' has been %s successfully") % (timer.name, effect),
				"disabled": timer.disabled
			}

	return {
		"result": False,
		"message": _("No matching Timer found")
	}
Example #19
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()
Example #20
0
	def modifyTimer(self, timer, name, shortdesc, begin, end, serviceref, eit=None, base_timer=None):
		if base_timer:
			old_timer = timer
			timer.justplay = base_timer.justplay
			timer.conflict_detection = base_timer.conflict_detection
			timer.always_zap = base_timer.always_zap
		timer.name = name
		timer.description = shortdesc
		timer.begin = int(begin)
		timer.end = int(end)
		timer.service_ref = ServiceReference(serviceref)
		if eit: 
			timer.eit = eit
		if base_timer:
			timersanitycheck = TimerSanityCheck(NavigationInstance.instance.RecordTimer.timer_list, timer)
			if not timersanitycheck.check():
				return False
			elif timersanitycheck.doubleCheck():
				return False
			else:
				doLog("[AutoTimer] conflict not found for modify timer %s." % timer.name)
		return True
Example #21
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()
Example #22
0
	def modifyTimer(self, timer, name, shortdesc, begin, end, serviceref, eit=None, base_timer=None):
		if base_timer:
			timer.justplay = base_timer.justplay
			timer.conflict_detection = base_timer.conflict_detection
			timer.always_zap = base_timer.always_zap
		timer.name = name
		timer.description = shortdesc
		timer.begin = int(begin)
		timer.end = int(end)
		timer.service_ref = ServiceReference(serviceref)
		if eit:
			timer.eit = eit
		if base_timer:
			check_timer_list = NavigationInstance.instance.RecordTimer.timer_list[:]
			if timer in check_timer_list:
				check_timer_list.remove(timer)
			timersanitycheck = TimerSanityCheck(check_timer_list, timer)
			if not timersanitycheck.check():
				return False
			elif timersanitycheck.doubleCheck():
				return False
			else:
				doLog("[AutoTimer] conflict not found for modify timer %s." % timer.name)
		return True