Esempio n. 1
0
def autostart(reason, **kwargs):
	if reason == 0 and kwargs.has_key("session"):
		session = kwargs["session"]
		epgrefresh.session = session

		if config.plugins.epgrefresh.enabled.value:
			if config.plugins.epgrefresh.wakeup.value:
				now = localtime()
				begin = int(mktime(
					(now.tm_year, now.tm_mon, now.tm_mday,
					config.plugins.epgrefresh.begin.value[0],
					config.plugins.epgrefresh.begin.value[1],
					0, now.tm_wday, now.tm_yday, now.tm_isdst)
				))
				# booted +- 10min from begin of timespan
				if abs(time() - begin) < 600:
					from Screens.MessageBox import MessageBox
					from Tools.Notifications import AddNotificationWithCallback
					from Tools.BoundFunction import boundFunction
					# XXX: we use a notification because this will be suppressed otherwise
					AddNotificationWithCallback(
						boundFunction(standbyQuestionCallback, session),
						MessageBox,
						_("This might have been an automated bootup to refresh the EPG. For this to happen it is recommended to put the receiver to Standby.\nDo you want to do this now?"),
						timeout = 15
					)

			epgrefresh.start(session)

	elif reason == 1:
		epgrefresh.stop()
    def render(self, req):
        statetext = "config changed."
        for key, value in iteritems(req.args):
            value = value[0]
            if key == "enabled":
                config.plugins.epgrefresh.enabled.value = True if value == "true" else False
            elif key == "enablemessage":
                config.plugins.epgrefresh.enablemessage.value = True if value == "true" else False
            elif key == "begin":
                value = int(value)
                if value:
                    t = localtime(value)
                    config.plugins.epgrefresh.begin.value = [
                        t.tm_hour, t.tm_min
                    ]
            elif key == "end":
                value = int(value)
                if value:
                    t = localtime(int(value))
                    config.plugins.epgrefresh.end.value = [t.tm_hour, t.tm_min]
            elif key == "interval_seconds":
                value = int(value)
                if value:
                    config.plugins.epgrefresh.interval_seconds.value = value
            elif key == "delay_standby":
                value = int(value)
                if value:
                    config.plugins.epgrefresh.delay_standby.value = value
            elif key == "inherit_autotimer":
                config.plugins.epgrefresh.inherit_autotimer.value = True if value == "true" else False
            elif key == "afterevent":
                config.plugins.epgrefresh.afterevent.value = True if value == "true" else False
            elif key == "force":
                config.plugins.epgrefresh.force.value = True if value == "true" else False
            elif key == "wakeup":
                config.plugins.epgrefresh.wakeup.value = True if value == "true" else False
            elif key == "parse_autotimer":
                if value in epgrefresh.parse_autotimer.choices:
                    epgrefresh.parse_autotimer.value = value
            elif key == "adapter":
                if value in config.plugins.epgrefresh.adapter.choices:
                    config.plugins.epgrefresh.adapter.value = value

        config.plugins.epgrefresh.save()

        if config.plugins.epgrefresh.enabled.value:
            epgrefresh.start()
        else:
            epgrefresh.stop()

        req.setResponseCode(http.OK)
        req.setHeader('Content-type', 'application/xhtml+xml')
        req.setHeader('charset', 'UTF-8')

        return """<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
<e2simplexmlresult>
 <e2state>true</e2state>
 <e2statetext>%s</e2statetext>
</e2simplexmlresult>""" % (statetext, )
	def render(self, req):
		statetext = "config changed."
		for key, value in req.args.iteritems():
			value = value[0]
			if key == "enabled":
				config.plugins.epgrefresh.enabled.value = True if value == "true" else False
			elif key == "enablemessage":
				config.plugins.epgrefresh.enablemessage.value = True if value == "true" else False
			elif key == "begin":
				value = int(value)
				if value:
					t = localtime(value)
					config.plugins.epgrefresh.begin.value = [t.tm_hour, t.tm_min]
			elif key == "end":
				value = int(value)
				if value:
					t = localtime(int(value))
					config.plugins.epgrefresh.end.value = [t.tm_hour, t.tm_min]
			elif key == "interval":
				value = int(value)
				if value:
					config.plugins.epgrefresh.interval.value = value
			elif key == "delay_standby":
				value = int(value)
				if value:
					config.plugins.epgrefresh.delay_standby.value = value
			elif key == "inherit_autotimer":
				config.plugins.epgrefresh.inherit_autotimer.value = True if value == "true" else False
			elif key == "afterevent":
				config.plugins.epgrefresh.afterevent.value = True if value == "true" else False
			elif key == "force":
				config.plugins.epgrefresh.force.value = True if value == "true" else False
			elif key == "wakeup":
				config.plugins.epgrefresh.wakeup.value = True if value == "true" else False
			elif key == "parse_autotimer":
				config.plugins.epgrefresh.parse_autotimer.value = True if value == "true" else False
			elif key == "background":
				statetext += " parameter \"background\" is deprecated. please use new \"adapter\" parameter instead."
				config.plugins.epgrefresh.adapter.value = "pip_hidden" if value == "true" else "main"
			elif key == "adapter":
				if value in config.plugins.epgrefresh.adapter.choices:
					config.plugins.epgrefresh.adapter.value = value

		config.plugins.epgrefresh.save()

		if config.plugins.epgrefresh.enabled.value:
			epgrefresh.start()
		else:
			epgrefresh.stop()

		req.setResponseCode(http.OK)
		req.setHeader('Content-type', 'application; xhtml+xml')
		req.setHeader('charset', 'UTF-8')

		return """<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
<e2simplexmlresult>
 <e2state>true</e2state>
 <e2statetext>%s</e2statetext>
</e2simplexmlresult>""" % (statetext,)
    def keySave(self, doSaveConfiguration=True):
        if self.isConfigurationChanged():
            if not epgrefresh.isRefreshAllowed():
                return
            else:
                epgrefresh.stop()
                if doSaveConfiguration:
                    self._saveConfiguration()

        self.close(self.session, self.needsEnigmaRestart)
	def keySave(self, doSaveConfiguration = True):
		if self.isConfigurationChanged():
			if not epgrefresh.isRefreshAllowed():
				return
			else:
				epgrefresh.stop()
				if doSaveConfiguration:
					self._saveConfiguration()
		
		self.close(self.session, self.needsEnigmaRestart)
