2 from Screens.MessageBox import MessageBox
3 from AutoTimerOverview import AutoTimerOverview
6 from AutoTimer import AutoTimer
7 from AutoPoller import autopoller
10 from Plugins.Plugin import PluginDescriptor
13 from xml.parsers.expat import ExpatError
16 from Components.config import config, ConfigSubsection, ConfigEnableDisable, ConfigInteger, ConfigSelection
18 # Initialize Configuration
19 config.plugins.autotimer = ConfigSubsection()
20 config.plugins.autotimer.autopoll = ConfigEnableDisable(default = False)
21 config.plugins.autotimer.interval = ConfigInteger(default = 3, limits=(1, 24))
22 config.plugins.autotimer.refresh = ConfigSelection(choices = [("none", _("None")), ("auto", _("Only AutoTimers created during this Session")), ("all", _("All non-repeating Timers"))], default = "none")
23 config.plugins.autotimer.try_guessing = ConfigEnableDisable(default = False)
28 def autostart(reason, **kwargs):
32 if config.plugins.autotimer.autopoll.value and reason == 0:
33 # Initialize AutoTimer
34 autotimer = AutoTimer()
43 if autotimer is not None:
51 def main(session, **kwargs):
54 autotimer = AutoTimer()
58 except ExpatError, ee:
61 "Your config file is not well-formed.\nError parsing in line: %s" % (ee.lineno),
62 type = MessageBox.TYPE_ERROR,
67 # Don't crash during development
69 traceback.print_exc(file=sys.stdout)
72 "An unexpected error occured: %s" % (e),
73 type = MessageBox.TYPE_ERROR,
78 # Do not run in background while editing, this might screw things up
81 session.openWithCallback(
87 def editCallback(session):
90 # Start autopoller again if wanted
91 if config.plugins.autotimer.autopoll.value:
92 autopoller.start(initial = False)
94 # Don't do anything when editing was canceled
98 # We might re-parse Xml so catch parsing error
100 ret = autotimer.parseEPG()
103 "Found a total of %d matching Events.\n%d Timer were added and %d modified.." % (ret[0], ret[1], ret[2]),
104 type = MessageBox.TYPE_INFO,
108 # Don't crash during development
109 import traceback, sys
110 traceback.print_exc(file=sys.stdout)
113 "An unexpected error occured: %s" % (e),
114 type = MessageBox.TYPE_ERROR,
118 # Remove instance if not running in background
119 if not config.plugins.autotimer.autopoll.value:
124 def Plugins(**kwargs):
126 PluginDescriptor(where = PluginDescriptor.WHERE_AUTOSTART, fnc = autostart),
127 PluginDescriptor(name="AutoTimer", description = "Edit Timers and scan for new Events", where = PluginDescriptor.WHERE_PLUGINMENU, icon = "plugin.png", fnc = main),
128 PluginDescriptor(name="AutoTimer", description = "Edit Timers and scan for new Events", where = PluginDescriptor.WHERE_EXTENSIONSMENU, fnc = main)