2 from Screens.MessageBox import MessageBox
5 from Components.config import config, ConfigSubsection, ConfigEnableDisable, \
6 ConfigNumber, ConfigSelection
8 # Initialize Configuration
9 config.plugins.autotimer = ConfigSubsection()
10 config.plugins.autotimer.autopoll = ConfigEnableDisable(default = False)
11 config.plugins.autotimer.interval = ConfigNumber(default = 3)
12 config.plugins.autotimer.refresh = ConfigSelection(choices = [
14 ("auto", _("Only AutoTimers created during this Session")),
15 ("all", _("All non-repeating Timers"))
18 config.plugins.autotimer.try_guessing = ConfigEnableDisable(default = True)
24 def autostart(reason, **kwargs):
29 if config.plugins.autotimer.autopoll.value and reason == 0:
30 # Initialize AutoTimer
31 from AutoTimer import AutoTimer
32 autotimer = AutoTimer()
35 from AutoPoller import AutoPoller
36 autopoller = AutoPoller()
41 if autopoller is not None:
42 # We might shutdown when configuring, timer won't be runnign then
45 except ValueError, ve:
50 if autotimer is not None:
58 def main(session, **kwargs):
63 from AutoTimer import AutoTimer
64 autotimer = AutoTimer()
66 from xml.parsers.expat import ExpatError
70 except ExpatError, ee:
73 "Your config file is not well-formed.\nError parsing in line: %s" % (ee.lineno),
74 type = MessageBox.TYPE_ERROR,
79 # Don't crash during development
81 traceback.print_exc(file=sys.stdout)
84 "An unexpected error occured: %s" % (e),
85 type = MessageBox.TYPE_ERROR,
90 # Do not run in background while editing, this might screw things up
91 if autopoller is not None:
94 from AutoTimerOverview import AutoTimerOverview
95 session.openWithCallback(
101 def editCallback(session):
105 # Start autopoller again if wanted
106 if config.plugins.autotimer.autopoll.value:
107 if autopoller is None:
108 from AutoPoller import AutoPoller
109 autopoller = AutoPoller()
110 autopoller.start(initial = False)
112 # Don't do anything when editing was canceled
116 # We might re-parse Xml so catch parsing error
118 ret = autotimer.parseEPG()
121 "Found a total of %d matching Events.\n%d Timer were added and %d modified.." % (ret[0], ret[1], ret[2]),
122 type = MessageBox.TYPE_INFO,
126 # Don't crash during development
127 import traceback, sys
128 traceback.print_exc(file=sys.stdout)
131 "An unexpected error occured: %s" % (e),
132 type = MessageBox.TYPE_ERROR,
136 # Remove instance if not running in background
137 if not config.plugins.autotimer.autopoll.value:
144 def Plugins(**kwargs):
145 from Plugins.Plugin import PluginDescriptor
148 PluginDescriptor(where = PluginDescriptor.WHERE_AUTOSTART, fnc = autostart),
149 PluginDescriptor(name="AutoTimer", description = "Edit Timers and scan for new Events", where = PluginDescriptor.WHERE_PLUGINMENU, icon = "plugin.png", fnc = main),
150 PluginDescriptor(name="AutoTimer", description = "Edit Timers and scan for new Events", where = PluginDescriptor.WHERE_EXTENSIONSMENU, fnc = main)