Esempio n. 6
0
def autostart(reason, **kwargs):
	if reason == 0 and "session" in kwargs:
		session = kwargs["session"]
		epgrefresh.session = session

		if config.plugins.epgrefresh.enabled.value:
			timeCallback(isCallback=False)

	elif reason == 1:
		epgrefresh.stop()
Esempio n. 7
0
def autostart(reason, **kwargs):
    if reason == 0 and "session" in kwargs:
        session = kwargs["session"]
        epgrefresh.session = session

        if config.plugins.epgrefresh.enabled.value:
            timeCallback(isCallback=False)

    elif reason == 1:
        epgrefresh.stop()
Esempio n. 8
0
def autostart(reason, session=None, **kwargs):
    global _session
    if reason == 0 and _session is None:
        if session is not None:
            epgrefresh.session = session
            _session = session
            if config.plugins.epgrefresh.enabled.value:
                timeCallback(isCallback=False)
            if config.plugins.epgrefresh_extra.autorestore_backup.value:
                restore_backup = config.misc.epgcache_filename.value + ".backup"
                if os.path.exists(restore_backup):
                    try:
                        os.system("cp -f %s %s" %
                                  (restore_backup,
                                   config.misc.epgcache_filename.value))
                        if os.path.exists(config.misc.epgcache_filename.value):
                            os.chmod(
                                "%s" % (config.misc.epgcache_filename.value),
                                0644)
                    except:
                        pass
            if os.path.exists(
                    "/usr/lib/enigma2/python/Plugins/Extensions/OpenWebif/pluginshook.src"
            ):
                try:
                    from EPGRefreshResource import \
                      EPGRefreshStartRefreshResource, \
                      EPGRefreshAddRemoveServiceResource, \
                      EPGRefreshListServicesResource, \
                      EPGRefreshChangeSettingsResource, \
                      EPGRefreshSettingsResource, \
                      EPGRefreshPreviewServicesResource, \
                      API_VERSION
                    root = EPGRefreshListServicesResource()
                    root.putChild("refresh", EPGRefreshStartRefreshResource())
                    root.putChild(
                        "add",
                        EPGRefreshAddRemoveServiceResource(
                            EPGRefreshAddRemoveServiceResource.TYPE_ADD))
                    root.putChild(
                        "del",
                        EPGRefreshAddRemoveServiceResource(
                            EPGRefreshAddRemoveServiceResource.TYPE_DEL))
                    root.putChild("set", EPGRefreshChangeSettingsResource())
                    root.putChild("get", EPGRefreshSettingsResource())
                    root.putChild("preview",
                                  EPGRefreshPreviewServicesResource())
                    from Plugins.Extensions.WebInterface.WebChilds.Toplevel import addExternalChild
                    addExternalChild(
                        ("epgrefresh", root, "EPGRefresh-Plugin", API_VERSION))
                    print("[EPGRefresh] Use OpenWebif")
                except:
                    print("[EPGRefresh] Error use OpenWebif")
    elif reason == 1:
        epgrefresh.stop()
	def keySave(self, doSaveConfiguration = True):
		if self.isConfigurationChanged():
			if not epgrefresh.isRefreshAllowed():
				return
			else:
				epgrefresh.stop()
				if doSaveConfiguration:
					self._saveConfiguration()

		if len(self.services[0]) == 0 and len(self.services[1]) == 0 and config.plugins.epgrefresh.enabled.value:
			self.session.openWithCallback(self.checkAnswer, MessageBox, _("EPGRefresh requires services/bouquets to be configured. Configure now?"), MessageBox.TYPE_YESNO, timeout=0)
		else:					
			self.close(self.session, self.needsEnigmaRestart)
