also hand epgrefresh session if not explicitely enabled thus allowing to run it from...
authorMoritz Venn <ritzmo@users.schwerkraft.elitedvb.net>
Thu, 20 Aug 2009 20:15:44 +0000 (20:15 +0000)
committerMoritz Venn <ritzmo@users.schwerkraft.elitedvb.net>
Thu, 20 Aug 2009 20:15:44 +0000 (20:15 +0000)
epgrefresh/src/EPGRefresh.py
epgrefresh/src/EPGRefreshResource.py
epgrefresh/src/plugin.py

index 20ef3aa..349f81f 100644 (file)
@@ -114,11 +114,15 @@ class EPGRefresh:
 
        def forceRefresh(self, session = None):
                print "[EPGRefresh] Forcing start of EPGRefresh"
-               if session is not None:
-                       self.session = session
+               if self.session is None:
+                       if session is not None:
+                               self.session = session
+                       else:
+                               return False
 
                self.forcedScan = True
                self.prepareRefresh()
+               return True
 
        def start(self, session = None):
                if session is not None:
index 12a33cf..72d5d24 100644 (file)
@@ -9,10 +9,11 @@ class EPGRefreshResource(resource.Resource):
 
        def render(self, req):
                if req.args.has_key("refresh"):
-                       # XXX: we assume we already know the session
-                       epgrefresh.forceRefresh()
-                       output = "initiated refresh"
+                       if epgrefresh.forceRefresh():
+                               output = "initiated refresh"
+                       else:
+                               output = "could not initiate refresh"
                else:
                        output = "unknown command"
-               return http.Response(responsecode.OK ,stream = output)
+               return http.Response(responsecode.OKstream = output)
 
index 618602d..4998a40 100644 (file)
@@ -47,32 +47,33 @@ def standbyQuestionCallback(session, res = None):
 
 # Autostart
 def autostart(reason, **kwargs):
-       if config.plugins.epgrefresh.enabled.value and reason == 0 \
-               and kwargs.has_key("session"):
-
+       if reason == 0 and kwargs.has_key("session"):
                session = kwargs["session"]
-               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
+               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 recommmended to put the receiver to Standby.\nDo you want to do this now?"),
-                                       timeout = 15
-                               )
-
-               epgrefresh.start(session)
+                                       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 recommmended to put the receiver to Standby.\nDo you want to do this now?"),
+                                               timeout = 15
+                                       )
+
+                       epgrefresh.start(session)
 
        elif reason == 1:
                epgrefresh.stop()