def main(session, **kwargs): global autotimer global autopoller if autotimer is None: from AutoTimer import AutoTimer autotimer = AutoTimer() try: autotimer.readXml() except SyntaxError as se: session.open( MessageBox, _("Your config file is not well-formed:\n%s") % (str(se)), type = MessageBox.TYPE_ERROR, timeout = 10 ) return from Plugins.SystemPlugins.Toolkit import NotifiablePluginBrowser NotifiablePluginBrowser.install() # Do not run in background while editing, this might screw things up if autopoller is not None: autopoller.stop() from AutoTimerOverview import AutoTimerOverview session.openWithCallback( editCallback, AutoTimerOverview, autotimer )
def autostart(reason, **kwargs): global autotimer global autopoller # Startup if reason == 0 and config.plugins.autotimer.autopoll.value: # Initialize AutoTimer from AutoTimer import AutoTimer autotimer = AutoTimer() # Start Poller from AutoPoller import AutoPoller autopoller = AutoPoller() autopoller.start() # Shutdown elif reason == 1: # Stop Poller if autopoller is not None: autopoller.stop() autopoller = None if autotimer is not None: # We re-read the config so we won't save wrong information try: autotimer.readXml() except Exception: # XXX: we should at least dump the error pass # Save xml autotimer.writeXml() # Remove AutoTimer autotimer = None
def main(session, **kwargs): global autotimer global autopoller if autotimer is None: from AutoTimer import AutoTimer autotimer = AutoTimer() try: autotimer.readXml() except SyntaxError as se: session.open(MessageBox, _("Your config file is not well-formed:\n%s") % (str(se)), type=MessageBox.TYPE_ERROR, timeout=10) return from Plugins.SystemPlugins.Toolkit import NotifiablePluginBrowser NotifiablePluginBrowser.install() # Do not run in background while editing, this might screw things up if autopoller is not None: autopoller.stop() from AutoTimerOverview import AutoTimerOverview session.openWithCallback(editCallback, AutoTimerOverview, autotimer)
def getAutoTimerInstance(self): if plugin.autotimer is None: self._remove = True autotimer = AutoTimer() try: autotimer.readXml() except Exception: # TODO: proper error handling pass return autotimer self._remove = False return plugin.autotimer
def getAutoTimerInstance(self): from plugin import autotimer if autotimer is None: self._remove = True return AutoTimer() self._remove = False return autotimer
def addAutotimerFromSearchString(session, match): from AutoTimerComponent import preferredAutoTimerComponent from AutoTimerImporter import AutoTimerImporter from plugin import autotimer # Create instance if needed if autotimer is None: from AutoTimer import AutoTimer autotimer = AutoTimer() autotimer.readXml() session.openWithCallback( importerCallback, AutoTimerImporter, preferredAutoTimerComponent( autotimer.getUniqueId(), match, '', # Match True # Enabled ), match, # Proposed Match None, # Proposed Begin None, # Proposed End None, # Proposed Disabled None, # Proposed ServiceReference None, # Proposed afterEvent None, # Proposed justplay None, # Proposed dirname, can we get anything useful here? [] # Proposed tags )
def main(session, **kwargs): global autotimer global autopoller if autotimer is None: from AutoTimer import AutoTimer autotimer = AutoTimer() try: autotimer.readXml() except SyntaxError, se: session.open( MessageBox, _("Your config file is not well-formed:\n%s") % (str(se)), type = MessageBox.TYPE_ERROR, timeout = 10 ) return
def addAutotimerFromEvent(session, evt = None, service = None): from AutoTimerComponent import preferredAutoTimerComponent from AutoTimerImporter import AutoTimerImporter from plugin import autotimer # Create instance if needed if autotimer is None: from AutoTimer import AutoTimer autotimer = AutoTimer() autotimer.readXml() match = evt and evt.getEventName() or "" name = match or "New AutoTimer" sref = None if service is not None: service = str(service) myref = eServiceReference(service) if not (myref.flags & eServiceReference.isGroup): # strip all after last : pos = service.rfind(':') if pos != -1: if service[pos-1] == ':': pos -= 1 service = service[:pos+1] sref = ServiceReference(myref) if evt: # timespan defaults to +- 1h begin = evt.getBeginTime()-3600 end = begin + evt.getDuration()+7200 else: begin = end = 0 # XXX: we might want to make sure that we actually collected any data because the importer does not do so :-) newTimer = autotimer.defaultTimer.clone() newTimer.id = autotimer.getUniqueId() newTimer.name = name newTimer.match = '' newTimer.enabled = True session.openWithCallback( importerCallback, AutoTimerImporter, newTimer, match, # Proposed Match begin, # Proposed Begin end, # Proposed End None, # Proposed Disabled sref, # Proposed ServiceReference None, # Proposed afterEvent None, # Proposed justplay None, # Proposed dirname, can we get anything useful here? [] # Proposed tags )
def autostart(reason, **kwargs): global autotimer global autopoller # Startup if config.plugins.autotimer.autopoll.value and reason == 0: # Initialize AutoTimer from AutoTimer import AutoTimer autotimer = AutoTimer() # Start Poller from AutoPoller import AutoPoller autopoller = AutoPoller() autopoller.start() # Shutdown elif reason == 1: # Stop Poller if autopoller is not None: autopoller.stop() autopoller = None if autotimer is not None: # We re-read the config so we won't save wrong information try: autotimer.readXml() except Exception: # XXX: we should at least dump the error pass # Save xml autotimer.writeXml() # Remove AutoTimer autotimer = None
def editorCallback(ret): if ret: from plugin import autotimer if autotimer is None: from AutoTimer import AutoTimer autotimer = AutoTimer() autotimer.readXml() autotimer.add(ret) # Save modified xml autotimer.writeXml()
def render(self, req): for key, value in iteritems(req.args): value = value[0] if key == "autopoll": config.plugins.autotimer.autopoll.value = True if value == "true" else False elif key == "interval": config.plugins.autotimer.interval.value = int(value) elif key == "refresh": config.plugins.autotimer.refresh.value = value elif key == "try_guessing": config.plugins.autotimer.try_guessing.value = True if value == "true" else False elif key == "editor": config.plugins.autotimer.editor.value = value elif key == "disabled_on_conflict": config.plugins.autotimer.disabled_on_conflict.value = True if value == "true" else False elif key == "addsimilar_on_conflict": config.plugins.autotimer.addsimilar_on_conflict.value = True if value == "true" else False elif key == "show_in_extensionsmenu": config.plugins.autotimer.show_in_extensionsmenu.value = True if value == "true" else False elif key == "fastscan": config.plugins.autotimer.fastscan.value = True if value == "true" else False elif key == "notifconflict": config.plugins.autotimer.notifconflict.value = True if value == "true" else False elif key == "notifsimilar": config.plugins.autotimer.notifsimilar.value = True if value == "true" else False elif key == "maxdaysinfuture": config.plugins.autotimer.maxdaysinfuture.value = int(value) elif key == "add_autotimer_to_tags": config.plugins.autotimer.add_autotimer_to_tags.value = True if value == "true" else False elif key == "add_name_to_tags": config.plugins.autotimer.add_name_to_tags.value = True if value == "true" else False if config.plugins.autotimer.autopoll.value: if plugin.autopoller is None: from AutoPoller import AutoPoller plugin.autopoller = AutoPoller() if plugin.autotimer is None: plugin.autotimer = AutoTimer() plugin.autopoller.start(initial = False) else: if plugin.autopoller is not None: plugin.autopoller.stop() plugin.autopoller = None if plugin.autotimer is not None: try: plugin.autotimer.readXml() except Exception: pass else: plugin.autotimer.writeXml() plugin.autotimer = None return self.returnResult(req, True, _("config changed."))
def editorCallback(ret): if ret: from plugin import autotimer # Create instance if needed (should have been created by addAutotimerFrom* above though) if autotimer is None: from AutoTimer import AutoTimer autotimer = AutoTimer() autotimer.readXml() autotimer.add(ret) # Save modified xml autotimer.writeXml() # Remove instance if not running in background if not config.plugins.autotimer.autopoll.value: autotimer = None
# GUI (Screens) from Screens.MessageBox import MessageBox from Tools.Notifications import AddPopup # Plugin from Components.PluginComponent import plugins from Plugins.Plugin import PluginDescriptor from Components.config import config from os import path as os_path from Logger import doLog from AutoTimer import AutoTimer autotimer = AutoTimer() autopoller = None AUTOTIMER_VERSION = "4.3" NOTIFICATIONDOMAIN = "AutoTimer" #pragma mark - Help try: from Plugins.SystemPlugins.MPHelp import registerHelp, XMLHelpReader from Tools.Directories import resolveFilename, SCOPE_PLUGINS reader = XMLHelpReader(resolveFilename(SCOPE_PLUGINS, "Extensions/AutoTimer/mphelp.xml"), translate=_) autotimerHelp = registerHelp(*reader) except Exception as e: doLog("[AutoTimer] Unable to initialize MPHelp:", e,
def addAutotimerFromService(session, service = None): from AutoTimerComponent import preferredAutoTimerComponent from AutoTimerImporter import AutoTimerImporter from plugin import autotimer # Create instance if needed if autotimer is None: from AutoTimer import AutoTimer autotimer = AutoTimer() autotimer.readXml() serviceHandler = eServiceCenter.getInstance() info = serviceHandler.info(service) match = info and info.getName(service) or "" name = match or "New AutoTimer" sref = info and info.getInfoString(service, iServiceInformation.sServiceref) if sref: # strip all after last : pos = sref.rfind(':') if pos != -1: if sref[pos-1] == ':': pos -= 1 sref = sref[:pos+1] sref = ServiceReference(sref) if info: begin = info.getInfo(service, iServiceInformation.sTimeCreate) end = begin + info.getLength(service) else: begin = end = 0 from os.path import dirname path = dirname(service.getPath()) if not path == '/': path += '/' tags = info.getInfoString(service, iServiceInformation.sTags) tags = tags and tags.split(' ') or [] # XXX: we might want to make sure that we actually collected any data because the importer does not do so :-) session.openWithCallback( importerCallback, AutoTimerImporter, preferredAutoTimerComponent( autotimer.getUniqueId(), name, '', # Match True # Enabled ), match, # Proposed Match begin, # Proposed Begin end, # Proposed End None, # Proposed Disabled sref, # Proposed ServiceReference None, # Proposed afterEvent None, # Proposed justplay path, # Proposed dirname tags # Proposed tags )