Esempio n. 10
0
def autostart(reason, **kwargs):
	if reason == 0 and "session" in kwargs:
		session = kwargs["session"]
		epgrefresh.session = session

		if config.plugins.epgrefresh.enabled.value:
			# check if box was woken up by a timer, if so, check if epgrefresh set this timer
			if session.nav.wasTimerWakeup() and config.misc.prev_wakeup_time.value == config.plugins.epgrefresh.wakeup_time.value:
				# if box is not in idle mode, do that
				from Screens.Standby import Standby, inStandby
				if not inStandby:
					from Tools import Notifications
					Notifications.AddNotificationWithID("Standby", Standby)
			epgrefresh.start()

	elif reason == 1:
		epgrefresh.stop()
Esempio n. 11
0
def autostart(reason, session=None, **kwargs):
	global _session
	if reason == 0 and _session is None:
		if session is not None:
			epgrefresh.session = session
			_session = session
			if config.plugins.epgrefresh.enabled.value:
				timeCallback(isCallback=False)
			if config.plugins.epgrefresh_extra.autorestore_backup.value:
				restore_backup = config.misc.epgcache_filename.value + ".backup"
				if os.path.exists(restore_backup):
					try:
						os.system("cp -f %s %s" % (restore_backup, config.misc.epgcache_filename.value ))
						if os.path.exists(config.misc.epgcache_filename.value): 
							os.chmod("%s" % (config.misc.epgcache_filename.value), 0644)
					except:
						pass
			if os.path.exists("/usr/lib/enigma2/python/Plugins/Extensions/OpenWebif/pluginshook.src"):
				try:
					from EPGRefreshResource import \
							EPGRefreshStartRefreshResource, \
							EPGRefreshAddRemoveServiceResource, \
							EPGRefreshListServicesResource, \
							EPGRefreshChangeSettingsResource, \
							EPGRefreshSettingsResource, \
							EPGRefreshPreviewServicesResource, \
							API_VERSION
					root = EPGRefreshListServicesResource()
					root.putChild("refresh", EPGRefreshStartRefreshResource())
					root.putChild("add", EPGRefreshAddRemoveServiceResource(EPGRefreshAddRemoveServiceResource.TYPE_ADD))
					root.putChild("del", EPGRefreshAddRemoveServiceResource(EPGRefreshAddRemoveServiceResource.TYPE_DEL))
					root.putChild("set", EPGRefreshChangeSettingsResource())
					root.putChild("get", EPGRefreshSettingsResource())
					root.putChild("preview", EPGRefreshPreviewServicesResource())
					from Plugins.Extensions.WebInterface.WebChilds.Toplevel import addExternalChild
					addExternalChild( ("epgrefresh", root, "EPGRefresh-Plugin", API_VERSION) )
					print("[EPGRefresh] Use OpenWebif")
				except:
					print("[EPGRefresh] Error use OpenWebif")
	elif reason == 1:
		epgrefresh.stop()
	def render(self, req):
		for key, value in req.args.iteritems():
			value = value[0]
			if key == "enabled":
				config.plugins.epgrefresh.enabled.value = True if value == "true" else False
			elif key == "begin":
				config.plugins.epgrefresh.begin.value = int(value)
			elif key == "end":
				config.plugins.epgrefresh.end.value = int(value)
			elif key == "interval":
				config.plugins.epgrefresh.interval.value = int(value)
			elif key == "delay_standby":
				config.plugins.epgrefresh.delay_standby.value = int(value)
			elif key == "inherit_autotimer":
				config.plugins.epgrefresh.inherit_autotimer.value = True if value == "true" else False
			elif key == "afterevent":
				config.plugins.epgrefresh.afterevent.value = True if value == "true" else False
			elif key == "force":
				config.plugins.epgrefresh.force.value = True if value == "true" else False
			elif key == "wakeup":
				config.plugins.epgrefresh.wakeup.value = True if value == "true" else False
			elif key == "pase_autotimer":
				config.plugins.epgrefresh.parse_autotimer.value = True if value == "true" else False
			elif key == "background":
				config.plugins.epgrefresh.background.value = True if value == "true" else False

		config.plugins.epgrefresh.save()

		if config.plugins.epgrefresh.enabled.value:
			epgrefresh.start()
		else:
			epgrefresh.stop()

		req.setResponseCode(http.OK)
		req.setHeader('Content-type', 'application; xhtml+xml')
		req.setHeader('charset', 'UTF-8')

		return """<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
Esempio n. 13
0
    def render(self, req):
        for key, value in req.args.iteritems():
            value = value[0]
            if key == "enabled":
                config.plugins.epgrefresh.enabled.value = True if value == "true" else False
            elif key == "begin":
                config.plugins.epgrefresh.begin.value = int(value)
            elif key == "end":
                config.plugins.epgrefresh.end.value = int(value)
            elif key == "interval":
                config.plugins.epgrefresh.interval.value = int(value)
            elif key == "delay_standby":
                config.plugins.epgrefresh.delay_standby.value = int(value)
            elif key == "inherit_autotimer":
                config.plugins.epgrefresh.inherit_autotimer.value = True if value == "true" else False
            elif key == "afterevent":
                config.plugins.epgrefresh.afterevent.value = True if value == "true" else False
            elif key == "force":
                config.plugins.epgrefresh.force.value = True if value == "true" else False
            elif key == "wakeup":
                config.plugins.epgrefresh.wakeup.value = True if value == "true" else False
            elif key == "pase_autotimer":
                config.plugins.epgrefresh.parse_autotimer.value = True if value == "true" else False

        config.plugins.epgrefresh.save()

        if config.plugins.epgrefresh.enabled.value:
            epgrefresh.start()
        else:
            epgrefresh.stop()

        req.setResponseCode(http.OK)
        req.setHeader('Content-type', 'application; xhtml+xml')
        req.setHeader('charset', 'UTF-8')

        return """<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
