本文整理汇总了Python中RecordTimer.RecordTimerEntry.afterEvent方法的典型用法代码示例。如果您正苦于以下问题:Python RecordTimerEntry.afterEvent方法的具体用法?Python RecordTimerEntry.afterEvent怎么用?Python RecordTimerEntry.afterEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RecordTimer.RecordTimerEntry
的用法示例。
在下文中一共展示了RecordTimerEntry.afterEvent方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: UPDT
# 需要导入模块: from RecordTimer import RecordTimerEntry [as 别名]
# 或者: from RecordTimer.RecordTimerEntry import afterEvent [as 别名]
def UPDT(self, args):
# <id> <settings>
args = args.split(None, 1)
if len(args) != 2:
payload = "%d argument error" % (CODE_SYNTAX,)
return self.sendLine(payload)
try:
timerId = int(args[0])
except ValueError:
payload = "%d argument error" % (CODE_SYNTAX,)
return self.sendLine(payload)
list = self.getTimerList()
if timerId < 1:
payload = "%d argument error" % (CODE_SYNTAX,)
return self.sendLine(payload)
if len(list) >= timerId: oldTimer = list[timerId - 1]
else: oldTimer = None
try:
flags, channelid, datestring, beginstring, endstring, priority, lifetime, name, description = args[1].split(':')
flags = int(flags)
service_ref = ServiceReference(self.channelList[int(channelid)-1])
datestruct = strptime(datestring, '%Y-%m-%d')
timestruct = strptime(beginstring, '%H%M')
begin = mktime((datestruct.tm_year, datestruct.tm_mon, datestruct.tm_mday, timestruct.tm_hour, timestruct.tm_min, 0, datestruct.tm_wday, datestruct.tm_yday, -1))
timestruct = strptime(endstring, '%H%M')
end = mktime((datestruct.tm_year, datestruct.tm_mon, datestruct.tm_mday, timestruct.tm_hour, timestruct.tm_min, 0, datestruct.tm_wday, datestruct.tm_yday, -1))
del datestruct, timestruct
except ValueError as e:
payload = "%d argument error" % (CODE_SYNTAX,)
return self.sendLine(payload)
except KeyError as e:
payload = "%d argument error" % (CODE_SYNTAX,)
return self.sendLine(payload)
if end < begin: end += 86400 # Add 1 day, beware - this is evil and might not work correctly due to dst
timer = RecordTimerEntry(service_ref, begin, end, name, description, 0, disabled=flags & 1 == 0)
if oldTimer:
recordTimer.removeEntry(oldTimer)
timer.justplay = oldTimer.justplay
timer.afterEvent = oldTimer.afterEvent
timer.dirname = oldTimer.dirname
timer.tags = oldTimer.tags
timer.log_entries = oldTimer.log_entries
conflict = recordTimer.record(timer)
if conflict is None:
return self.sendTimerLine(timer, timerId, last=True)
else:
payload = "%d timer conflict detected, original timer lost." % (CODE_ERR_LOCAL,)
return self.sendLine(payload)
示例2: parseTimer
# 需要导入模块: from RecordTimer import RecordTimerEntry [as 别名]
# 或者: from RecordTimer.RecordTimerEntry import afterEvent [as 别名]
#.........这里部分代码省略.........
doLog(msg)
newEntry.log(501, msg)
if allow_modify:
if self.modifyTimer(newEntry, name, shortdesc, begin, end, serviceref, eit, base_timer=timer):
msg = "[AutoTimer] AutoTimer modified timer: %s ." % (newEntry.name)
doLog(msg)
newEntry.log(501, msg)
modified += 1
else:
msg = "[AutoTimer] AutoTimer modification not allowed for timer %s because conflicts or double timer." % (newEntry.name)
doLog(msg)
if oldEntry:
self.setOldTimer(newEntry, oldEntry)
doLog("[AutoTimer] conflict for modification timer %s detected return to old timer" % (newEntry.name))
continue
else:
msg = "[AutoTimer] AutoTimer modification not allowed for timer: %s ." % (newEntry.name)
doLog(msg)
continue
else:
newEntry = RecordTimerEntry(ServiceReference(serviceref), begin, end, name, shortdesc, eit)
newAT = True
msg = "[AutoTimer] Try to add new timer based on AutoTimer %s." % (timer.name)
doLog(msg)
newEntry.log(500, msg)
# Mark this entry as AutoTimer
newEntry.flags.add("autotimer")
# Apply afterEvent
if timer.hasAfterEvent():
afterEvent = timer.getAfterEventTimespan(localtime(end))
if afterEvent is None:
afterEvent = timer.getAfterEvent()
if afterEvent is not None:
newEntry.afterEvent = afterEvent
newEntry.dirname = dest
newEntry.calculateFilename()
newEntry.justplay = timer.justplay
newEntry.vpsplugin_enabled = timer.vps_enabled
newEntry.vpsplugin_overwrite = timer.vps_overwrite
newEntry.conflict_detection = timer.conflict_detection
newEntry.always_zap = timer.always_zap
newEntry.zap_wakeup = timer.zap_wakeup
tags = timer.tags[:]
if config.plugins.autotimer.add_autotimer_to_tags.value:
if 'AutoTimer' not in tags:
tags.append('AutoTimer')
if config.plugins.autotimer.add_name_to_tags.value:
tagname = timer.name.strip()
if tagname:
tagname = tagname[0].upper() + tagname[1:].replace(" ", "_")
if tagname not in tags:
tags.append(tagname)
newEntry.tags = tags
if oldExists and newAT is None:
if self.isResolvedConflict(newEntry):
recordHandler.timeChanged(newEntry)
else:
if oldEntry:
self.setOldTimer(newEntry, oldEntry)
示例3: parseTimer
# 需要导入模块: from RecordTimer import RecordTimerEntry [as 别名]
# 或者: from RecordTimer.RecordTimerEntry import afterEvent [as 别名]
#.........这里部分代码省略.........
newEntry.log(501, msg)
else:
if config.plugins.autotimer.refresh.value != "all":
doLog("Won't modify existing timer because it's no timer set by us")
continue
msg = "[AutoTimer] Warning, AutoTimer %s messed with a timer which might not belong to it: %s ." % (timer.name, newEntry.name)
doLog(msg)
newEntry.log(501, msg)
modified += 1
if allow_modify:
self.modifyTimer(newEntry, name, shortdesc, begin, end, serviceref, eit)
msg = "[AutoTimer] AutoTimer modified timer: %s ." % (newEntry.name)
doLog(msg)
newEntry.log(501, msg)
else:
msg = "[AutoTimer] AutoTimer modification not allowed for timer: %s ." % (newEntry.name)
doLog(msg)
else:
newEntry = RecordTimerEntry(ServiceReference(serviceref), begin, end, name, shortdesc, eit)
msg = "[AutoTimer] Try to add new timer based on AutoTimer %s." % (timer.name)
doLog(msg)
newEntry.log(500, msg)
# Mark this entry as AutoTimer (only AutoTimers will have this Attribute set)
# It is only temporarily, after a restart it will be lost,
# because it won't be stored in the timer xml file
newEntry.isAutoTimer = True
# Apply afterEvent
if timer.hasAfterEvent():
afterEvent = timer.getAfterEventTimespan(localtime(end))
if afterEvent is None:
afterEvent = timer.getAfterEvent()
if afterEvent is not None:
newEntry.afterEvent = afterEvent
newEntry.dirname = dest
newEntry.calculateFilename()
newEntry.justplay = timer.justplay
newEntry.vpsplugin_enabled = timer.vps_enabled
newEntry.vpsplugin_overwrite = timer.vps_overwrite
tags = timer.tags[:]
if config.plugins.autotimer.add_autotimer_to_tags.value:
if TAG not in tags:
tags.append(TAG)
if config.plugins.autotimer.add_name_to_tags.value:
tagname = timer.name.strip()
if tagname:
tagname = tagname[0].upper() + tagname[1:].replace(" ", "_")
if tagname not in tags:
tags.append(tagname)
newEntry.tags = tags
if oldExists:
# XXX: this won't perform a sanity check, but do we actually want to do so?
recordHandler.timeChanged(newEntry)
else:
conflictString = ""
if similarTimer:
conflictString = similardict[eit].conflictString
msg = "[AutoTimer] Try to add similar Timer because of conflicts with %s." % (conflictString)
示例4: parseTimer
# 需要导入模块: from RecordTimer import RecordTimerEntry [as 别名]
# 或者: from RecordTimer.RecordTimerEntry import afterEvent [as 别名]
#.........这里部分代码省略.........
# But there is a match
if oldExists:
continue
# We want to search for possible doubles
for rtimer in chain.from_iterable( itervalues(timerdict) ):
if not rtimer.disabled:
if self.checkDoubleTimers(timer, name, rtimer.name, begin, rtimer.begin, end, rtimer.end ):
oldExists = True
# print("[AutoTimer] We found a timer with same StartTime, skipping event")
break
if timer.avoidDuplicateDescription >= 2:
if self.checkSimilarity(timer, name, rtimer.name, shortdesc, rtimer.description, extdesc, rtimer.extdesc ):
oldExists = True
print("[AutoTimer] We found a timer (any service) with same description, skipping event")
break
if oldExists:
continue
if timer.checkCounter(timestamp):
print("[AutoTimer] Not adding new timer because counter is depleted.")
continue
newEntry = RecordTimerEntry(ServiceReference(serviceref), begin, end, name, shortdesc, eit)
newEntry.log(500, "[AutoTimer] Try to add new timer based on AutoTimer %s." % (timer.name))
# Mark this entry as AutoTimer (only AutoTimers will have this Attribute set)
# It is only temporarily, after a restart it will be lost,
# because it won't be stored in the timer xml file
newEntry.isAutoTimer = True
# Apply afterEvent
if timer.hasAfterEvent():
afterEvent = timer.getAfterEventTimespan(localtime(end))
if afterEvent is None:
afterEvent = timer.getAfterEvent()
if afterEvent is not None:
newEntry.afterEvent = afterEvent
newEntry.dirname = timer.destination
newEntry.justplay = timer.justplay
newEntry.vpsplugin_enabled = timer.vps_enabled
newEntry.vpsplugin_overwrite = timer.vps_overwrite
tags = timer.tags[:]
if config.plugins.autotimer.add_autotimer_to_tags.value:
tags.append('AutoTimer')
if config.plugins.autotimer.add_name_to_tags.value:
tagname = timer.name.strip()
if tagname:
tagname = tagname[0].upper() + tagname[1:].replace(" ", "_")
tags.append(tagname)
newEntry.tags = tags
if oldExists:
# XXX: this won't perform a sanity check, but do we actually want to do so?
recordHandler.timeChanged(newEntry)
if renameTimer is not None and timer.series_labeling:
renameTimer(newEntry, name, evtBegin, evtEnd)
else:
conflictString = ""
if similarTimer:
conflictString = similardict[eit].conflictString
newEntry.log(504, "[AutoTimer] Try to add similar Timer because of conflicts with %s." % (conflictString))
示例5: parseEPG
# 需要导入模块: from RecordTimer import RecordTimerEntry [as 别名]
# 或者: from RecordTimer.RecordTimerEntry import afterEvent [as 别名]
#.........这里部分代码省略.........
timers.append((name, begin, end, serviceref, timer.name))
if simulateOnly:
continue
# Initialize
newEntry = None
oldExists = False
# Check for double Timers
# We first check eit and if user wants us to guess event based on time
# we try this as backup. The allowed diff should be configurable though.
for rtimer in recorddict.get(serviceref, ()):
if rtimer.eit == eit or config.plugins.autotimer.try_guessing.value and getTimeDiff(rtimer, begin, end) > ((duration/10)*8):
oldExists = True
# Abort if we don't want to modify timers or timer is repeated
if config.plugins.autotimer.refresh.value == "none" or rtimer.repeated:
print "[AutoTimer] Won't modify existing timer because either no modification allowed or repeated timer"
break
if hasattr(rtimer, "isAutoTimer"):
print "[AutoTimer] Modifying existing AutoTimer!"
else:
if config.plugins.autotimer.refresh.value != "all":
print "[AutoTimer] Won't modify existing timer because it's no timer set by us"
break
print "[AutoTimer] Warning, we're messing with a timer which might not have been set by us"
newEntry = rtimer
modified += 1
# Modify values saved in timer
newEntry.name = name
newEntry.description = description
newEntry.begin = int(begin)
newEntry.end = int(end)
newEntry.service_ref = ServiceReference(serviceref)
break
elif timer.avoidDuplicateDescription == 1 and not rtimer.disabled and rtimer.name == name and rtimer.description == description:
oldExists = True
print "[AutoTimer] We found a timer with same description, skipping event"
break
# We found no timer we want to edit
if newEntry is None:
# But there is a match
if oldExists:
continue
# We want to search for possible doubles
if timer.avoidDuplicateDescription == 2:
# I thinks thats the fastest way to do this, though it's a little ugly
try:
for list in recorddict.values():
for rtimer in list:
if not rtimer.disabled and rtimer.name == name and rtimer.description == description:
raise AutoTimerIgnoreTimerException("We found a timer with same description, skipping event")
except AutoTimerIgnoreTimerException, etite:
print etite
continue
if timer.checkCounter(timestamp):
continue
print "[AutoTimer] Adding an event."
newEntry = RecordTimerEntry(ServiceReference(serviceref), begin, end, name, description, eit)
# Mark this entry as AutoTimer (only AutoTimers will have this Attribute set)
newEntry.isAutoTimer = True
# Apply afterEvent
if timer.hasAfterEvent():
afterEvent = timer.getAfterEventTimespan(localtime(end))
if afterEvent is None:
afterEvent = timer.getAfterEvent()
if afterEvent is not None:
newEntry.afterEvent = afterEvent
newEntry.dirname = timer.destination
newEntry.justplay = timer.justplay
newEntry.tags = timer.tags
if oldExists:
# XXX: this won't perform a sanity check, but do we actually want to do so?
NavigationInstance.instance.RecordTimer.timeChanged(newEntry)
else:
conflicts = NavigationInstance.instance.RecordTimer.record(newEntry)
if conflicts and config.plugins.autotimer.disabled_on_conflict.value:
newEntry.disabled = True
# We might want to do the sanity check locally so we don't run it twice - but I consider this workaround a hack anyway
conflicts = NavigationInstance.instance.RecordTimer.record(newEntry)
conflicting.append((name, begin, end, serviceref, timer.name))
if conflicts is None:
timer.decrementCounter()
new += 1
recorddict.setdefault(serviceref, []).append(newEntry)
else:
conflicting.append((name, begin, end, serviceref, timer.name))
示例6: parseEPG
# 需要导入模块: from RecordTimer import RecordTimerEntry [as 别名]
# 或者: from RecordTimer.RecordTimerEntry import afterEvent [as 别名]
#.........这里部分代码省略.........
if oldExists:
continue
# We want to search for possible doubles
if timer.avoidDuplicateDescription >= 2:
for rtimer in chain.from_iterable( itervalues(recorddict) ):
if not rtimer.disabled \
and rtimer.name == name \
and rtimer.description == shortdesc:
# Some channels indicate replays in the extended descriptions
# If the similarity percent is higher then 0.8 it is a very close match
if ( len(extdesc) == len(rtimer.extdesc) and extdesc == rtimer.extdesc ) \
or ( 0.8 < SequenceMatcher(lambda x: x == " ",extdesc, rtimer.extdesc).ratio() ):
oldExists = True
print("[AutoTimer] We found a timer (any service) with same description, skipping event")
break
if oldExists:
continue
if timer.checkCounter(timestamp):
print("[AutoTimer] Not adding new timer because counter is depleted.")
continue
newEntry = RecordTimerEntry(ServiceReference(serviceref), begin, end, name, shortdesc, eit)
newEntry.log(500, "[AutoTimer] Try to add new timer based on AutoTimer %s." % (timer.name))
# Mark this entry as AutoTimer (only AutoTimers will have this Attribute set)
# It is only temporarily, after a restart it will be lost,
# because it won't be stored in the timer xml file
newEntry.isAutoTimer = True
# Apply afterEvent
if timer.hasAfterEvent():
afterEvent = timer.getAfterEventTimespan(localtime(end))
if afterEvent is None:
afterEvent = timer.getAfterEvent()
if afterEvent is not None:
newEntry.afterEvent = afterEvent
newEntry.dirname = timer.destination
newEntry.justplay = timer.justplay
newEntry.tags = timer.tags
newEntry.vpsplugin_enabled = timer.vps_enabled
newEntry.vpsplugin_overwrite = timer.vps_overwrite
if oldExists:
# XXX: this won't perform a sanity check, but do we actually want to do so?
recordHandler.timeChanged(newEntry)
else:
conflictString = ""
if similarTimer:
conflictString = similar[eit].conflictString
newEntry.log(504, "[AutoTimer] Try to add similar Timer because of conflicts with %s." % (conflictString))
# Try to add timer
conflicts = recordHandler.record(newEntry)
if conflicts:
conflictString += ' / '.join(["%s (%s)" % (x.name, strftime("%Y%m%d %H%M", localtime(x.begin))) for x in conflicts])
print("[AutoTimer] conflict with %s detected" % (conflictString))
if conflicts and config.plugins.autotimer.addsimilar_on_conflict.value:
# We start our search right after our actual index
# Attention we have to use a copy of the list, because we have to append the previous older matches
lepgm = len(epgmatches)
for i in xrange(lepgm):
示例7: parseEPG
# 需要导入模块: from RecordTimer import RecordTimerEntry [as 别名]
# 或者: from RecordTimer.RecordTimerEntry import afterEvent [as 别名]
#.........这里部分代码省略.........
# Initialize
newEntry = None
oldExists = False
# Check for double Timers
# We first check eit and if user wants us to guess event based on time
# we try this as backup. The allowed diff should be configurable though.
for rtimer in recorddict.get(serviceref, ()):
if rtimer.eit == eit or config.plugins.autotimer.try_guessing.value and getTimeDiff(rtimer, begin, end) > ((duration/10)*8):
oldExists = True
# Abort if we don't want to modify timers or timer is repeated
if config.plugins.autotimer.refresh.value == "none":
print "[AutoTimer] Won't modify existing timer because no modification allowed"
break
if rtimer.repeated:
print "[AutoTimer] Won't modify existing timer because repeated timer"
break
if hasattr(rtimer, "isAutoTimer"):
rtimer.log(501, "[AutoTimer] AutoTimer %s modified this automatically generated timer." % (timer.name,))
else:
if config.plugins.autotimer.refresh.value != "all":
print "[AutoTimer] Won't modify existing timer because it's no timer set by us"
break
rtimer.log(501, "[AutoTimer] Warning, AutoTimer %s messed with a timer which might not belong to it." % (timer.name,))
newEntry = rtimer
modified += 1
# Modify values saved in timer
newEntry.name = evtInfo.name
newEntry.description = evtInfo.shortDescription
newEntry.begin = int(begin)
newEntry.end = int(end)
newEntry.service_ref = ServiceReference(serviceref)
break
elif timer.avoidDuplicateDescription >= 1 and self.normalizeRecordTimer(rtimer) == evtInfo:
oldExists = True
print "[AutoTimer] We found a timer with same service and description, skipping event"
break
# We found no timer we want to edit
if newEntry is None:
# But there is a match
if oldExists:
continue
# We want to search for possible doubles
if timer.avoidDuplicateDescription >= 2 and self.isEventInList(evtInfo, recorddict, self.normalizeRecordTimer):
print "[AutoTimer] We found a timer with same description, skipping event"
continue
if timer.checkCounter(timestamp):
print "[AutoTimer] Not adding new timer because counter is depleted."
continue
newEntry = RecordTimerEntry(ServiceReference(serviceref), begin, end, evtInfo.name, evtInfo.shortDescription, eit)
newEntry.log(500, "[AutoTimer] Adding new timer based on AutoTimer %s." % (timer.name,))
# Mark this entry as AutoTimer (only AutoTimers will have this Attribute set)
newEntry.isAutoTimer = True
# Apply afterEvent
if timer.hasAfterEvent():
afterEvent = timer.getAfterEventTimespan(localtime(end))
if afterEvent is None:
afterEvent = timer.getAfterEvent()
if afterEvent is not None:
newEntry.afterEvent = afterEvent
newEntry.dirname = timer.destination
newEntry.justplay = timer.justplay
newEntry.tags = timer.tags
newEntry.vpsplugin_enabled = timer.vps_enabled
newEntry.vpsplugin_overwrite = timer.vps_overwrite
if oldExists:
# XXX: this won't perform a sanity check, but do we actually want to do so?
NavigationInstance.instance.RecordTimer.timeChanged(newEntry)
else:
conflicts = NavigationInstance.instance.RecordTimer.record(newEntry)
if conflicts and config.plugins.autotimer.disabled_on_conflict.value:
conflictString = ' / '.join(["%s (%s)" % (x.name, strftime("%Y%m%d %H%M", localtime(x.begin))) for x in conflicts])
newEntry.log(503, "[AutoTimer] Timer disabled because of conflicts with %s." % (conflictString,))
del conflictString
newEntry.disabled = True
# We might want to do the sanity check locally so we don't run it twice - but I consider this workaround a hack anyway
conflicts = NavigationInstance.instance.RecordTimer.record(newEntry)
conflicting.append((evtInfo.name, begin, end, serviceref, timer.name))
if conflicts is None:
timer.decrementCounter()
new += 1
recorddict.setdefault(serviceref, []).append(newEntry)
else:
conflicting.append((evtInfo.name, begin, end, serviceref, timer.name))
return (total, new, modified, timers, conflicting)
示例8: strptime
# 需要导入模块: from RecordTimer import RecordTimerEntry [as 别名]
# 或者: from RecordTimer.RecordTimerEntry import afterEvent [as 别名]
timestruct = strptime(endstring, '%H%M')
end = mktime((datestruct.tm_year, datestruct.tm_mon, datestruct.tm_mday, timestruct.tm_hour, timestruct.tm_min, 0, datestruct.tm_wday, datestruct.tm_yday, -1))
del datestruct, timestruct
except ValueError, e:
payload = "%d argument error" % (CODE_SYNTAX,)
return self.sendLine(payload)
except KeyError, e:
payload = "%d argument error" % (CODE_SYNTAX,)
return self.sendLine(payload)
if end < begin: end += 86400 # Add 1 day, beware - this is evil and might not work correctly due to dst
timer = RecordTimerEntry(service_ref, begin, end, name, description, 0, disabled=flags & 1 == 0)
if oldTimer:
recordTimer.removeEntry(oldTimer)
timer.justplay = oldTimer.justplay
timer.afterEvent = oldTimer.afterEvent
timer.dirname = oldTimer.dirname
timer.tags = oldTimer.tags
timer.log_entries = oldTimer.log_entries
conflict = recordTimer.record(timer)
if conflict is None:
return self.sendTimerLine(timer, timerId, last=True)
else:
payload = "%d timer conflict detected, original timer lost." % (CODE_ERR_LOCAL,)
return self.sendLine(payload)
def NEWT(self, args):
self.UPDT("999999999 " + args)
def MODT(self, args):