AutomaticTimerlistCleanup plugin - initial checkin
authorDr.Best <dr_best@users.schwerkraft.elitedvb.net>
Wed, 14 Apr 2010 18:17:16 +0000 (18:17 +0000)
committerDr.Best <dr_best@users.schwerkraft.elitedvb.net>
Wed, 14 Apr 2010 18:17:16 +0000 (18:17 +0000)
14 files changed:
Makefile.am
automatictimerlistcleanup/CONTROL/control [new file with mode: 0644]
automatictimerlistcleanup/Makefile.am [new file with mode: 0755]
automatictimerlistcleanup/meta/Makefile.am [new file with mode: 0755]
automatictimerlistcleanup/meta/automatictimerlistcleanup.jpg [new file with mode: 0644]
automatictimerlistcleanup/meta/plugin_automatictimerlistcleanup.xml [new file with mode: 0755]
automatictimerlistcleanup/po/AutomaticTimerlistCleanup.pot [new file with mode: 0644]
automatictimerlistcleanup/po/Makefile.am [new file with mode: 0644]
automatictimerlistcleanup/po/de.po [new file with mode: 0644]
automatictimerlistcleanup/src/Makefile.am [new file with mode: 0755]
automatictimerlistcleanup/src/__init__.py [new file with mode: 0644]
automatictimerlistcleanup/src/maintainer.info [new file with mode: 0644]
automatictimerlistcleanup/src/plugin.py [new file with mode: 0644]
configure.ac

index fff9493..0a2f156 100644 (file)
@@ -2,6 +2,7 @@ AUTOMAKE_OPTIONS = gnu
 SUBDIRS = \
        ac3lipsync \
        antiscrollbar \
+       automatictimerlistcleanup \
        autoresolution \
        autotimer \
        cdinfo \