Esempio n. 14
0
def main(session, **kwargs):
	epgrefresh.stop()
	session.openWithCallback(
		doneConfiguring,
		EPGRefreshConfiguration
	)
	def render(self, req):
		statetext = "config changed."
		for key, value in iteritems(req.args):
			value = value[0]
			if key == "enabled":
				config.plugins.epgrefresh.enabled.value = True if value == "true" else False
			elif key == "enablemessage":
				config.plugins.epgrefresh.enablemessage.value = True if value == "true" else False
			elif key == "begin":
				value = int(value)
				if value:
					t = localtime(value)
					config.plugins.epgrefresh.begin.value = [t.tm_hour, t.tm_min]
			elif key == "end":
				value = int(value)
				if value:
					t = localtime(int(value))
					config.plugins.epgrefresh.end.value = [t.tm_hour, t.tm_min]
			elif key == "interval_seconds":
				value = int(value)
				if value:
					config.plugins.epgrefresh.interval_seconds.value = value
			elif key == "delay_standby":
				value = int(value)
				if value:
					config.plugins.epgrefresh.delay_standby.value = value
			elif key == "inherit_autotimer":
				config.plugins.epgrefresh.inherit_autotimer.value = True if value == "true" else False
			elif key == "afterevent":
				config.plugins.epgrefresh.afterevent.value = True if value == "true" else False
			elif key == "force":
				config.plugins.epgrefresh.force.value = True if value == "true" else False
			elif key == "wakeup":
				config.plugins.epgrefresh.wakeup.value = True if value == "true" else False
			elif key == "parse_autotimer":
				if value in config.plugins.epgrefresh.parse_autotimer.choices:
					config.plugins.epgrefresh.parse_autotimer.value = value
				elif value == "true":
					config.plugins.epgrefresh.parse_autotimer.value = "always"
				else:
					config.plugins.epgrefresh.parse_autotimer.value = "never"
			elif key == "adapter":
				if value in config.plugins.epgrefresh.adapter.choices:
					config.plugins.epgrefresh.adapter.value = value
			elif key == "skipProtectedServices":
				if value in config.plugins.epgrefresh.skipProtectedServices.choices:
					config.plugins.epgrefresh.skipProtectedServices.value = value

		config.plugins.epgrefresh.save()

		if config.plugins.epgrefresh.enabled.value:
			epgrefresh.start()
		else:
			epgrefresh.stop()

		req.setResponseCode(http.OK)
		req.setHeader('Content-type', 'application/xhtml+xml')
		req.setHeader('charset', 'UTF-8')

		return """<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
<e2simplexmlresult>
 <e2state>true</e2state>
 <e2statetext>%s</e2statetext>
</e2simplexmlresult>""" % (statetext,)