autotimer: (untested) support for notification on conflicts
authorMoritz Venn <moritz.venn@freaque.net>
Mon, 31 Jan 2011 19:00:00 +0000 (20:00 +0100)
committerMoritz Venn <moritz.venn@freaque.net>
Mon, 31 Jan 2011 19:00:00 +0000 (20:00 +0100)
autotimer/src/AutoPoller.py
autotimer/src/AutoTimer.py
autotimer/src/AutoTimerSettings.py
autotimer/src/plugin.py

index bdfc38f..127b55b 100644 (file)
@@ -4,6 +4,11 @@ from enigma import eTimer
 # Config
 from Components.config import config
 
+# Notifications
+from Tools.FuzzyDate import FuzzyTime
+from Tools.Notifications import AddPopup
+NOTIFICATIONID = 'AutoTimerConflictEncounteredNotification'
+
 class AutoPoller:
        """Automatically Poll AutoTimer"""
 
@@ -31,11 +36,20 @@ class AutoPoller:
 
                # Ignore any program errors
                try:
-                       autotimer.parseEPG()
+                       ret = autotimer.parseEPG()
                except Exception:
                        # Dump error to stdout
                        import traceback, sys
                        traceback.print_exc(file=sys.stdout)
+               else:
+                       conflicts = ret[4]
+                       if conflicts and config.plugins.autotimer.notifconflict.value:
+                               AddPopup(
+                                       _("%d conflict(s) encountered when trying to add new timers:\n%s") % (len(conflicts), '\n'.join([_("%s: %s at %s") % (x[4], x[0], FuzzyTime(x[2])) for x in conflicts])),
+                                       MessageBox.TYPE_INFO,
+                                       5,
+                                       NOTIFICATIONID
+                               )
 
                self.timer.startLongTimer(config.plugins.autotimer.interval.value*3600)
 
index 5df54e4..f80ee22 100644 (file)
@@ -154,12 +154,13 @@ class AutoTimer:
        def parseEPG(self, simulateOnly = False):
                if NavigationInstance.instance is None:
                        print "[AutoTimer] Navigation is not available, can't parse EPG"
-                       return (0, 0, 0, [])
+                       return (0, 0, 0, [], [])
 
                total = 0
                new = 0
                modified = 0
                timers = []
+               conflicting = []
 
                self.readXml()
 
@@ -330,10 +331,13 @@ class AutoTimer:
                                                newEntry.disabled = True
                                                # We might want to do the sanity check locally so we don't run it twice - but I consider this workaround a hack anyway
                                                conflicts = NavigationInstance.instance.RecordTimer.record(newEntry)
+                                               conflicting.append((name, begin, end, serviceref, timer.name))
                                        if conflicts is None:
                                                timer.decrementCounter()
                                                new += 1
                                                recorddict.setdefault(serviceref, []).append(newEntry)
+                                       else:
+                                               conflicting.append((name, begin, end, serviceref, timer.name))
 
-               return (total, new, modified, timers)
+               return (total, new, modified, timers, conflicting)
 
index eb2781f..8a29714 100644 (file)
@@ -42,6 +42,7 @@ class AutoTimerSettings(Screen, ConfigListScreen):
                                getConfigListEntry(_("Modify existing timers"), config.plugins.autotimer.refresh, _("This setting controls the behavior when a timer matches a found event.")),
                                getConfigListEntry(_("Guess existing timer based on begin/end"), config.plugins.autotimer.try_guessing, _("If this is enabled an existing timer will also be considered recording an event if it records at least 80% of the it.")),
                                getConfigListEntry(_("Add timer as disabled on conflict"), config.plugins.autotimer.disabled_on_conflict, _("This toggles the behavior on timer conflicts. If an AutoTimer matches an event that conflicts with an existing timer it will not ignore this event but add it disabled.")),
+                               getConfigListEntry(_("Show notification on conflicts"), config.plugins.autotimer.notifconflict, _("By enabling this you will be notified about timer conflicts found during automated polling. There is no intelligence involved, so it might bother you about the same conflict over and over.")),
                                getConfigListEntry(_("Editor for new AutoTimers"), config.plugins.autotimer.editor, _("The editor to be used for new AutoTimers. This can either be the Wizard or the classic editor.")),
                                getConfigListEntry(_("Support \"Fast Scan\"?"), config.plugins.autotimer.fastscan, _("When supporting \"Fast Scan\" the service type is ignored. You don't need to enable this unless your Image supports \"Fast Scan\" and you are using it.")),
                        ],
index f6a0cf1..4b84430 100644 (file)
@@ -31,6 +31,7 @@ config.plugins.autotimer.editor = ConfigSelection(choices = [
 config.plugins.autotimer.disabled_on_conflict = ConfigEnableDisable(default = False)
 config.plugins.autotimer.show_in_extensionsmenu = ConfigYesNo(default = False)
 config.plugins.autotimer.fastscan = ConfigYesNo(default = False)
+config.plugins.autotimer.notifconflict = ConfigYesNo(default = True)
 
 autotimer = None
 autopoller = None
@@ -114,7 +115,7 @@ def editCallback(session):
                ret = autotimer.parseEPG()
                session.open(
                        MessageBox,
-                       _("Found a total of %d matching Events.\n%d Timer were added and %d modified.") % (ret[0], ret[1], ret[2]),
+                       _("Found a total of %d matching Events.\n%d Timer were added and %d modified, %d conflicts encountered.") % (ret[0], ret[1], ret[2], len(ret[4])),
                        type = MessageBox.TYPE_INFO,
                        timeout = 10
                )