diff --git a/automatictimerlistcleanup/CONTROL/control b/automatictimerlistcleanup/CONTROL/control
new file mode 100644 (file)
index 0000000..bf16dee
--- /dev/null
@@ -0,0 +1,10 @@
+Package: enigma2-plugin-systemplugins-automatictimerlistcleanup
+Version: 1.0
+Description: Automatic Timerlist Cleanup Plugin
+Architecture: mipsel
+Section: extra
+Priority: optional
+Maintainer: Dr. Best <dr.best@dreambox-tools.info>
+Homepage: http://www.dreambox-tools.info
+Depends: enigma2
+Source: http://enigma2-plugins.schwerkraft.elitedvb.net/
diff --git a/automatictimerlistcleanup/Makefile.am b/automatictimerlistcleanup/Makefile.am
new file mode 100755 (executable)
index 0000000..1442b1d
--- /dev/null
@@ -0,0 +1 @@
+SUBDIRS = src meta po
diff --git a/automatictimerlistcleanup/meta/Makefile.am b/automatictimerlistcleanup/meta/Makefile.am
new file mode 100755 (executable)
index 0000000..4f6dc1a
--- /dev/null
@@ -0,0 +1,5 @@
+installdir = $(datadir)/meta/
+
+dist_install_DATA = plugin_automatictimerlistcleanup.xml
+
+EXTRA_DIST = virtualzap.jpg
diff --git a/automatictimerlistcleanup/meta/automatictimerlistcleanup.jpg b/automatictimerlistcleanup/meta/automatictimerlistcleanup.jpg
new file mode 100644 (file)
index 0000000..4d80193
Binary files /dev/null and b/automatictimerlistcleanup/meta/automatictimerlistcleanup.jpg differ
diff --git a/automatictimerlistcleanup/meta/plugin_automatictimerlistcleanup.xml b/automatictimerlistcleanup/meta/plugin_automatictimerlistcleanup.xml
new file mode 100755 (executable)
index 0000000..425d925
--- /dev/null
@@ -0,0 +1,24 @@
+<default>
+         <prerequisites>
+                    <tag type="Multimedia" />
+         </prerequisites>
+          <info language="en">
+                    <author>Dr.Best</author>
+                    <name>Automatic Timerlist Cleanup</name>
+                    <packagename>enigma2-plugin-systemplugins-automatictimerlistcleanup</packagename>
+                    <shortdescription>cleanup timerlist automatically</shortdescription>
+                    <description>cleanup timerlist automatically</description>
+                    <screenshot src="http://www.dreamboxupdate.com/preview/automatictimerlistcleanup.jpg" />               
+          </info>
+          <info language="de">
+                    <author>Dr.Best</author>
+                    <name>Automatic Timerlist Cleanup</name>
+                    <packagename>enigma2-plugin-systemplugins-automatictimerlistcleanup</packagename>
+                   <shortdescription>Timerliste automatisch aufräumen lassen</shortdescription>
+                    <description>Timerliste automatisch aufräumen lassen</description>
+                    <screenshot src="http://www.dreamboxupdate.com/preview/automatictimerlistcleanup.jpg" />            
+          </info>
+         <files type="package"> <!-- without version, without .ipk -->
+               <file type="package" name="enigma2-plugin-systemplugins-automatictimerlistcleanup" />
+         </files>
+</default>
diff --git a/automatictimerlistcleanup/po/AutomaticTimerlistCleanup.pot b/automatictimerlistcleanup/po/AutomaticTimerlistCleanup.pot
new file mode 100644 (file)
index 0000000..056f4c4
--- /dev/null
@@ -0,0 +1,57 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: \n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-04-14 19:59+0100\n"
+"PO-Revision-Date: \n"
+"Last-Translator: Dr. Best <dr.best@dreambox-tools.info>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Poedit-KeywordsList: _(\n"
+"X-Poedit-Basepath: .\n"
+"X-Poedit-SearchPath-0: ../src\n"
+
+#: ../src/plugin.py:36
+msgid "disabled"
+msgstr ""
+
+#: ../src/plugin.py:36
+msgid "immediately after recording"
+msgstr ""
+
+#: ../src/plugin.py:36
+msgid "older than 1 day"
+msgstr ""
+
+#: ../src/plugin.py:36
+msgid "older than 3 days"
+msgstr ""
+
+#: ../src/plugin.py:36
+msgid "older than 1 week"
+msgstr ""
+
+#: ../src/plugin.py:36
+msgid "older than 2 weeks"
+msgstr ""
+
+#: ../src/plugin.py:49
+#: ../src/plugin.py:122
+#: ../src/plugin.py:125
+msgid "Automatic Timerlist Cleanup Setup"
+msgstr ""
+
+#: ../src/plugin.py:53
+msgid "Cancel"
+msgstr ""
+
+#: ../src/plugin.py:54
+msgid "OK"
+msgstr ""
+
+#: ../src/plugin.py:56
+msgid "Cleanup timerlist-entries"
+msgstr ""
+
diff --git a/automatictimerlistcleanup/po/Makefile.am b/automatictimerlistcleanup/po/Makefile.am
new file mode 100644 (file)
index 0000000..41b704a
--- /dev/null
@@ -0,0 +1,57 @@
+#
+# to use this for the localisation of other plugins,
+# just change the DOMAIN to the name of the Plugin.
+# It is assumed, that the domain ist the same as
+# the directory name of the plugin.
+#
+
+DOMAIN=AutomaticTimerlistCleanup
+installdir = /usr/lib/enigma2/python/Plugins/SystemPlugins/$(DOMAIN)
+#GETTEXT=./pygettext.py
+GETTEXT=xgettext
+
+#MSGFMT = ./msgfmt.py
+MSGFMT = msgfmt
+
+LANGS := de
+LANGPO := $(foreach LANG, $(LANGS),$(LANG).po)
+LANGMO := $(foreach LANG, $(LANGS),$(LANG).mo)
+
+default: $(DOMAIN).pot $(LANGPO) merge $(LANGMO)
+       for lang in $(LANGS); do \
+               mkdir -p $$lang/LC_MESSAGES; \
+               cp $$lang.mo $$lang/LC_MESSAGES/$(DOMAIN).mo; \
+       done
+
+merge:
+       for lang in $(LANGS); do \
+               msgmerge --no-location -s -N -U $$lang.po $(DOMAIN).pot; \
+       done
+
+
+# the TRANSLATORS: allows putting translation comments before the to-be-translated line.
+$(DOMAIN).pot:
+       $(GETTEXT) -L python --add-comments="TRANSLATORS:" -d $(DOMAIN) -s -o $(DOMAIN).pot ../src/*.py
+       msguniq -o $(DOMAIN)uniq.pot $(DOMAIN).pot
+       $(RM) $(DOMAIN).pot
+       mv $(DOMAIN)uniq.pot $(DOMAIN).pot
+
+.PHONY: $(DOMAIN).pot
+
+
+%.mo: %.po
+       $(MSGFMT) -o $@ $<
+
+%.po:
+       msginit -l $@ -o $@ -i $(DOMAIN).pot --no-translator
+
+CLEANFILES = $(foreach LANG, $(LANGS),$(LANG).mo)
+
+clean-local:
+       $(RM) -r $(LANGS)
+
+install-data-am: default
+       for lang in $(LANGS); do \
+               mkdir -p $(DESTDIR)$(installdir)/locale/$$lang/LC_MESSAGES; \
+               cp $$lang.mo $(DESTDIR)$(installdir)/locale/$$lang/LC_MESSAGES/$(DOMAIN).mo; \
+       done
diff --git a/automatictimerlistcleanup/po/de.po b/automatictimerlistcleanup/po/de.po
new file mode 100644 (file)
index 0000000..ac28a1a
--- /dev/null
@@ -0,0 +1,57 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: \n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-04-14 19:59+0100\n"
+"PO-Revision-Date: \n"
+"Last-Translator: Dr. Best <dr.best@dreambox-tools.info>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Poedit-KeywordsList: _(\n"
+"X-Poedit-Basepath: .\n"
+"X-Poedit-SearchPath-0: ../src\n"
+
+#: ../src/plugin.py:36
+msgid "disabled"
+msgstr "abgeschaltet"
+
+#: ../src/plugin.py:36
+msgid "immediately after recording"
+msgstr "direkt nach Aufnahme"
+
+#: ../src/plugin.py:36
+msgid "older than 1 day"
+msgstr "älter als 1 Tag"
+
+#: ../src/plugin.py:36
+msgid "older than 3 days"
+msgstr "älter als 3 Tage"
+
+#: ../src/plugin.py:36
+msgid "older than 1 week"
+msgstr "älter als 1 Woche"
+
+#: ../src/plugin.py:36
+msgid "older than 2 weeks"
+msgstr "älter als 2 Wochen"
+
+#: ../src/plugin.py:49
+#: ../src/plugin.py:122
+#: ../src/plugin.py:125
+msgid "Automatic Timerlist Cleanup Setup"
+msgstr "Automatisches Aufräumen der Timerlisten - Setup"
+
+#: ../src/plugin.py:53
+msgid "Cancel"
+msgstr "Abbrechen"
+
+#: ../src/plugin.py:54
+msgid "OK"
+msgstr "OK"
+
+#: ../src/plugin.py:56
+msgid "Cleanup timerlist-entries"
+msgstr "Timerlisteneinträge aufräumen"
+
diff --git a/automatictimerlistcleanup/src/Makefile.am b/automatictimerlistcleanup/src/Makefile.am
new file mode 100755 (executable)
index 0000000..67a2a95
--- /dev/null
@@ -0,0 +1,5 @@
+installdir = /usr/lib/enigma2/python/Plugins/SystemPlugins/AutomaticTimerlistCleanup
+
+install_PYTHON = *.py
+
+install_DATA = maintainer.info
diff --git a/automatictimerlistcleanup/src/__init__.py b/automatictimerlistcleanup/src/__init__.py
new file mode 100644 (file)
index 0000000..2bad5d8
--- /dev/null
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+from Components.Language import language
+from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_LANGUAGE
+from os import environ as os_environ
+import gettext
+
+def localeInit():
+       lang = language.getLanguage()[:2] # getLanguage returns e.g. "fi_FI" for "language_country"
+       os_environ["LANGUAGE"] = lang # Enigma doesn't set this (or LC_ALL, LC_MESSAGES, LANG). gettext needs it!
+       gettext.bindtextdomain("AutomaticTimerlistCleanup", resolveFilename(SCOPE_PLUGINS, "SystemPlugins/AutomaticTimerlistCleanup/locale"))
+
+def _(txt):
+       t = gettext.dgettext("AutomaticTimerlistCleanup", txt)
+       if t == txt:
+               print "[AutomaticTimerlistCleanup] fallback to default translation for", txt
+               t = gettext.gettext(txt)
+       return t
+
+localeInit()
+language.addCallback(localeInit)
+
diff --git a/automatictimerlistcleanup/src/maintainer.info b/automatictimerlistcleanup/src/maintainer.info
new file mode 100644 (file)
index 0000000..4049126
--- /dev/null
@@ -0,0 +1,2 @@
+dr.best@dreambox-tools.info
+AutomaticTimerlistCleanup
diff --git a/automatictimerlistcleanup/src/plugin.py b/automatictimerlistcleanup/src/plugin.py
new file mode 100644 (file)
index 0000000..875f3b6
--- /dev/null
@@ -0,0 +1,126 @@
+#
+#  AutomaticTimerlistCleanup E2
+#
+#  $Id$
+#
+#  Coded by Dr.Best (c) 2010
+#  Support: www.dreambox-tools.info
+#
+#  This plugin is licensed under the Creative Commons 
+#  Attribution-NonCommercial-ShareAlike 3.0 Unported 
+#  License. To view a copy of this license, visit
+#  http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative
+#  Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
+#
+#  Alternatively, this plugin may be distributed and executed on hardware which
+#  is licensed by Dream Multimedia GmbH.
+
+#  This plugin is NOT free software. It is open source, you are allowed to
+#  modify it (if you keep the license), but it may not be commercially 
+#  distributed other than under the conditions noted above.
+#
+from Plugins.Plugin import PluginDescriptor
+from Screens.Screen import Screen
+from Components.ActionMap import ActionMap
+from Components.Sources.StaticText import StaticText
+from Components.config import config, ConfigSubsection, ConfigSelection, getConfigListEntry
+from Components.ConfigList import ConfigListScreen
+from enigma import eTimer
+from time import time, strftime, localtime
+from timer import TimerEntry
+
+# for localized messages
+from . import _
+
+config.plugins.automatictimerlistcleanup = ConfigSubsection()
+config.plugins.automatictimerlistcleanup.type = ConfigSelection(default = "-1", choices = [("-1",_("disabled")), ("0",_("immediately after recording")),("1",_("older than 1 day")),("3",_("older than 3 days")),("7",_("older than 1 week")),("14",_("older than 2 weeks"))])
+
+class AutomaticTimerlistCleanUpSetup(Screen, ConfigListScreen): # config
+
+       skin = """
+               <screen position="center,center" size="560,400" title="%s" >
+                       <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" zPosition="0" size="140,40" transparent="1" alphatest="on" />
+                       <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" zPosition="0" size="140,40" transparent="1" alphatest="on" />
+                       <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" zPosition="0" size="140,40" transparent="1" alphatest="on" />
+                       <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" zPosition="0" size="140,40" transparent="1" alphatest="on" />
+                       <widget render="Label" source="key_red" position="0,0" size="140,40" zPosition="5" valign="center" halign="center" backgroundColor="red" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
+                       <widget render="Label" source="key_green" position="140,0" size="140,40" zPosition="5" valign="center" halign="center" backgroundColor="red" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
+                       <widget name="config" position="20,50" size="520,330" scrollbarMode="showOnDemand" />
+               </screen>""" % _("Automatic Timerlist Cleanup Setup")
+
+       def __init__(self, session):
+               Screen.__init__(self, session)
+               self["key_red"] = StaticText(_("Cancel"))
+               self["key_green"] = StaticText(_("OK"))
+               self.list = [ ]
+               self.list.append(getConfigListEntry(_("Cleanup timerlist-entries"), config.plugins.automatictimerlistcleanup.type))
+               ConfigListScreen.__init__(self, self.list, session)
+               self["setupActions"] = ActionMap(["SetupActions", "ColorActions"],
+               {
+                       "green": self.keySave,
+                       "cancel": self.keyClose,
+               }, -2)
+
+       def keySave(self):
+               for x in self["config"].list:
+                       x[1].save()
+               self.close(True)
+
+       def keyClose(self):
+               for x in self["config"].list:
+                       x[1].cancel()
+               self.close(False)
+
+class AutomaticTimerlistCleanUp:
+       TIMER_INTERVAL = 86400 # check timerlist every 24 hour
+       def __init__(self, session):
+               self.session = session
+               print "[AutomaticTimerlistCleanUp] Starting AutomaticTimerlistCleanUp..."
+               self.timer = eTimer() # check timer
+               self.timer.callback.append(self.cleanupTimerlist)
+               self.cleanupTimerlist() # always check immediately after starting plugin
+               config.plugins.automatictimerlistcleanup.type.addNotifier(self.configChange, initial_call = False)
+               self.session.nav.RecordTimer.on_state_change.append(self.timerentryOnStateChange)
+
+       def cleanupTimerlist(self):
+               if int(config.plugins.automatictimerlistcleanup.type.value) > -1: # check only if feature is enabled
+                       value = time() - int(config.plugins.automatictimerlistcleanup.type.value) * 86400 # calculate end time for comparison with processed timers
+                       print "[AutomaticTimerlistCleanUp] Cleaning up timerlist-entries older than ",strftime("%c", localtime(value))
+                       self.session.nav.RecordTimer.processed_timers = [ timerentry for timerentry in self.session.nav.RecordTimer.processed_timers if timerentry.disabled or (timerentry.end and timerentry.end > value) ] # cleanup timerlist
+                       print "[AutomaticTimerlistCleanUp] Next automatic timerlist cleanup at ", strftime("%c", localtime(time()+self.TIMER_INTERVAL))
+                       self.timer.startLongTimer(self.TIMER_INTERVAL) # check again in x secs
+               else:
+                       print "[AutomaticTimerlistCleanUp] disabled"
+               
+       def configChange(self, configElement = None):
+               # config was changed in setup
+               if self.timer.isActive(): # stop timer if running
+                       self.timer.stop()
+               print "[AutomaticTimerlistCleanUp] Setup values have changed"
+               if int(config.plugins.automatictimerlistcleanup.type.value) > -1:
+                       print "[AutomaticTimerlistCleanUp] Next automatic timerlist cleanup at ", strftime("%c", localtime(time()+120))
+                       self.timer.startLongTimer(120) # check timerlist in 2 minutes after changing 
+               else:
+                       print "[AutomaticTimerlistCleanUp] disabled"
+               
+       def timerentryOnStateChange(self, timer):
+               if int(config.plugins.automatictimerlistcleanup.type.value) > -1 and timer.state == TimerEntry.StateEnded and timer.cancelled is not True: #if enabled, timerentry ended and it was not cancelled by user
+                       print "[AutomaticTimerlistCleanUp] Timerentry has been changed to StateEnd"
+                       if self.timer.isActive(): # stop timer if running
+                               self.timer.stop()
+                       self.cleanupTimerlist() # and check if entries have to be cleaned up in the timerlist
+
+def autostart(session, **kwargs):
+       AutomaticTimerlistCleanUp(session) # start plugin at sessionstart
+       
+def setup(session, **kwargs):
+       session.open(AutomaticTimerlistCleanUpSetup) # start setup
+
+def startSetup(menuid):
+       if menuid != "system": # show setup only in system level menu
+               return []
+       return [(_("Automatic Timerlist Cleanup Setup"), setup, "automatictimerlistcleanup", 46)]
+       
+def Plugins(**kwargs):
+       return [PluginDescriptor(where = [PluginDescriptor.WHERE_SESSIONSTART], fnc = autostart), PluginDescriptor(name="Automatic Timerlist Cleanup Setup", description=_("Automatic Timerlist Cleanup Setup"), where = PluginDescriptor.WHERE_MENU, fnc=startSetup) ]
+
index 224500c..0c3eea3 100644 (file)
@@ -37,6 +37,11 @@ antiscrollbar/Makefile
 antiscrollbar/meta/Makefile
 antiscrollbar/src/Makefile
 
+automatictimerlistcleanup/Makefile
+automatictimerlistcleanup/meta/Makefile
+automatictimerlistcleanup/po/Makefile
+automatictimerlistcleanup/src/Makefile
+
 autoresolution/Makefile
 autoresolution/meta/Makefile
 autoresolution/src/Makefile