Added Elektro - Please check
authorMoritz Strübe <morty@users.schwerkraft.elitedvb.net>
Sat, 11 Jul 2009 12:24:20 +0000 (12:24 +0000)
committerMoritz Strübe <morty@users.schwerkraft.elitedvb.net>
Sat, 11 Jul 2009 12:24:20 +0000 (12:24 +0000)
elektro/CONTROL/control [new file with mode: 0644]
elektro/Makefile.am [new file with mode: 0644]
elektro/po/Makefile.am [new file with mode: 0644]
elektro/po/de.po [new file with mode: 0644]
elektro/po/it.po [new file with mode: 0644]
elektro/src/Makefile.am [new file with mode: 0644]
elektro/src/__init__.py [new file with mode: 0644]
elektro/src/elektro.png [new file with mode: 0644]
elektro/src/plugin.py [new file with mode: 0644]
elektro/src/readme.txt [new file with mode: 0644]

diff --git a/elektro/CONTROL/control b/elektro/CONTROL/control
new file mode 100644 (file)
index 0000000..dd20c76
--- /dev/null
@@ -0,0 +1,10 @@
+Package: enigma2-plugin-extensions-elektro\r
+Version: 20090711\r
+Description: Automatically shut down your box when you don't need it.\r
+Architecture: mipsel\r
+Section: extra\r
+Priority: optional\r
+Maintainer: Morty <morty@gmx.net>\r
+Homepage: http://wiki.blue-panel.com/index.php/Elektro\r
+Depends: enigma2\r
+Source: http://enigma2-plugins.schwerkraft.elitedvb.net/\r
diff --git a/elektro/Makefile.am b/elektro/Makefile.am
new file mode 100644 (file)
index 0000000..8078aa5
--- /dev/null
@@ -0,0 +1 @@
+SUBDIRS = src po\r
diff --git a/elektro/po/Makefile.am b/elektro/po/Makefile.am
new file mode 100644 (file)
index 0000000..00e7998
--- /dev/null
@@ -0,0 +1,57 @@
+#\r
+# to use this for the localisation of other plugins,\r
+# just change the DOMAIN to the name of the Plugin.\r
+# It is assumed, that the domain ist the same as\r
+# the directory name of the plugin.\r
+#\r
+\r
+DOMAIN=EPGSearch\r
+installdir = /usr/lib/enigma2/python/Plugins/Extensions/$(DOMAIN)\r
+#GETTEXT=./pygettext.py\r
+GETTEXT=xgettext\r
+\r
+#MSGFMT = ./msgfmt.py\r
+MSGFMT = msgfmt\r
+\r
+LANGS := de it\r
+LANGPO := $(foreach LANG, $(LANGS),$(LANG).po)\r
+LANGMO := $(foreach LANG, $(LANGS),$(LANG).mo)\r
+\r
+default: $(DOMAIN).pot $(LANGPO) merge $(LANGMO)\r
+       for lang in $(LANGS); do \\r
+               mkdir -p $$lang/LC_MESSAGES; \\r
+               cp $$lang.mo $$lang/LC_MESSAGES/$(DOMAIN).mo; \\r
+       done\r
+\r
+merge:\r
+       for lang in $(LANGS); do \\r
+               msgmerge --no-location -s -N -U $$lang.po $(DOMAIN).pot; \\r
+       done\r
+\r
+\r
+# the TRANSLATORS: allows putting translation comments before the to-be-translated line.\r
+$(DOMAIN).pot:\r
+       $(GETTEXT) -L python --add-comments="TRANSLATORS:" -d $(DOMAIN) -s -o $(DOMAIN).pot ../src/*.py\r
+       msguniq -o $(DOMAIN)uniq.pot $(DOMAIN).pot\r
+       $(RM) $(DOMAIN).pot\r
+       mv $(DOMAIN)uniq.pot $(DOMAIN).pot\r
+\r
+.PHONY: $(DOMAIN).pot\r
+\r
+\r
+%.mo: %.po\r
+       $(MSGFMT) -o $@ $<\r
+\r
+%.po:\r
+       msginit -l $@ -o $@ -i $(DOMAIN).pot --no-translator\r
+\r
+CLEANFILES = $(foreach LANG, $(LANGS),$(LANG).mo)\r
+\r
+clean-local:\r
+       $(RM) -r $(LANGS)\r
+\r
+install-data-am: default\r
+       for lang in $(LANGS); do \\r
+               mkdir -p $(DESTDIR)$(installdir)/locale/$$lang/LC_MESSAGES; \\r
+               cp $$lang.mo $(DESTDIR)$(installdir)/locale/$$lang/LC_MESSAGES/$(DOMAIN).mo; \\r
+       done\r
diff --git a/elektro/po/de.po b/elektro/po/de.po
new file mode 100644 (file)
index 0000000..b68eaaa
--- /dev/null
@@ -0,0 +1,110 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: Elektro Power Save\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2009-04-26 11:35+0100\n"
+"PO-Revision-Date: 2009-04-26 11:35+0100\n"
+"Last-Translator: Moritz 'Morty' Strübe <morty@gmx.net>\n"
+"Language-Team: Morty <morty@gmx.net>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Poedit-Language: German\n"
+"X-Poedit-Country: GERMANY\n"
+"X-Poedit-SourceCharset: utf-8\n"
+"X-Poedit-Basepath: ../../..\n"
+"X-Poedit-SearchPath-0: .\n"
+
+#: plugin.py:110
+msgid "Monday"
+msgstr "Montag"
+
+#: plugin.py:111
+msgid "Tuesday"
+msgstr "Dienstag"
+
+#: plugin.py:112
+msgid "Wednesday"
+msgstr "Mittwoch"
+
+#: plugin.py:113
+msgid "Thursday"
+msgstr "Donnerstag"
+
+#: plugin.py:114
+msgid "Friday"
+msgstr "Freitag"
+
+#: plugin.py:115
+msgid "Saturday"
+msgstr "Samstag"
+
+#: plugin.py:116
+msgid "Sunday"
+msgstr "Sonntag"
+
+#: plugin.py:195
+msgid "Enable Elektro Power Save"
+msgstr "Elektro Power Save aktivieren"
+
+#: plugin.py:196
+#: plugin.py:300
+msgid "Standby on boot"
+msgstr "Nach dem Booten in den Standby"
+
+#: plugin.py:197
+msgid "Standby on manual boot"
+msgstr "Nach dem manuellen Booten in den Standby"
+
+#: plugin.py:198
+msgid "Standby on boot screen timeout"
+msgstr "In-den-Standby-Bildschirm Anzeigezeit"
+
+#: plugin.py:199
+msgid "Force sleep (even when not in standby)"
+msgstr "Erzwinge Ruhezustand (auch wenn nicht im Standby)"
+
+#: plugin.py:200
+msgid "Dont wake up"
+msgstr "Nicht aufwachen"
+
+#: plugin.py:201
+msgid "Holiday mode (experimental)"
+msgstr "Urlaubsmodus (Experimentell)"
+
+#: plugin.py:203
+msgid "Next day starts at"
+msgstr "Die nächste Tag beginnt um"
+
+#: plugin.py:206
+msgid "Wakeup"
+msgstr "Aufwachen"
+
+#: plugin.py:207
+msgid "Sleep"
+msgstr "Ruhezustand"
+
+#: plugin.py:211
+msgid "Cancel"
+msgstr "Abbruch"
+
+#: plugin.py:212
+msgid "Ok"
+msgstr "OK"
+
+#: plugin.py:213
+msgid "Help"
+msgstr "Hilfe"
+
+#: plugin.py:237
+msgid "Showing Elektro readme.txt"
+msgstr "Zeige Electro Readme.txt"
+
+#: plugin.py:323
+msgid "Go to Standby now?"
+msgstr "Jetzt in den Standby gehen?"
+
+#: plugin.py:465
+msgid "Go to sleep now?"
+msgstr "Jetzt in den Ruhezustand gehen?"
+
diff --git a/elektro/po/it.po b/elektro/po/it.po
new file mode 100644 (file)
index 0000000..eee3545
--- /dev/null
@@ -0,0 +1,107 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: enigma2 - elektropowersaver\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2009-03-28 16:15+0100\n"
+"PO-Revision-Date: 2009-03-28 16:32+0100\n"
+"Last-Translator: Spaeleus <spaeleus@croci.org>\n"
+"Language-Team: www.linsat.net <spaeleus@croci.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+"X-Poedit-Language: Italian\n"
+"X-Poedit-Country: ITALY\n"
+"X-Poedit-SourceCharset: iso-8859-1\n"
+"X-Poedit-Basepath: /home/dario/Plugins/elektro\n"
+"X-Poedit-SearchPath-0: /home/dario/Plugins/elektro\n"
+
+#: /home/dario/Plugins/elektro/plugin.py:108
+msgid "Monday"
+msgstr "Lunedì"
+
+#: /home/dario/Plugins/elektro/plugin.py:109
+msgid "Tuesday"
+msgstr "Martedì"
+
+#: /home/dario/Plugins/elektro/plugin.py:110
+msgid "Wednesday"
+msgstr "Mercoledì"
+
+#: /home/dario/Plugins/elektro/plugin.py:111
+msgid "Thursday"
+msgstr "Giovedì"
+
+#: /home/dario/Plugins/elektro/plugin.py:112
+msgid "Friday"
+msgstr "Venerdì"
+
+#: /home/dario/Plugins/elektro/plugin.py:113
+msgid "Saturday"
+msgstr "Sabato"
+
+#: /home/dario/Plugins/elektro/plugin.py:114
+msgid "Sunday"
+msgstr "Domenica"
+
+#: /home/dario/Plugins/elektro/plugin.py:182
+msgid "Enable Elektro Power Save"
+msgstr "Abilitare \"Elektro Power Save\""
+
+#: /home/dario/Plugins/elektro/plugin.py:183
+#: /home/dario/Plugins/elektro/plugin.py:269
+msgid "Standby on boot"
+msgstr "Standby all'avvio"
+
+#: /home/dario/Plugins/elektro/plugin.py:184
+msgid "Standby on boot screen timeout"
+msgstr "Timeout standby su schermata di avvio"
+
+#: /home/dario/Plugins/elektro/plugin.py:185
+msgid "Force sleep (even when not in standby)"
+msgstr "Forzare spegnimento (anche se non in standby)"
+
+#: /home/dario/Plugins/elektro/plugin.py:186
+msgid "Dont wake up"
+msgstr "Non accendere"
+
+#: /home/dario/Plugins/elektro/plugin.py:187
+msgid "Holiday mode (experimental)"
+msgstr "Modalità \"vacanza\" (sperimentale)"
+
+#: /home/dario/Plugins/elektro/plugin.py:189
+msgid "Next day starts at"
+msgstr "Il prossimo giorno inizia alle"
+
+#: /home/dario/Plugins/elektro/plugin.py:192
+msgid "Wakeup"
+msgstr "Accendere"
+
+#: /home/dario/Plugins/elektro/plugin.py:193
+msgid "Sleep"
+msgstr "Spegnere"
+
+#: /home/dario/Plugins/elektro/plugin.py:197
+msgid "Cancel"
+msgstr "Annull."
+
+#: /home/dario/Plugins/elektro/plugin.py:198
+msgid "Ok"
+msgstr "Ok"
+
+#: /home/dario/Plugins/elektro/plugin.py:199
+msgid "Help"
+msgstr "Aiuto"
+
+#: /home/dario/Plugins/elektro/plugin.py:223
+msgid "Showing Elektro readme.txt"
+msgstr "Elektro readme.txt"
+
+#: /home/dario/Plugins/elektro/plugin.py:292
+msgid "Go to Standby now?"
+msgstr "Standby?"
+
+#: /home/dario/Plugins/elektro/plugin.py:434
+msgid "Go to sleep now?"
+msgstr "Spegenere?"
+
diff --git a/elektro/src/Makefile.am b/elektro/src/Makefile.am
new file mode 100644 (file)
index 0000000..58a4f66
--- /dev/null
@@ -0,0 +1,4 @@
+installdir = /usr/lib/enigma2/python/Plugins/Extensions/Elektro\r
+\r
+install_PYTHON = *.py\r
+install_DATA = readme.txt elektro.png\r
diff --git a/elektro/src/__init__.py b/elektro/src/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/elektro/src/elektro.png b/elektro/src/elektro.png
new file mode 100644 (file)
index 0000000..a47c71c
Binary files /dev/null and b/elektro/src/elektro.png differ
diff --git a/elektro/src/plugin.py b/elektro/src/plugin.py
new file mode 100644 (file)
index 0000000..9ad38e9
--- /dev/null
@@ -0,0 +1,496 @@
+#
+# Power Save Plugin by gutemine
+# Rewritten by Morty (morty@gmx.net)
+#
+# Deep standby will be called sleep. Normal standby will be named standby!
+# All calculations are in the local timezone, or in the relative Timezone.
+# In the relative timezone the day starts at "nextday". If it is before nextday the last day will be used.
+#
+#
+
+
+#from enigma import *
+
+
+from Screens.InfoBarGenerics import *
+# from RecordTimer import *
+
+
+import calendar 
+#################
+
+# Plugin
+from Plugins.Plugin import PluginDescriptor
+
+# GUI (Screens)
+from Screens.Screen import Screen
+from Components.ConfigList import ConfigListScreen
+from Screens.MessageBox import MessageBox
+from Screens.Console import Console
+from Screens import Standby 
+
+# GUI (Summary)
+# from Screens.Setup import SetupSummary
+
+# GUI (Components)
+from Components.ActionMap import ActionMap
+from Components.Button import Button
+
+# Configuration
+from Components.config import getConfigListEntry, ConfigEnableDisable, \
+       ConfigYesNo, ConfigText, ConfigClock, ConfigNumber, ConfigSelection, \
+       config, ConfigSubsection, ConfigSubList, ConfigSubDict
+
+# Startup/shutdown notification
+from Tools import Notifications
+
+import os
+# Timer, etc
+
+#import time
+from time import localtime, asctime, time, gmtime
+# import datetime
+# import codecs
+
+
+# Enigma system functions
+from enigma import quitMainloop, eTimer
+
+
+# import Wakeup?!
+from Tools.DreamboxHardware import getFPWasTimerWakeup
+
+
+
+# from Tools import Directories
+import gettext
+from Tools.Directories import resolveFilename, SCOPE_PLUGINS
+try:
+       _ = gettext.translation('elektro', resolveFilename(SCOPE_PLUGINS, "Extensions/Elektro/locale"), [config.osd.language.getText()]).gettext
+except IOError:
+       print "[Elektro] Locale not found!"
+       pass
+
+#############
+
+# Globals
+session = None
+ElektroWakeUpTime = -1
+elektro_pluginversion = "3.3.1"
+elektro_readme = "/usr/lib/enigma2/python/Plugins/Extensions/Elektro/readme.txt"
+elektrostarttime = 60 
+elektrosleeptime = 5
+elektroShutdownThreshold = 60 * 20
+
+
+#Configuration
+config.plugins.elektro = ConfigSubsection()
+config.plugins.elektro.nextday = ConfigClock(default = ((6 * 60 + 0) * 60) )
+
+config.plugins.elektro.sleep = ConfigSubDict()
+for i in range(7):
+       config.plugins.elektro.sleep[i] = ConfigClock(default = ((1 * 60 + 0) * 60) )
+
+config.plugins.elektro.wakeup = ConfigSubDict()
+for i in range(7):
+       config.plugins.elektro.wakeup[i] = ConfigClock(default = ((9 * 60 + 0) * 60) )
+
+config.plugins.elektro.standbyOnBoot = ConfigEnableDisable(default = False)
+config.plugins.elektro.standbyOnManualBoot =  ConfigEnableDisable(default = True)
+config.plugins.elektro.standbyOnBootTimeout = ConfigNumber(default = 60)
+config.plugins.elektro.enable = ConfigEnableDisable(default = False)
+config.plugins.elektro.nextwakeup = ConfigNumber(default = 0)
+config.plugins.elektro.force = ConfigEnableDisable(default = False)
+config.plugins.elektro.dontwakeup = ConfigEnableDisable(default = False)
+config.plugins.elektro.holiday =  ConfigEnableDisable(default = False)
+
+
+
+weekdays = [
+       _("Monday"),
+       _("Tuesday"),
+       _("Wednesday"),
+       _("Thursday"),
+       _("Friday"),
+       _("Saturday"),
+       _("Sunday"),
+]
+
+
+#global ElektroWakeUpTime
+ElektroWakeUpTime = -1
+
+def autostart(reason, **kwargs):
+       global session  
+       if reason == 0 and kwargs.has_key("session"):
+               session = kwargs["session"]
+               session.open(DoElektro)
+
+def getNextWakeup():
+       global ElektroWakeUpTime
+       
+       #it might happen, that session does not exist. I don't know why. :-(
+       if session is None:
+               return ElektroWakeUpTime;
+       
+       nextTimer = session.nav.RecordTimer.getNextRecordingTime()
+       print "[Elektro] Now: " + strftime("%a:%H:%M:%S",  gmtime(time()))
+       if (nextTimer < 1) or (nextTimer > ElektroWakeUpTime):
+               print "[Elektro] will wake up " + strftime("%a:%H:%M:%S",  gmtime(ElektroWakeUpTime))
+               return ElektroWakeUpTime
+       
+       #We have to make sure, that the Box will wake up because of us
+       # and not because of the timer
+       print "[Elektro] will wake up due to the next timer" + strftime("%a:%H:%M:%S",  gmtime(nextTimer))
+       return nextTimer - 1
+          
+       
+       
+       
+def Plugins(**kwargs):
+       return [
+               PluginDescriptor(
+                       name="Elektro", 
+                       description="Elektro Power Save Plugin Ver. " + elektro_pluginversion, 
+                       where = [
+                               PluginDescriptor.WHERE_SESSIONSTART, 
+                               PluginDescriptor.WHERE_AUTOSTART
+                       ], 
+                       fnc = autostart, 
+                       wakeupfnc=getNextWakeup
+               ),
+               PluginDescriptor(
+                       name="Elektro", 
+                       description="Elektro Power Save Plugin Ver. " + elektro_pluginversion, 
+                       where = PluginDescriptor.WHERE_PLUGINMENU, 
+                       icon="elektro.png", 
+                       fnc=main
+               )
+       ]
+
+       
+def main(session,**kwargs):
+       try:    
+               session.open(Elektro)
+       except:
+               print "[Elektro] Pluginexecution failed"
+
+class Elektro(ConfigListScreen,Screen):
+       skin = """
+                       <screen position="100,100" size="550,400" title="Elektro Power Save Ver. """ + elektro_pluginversion + """" >
+                       <widget name="config" position="0,0" size="550,360" scrollbarMode="showOnDemand" />
+                       
+                       <widget name="key_red" position="0,360" size="140,40" valign="center" halign="center" zPosition="4"  foregroundColor="white" font="Regular;18" transparent="1"/> 
+                       <widget name="key_green" position="140,360" size="140,40" valign="center" halign="center" zPosition="4"  foregroundColor="white" font="Regular;18" transparent="1"/> 
+                       <widget name="key_yellow" position="280,360" size="140,40" valign="center" halign="center" zPosition="4"  foregroundColor="white" font="Regular;18" transparent="1"/>
+                       
+                       <ePixmap name="red"    position="0,360"   zPosition="2" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
+                       <ePixmap name="green"  position="140,360" zPosition="2" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
+                       <ePixmap name="yellow" position="280,360" zPosition="2" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" /> 
+               </screen>"""
+               
+       def __init__(self, session, args = 0):
+               self.session = session
+               Screen.__init__(self, session)
+       
+               
+               self.list = []
+               
+               
+               self.list.append(getConfigListEntry(_("Enable Elektro Power Save"),config.plugins.elektro.enable))
+               self.list.append(getConfigListEntry(_("Standby on boot"), config.plugins.elektro.standbyOnBoot ))
+               self.list.append(getConfigListEntry(_("Standby on manual boot"), config.plugins.elektro.standbyOnManualBoot ))
+               self.list.append(getConfigListEntry(_("Standby on boot screen timeout"), config.plugins.elektro.standbyOnBootTimeout))
+               self.list.append(getConfigListEntry(_("Force sleep (even when not in standby)"), config.plugins.elektro.force ))
+               self.list.append(getConfigListEntry(_("Dont wake up"), config.plugins.elektro.dontwakeup ))
+               self.list.append(getConfigListEntry(_("Holiday mode (experimental)"), config.plugins.elektro.holiday ))
+               
+               self.list.append(getConfigListEntry(_("Next day starts at"), config.plugins.elektro.nextday))
+
+               for i in range(7):
+                       self.list.append(getConfigListEntry(weekdays[i] + ": "  + _("Wakeup"), config.plugins.elektro.wakeup[i]))
+                       self.list.append(getConfigListEntry(weekdays[i] + ": "  + _("Sleep"), config.plugins.elektro.sleep[i]))
+                       
+               ConfigListScreen.__init__(self, self.list)
+               
+               self["key_red"] = Button(_("Cancel"))
+               self["key_green"] = Button(_("Ok"))
+               self["key_yellow"] = Button(_("Help"))
+               self["setupActions"] = ActionMap(["SetupActions", "ColorActions"],
+               {
+                       "red": self.cancel,
+                       "green": self.save,
+                       "yellow": self.help,
+                       "save": self.save,
+                       "cancel": self.cancel,
+                       "ok": self.save,
+               }, -2)
+       
+       def save(self):
+               #print "saving"
+               for x in self["config"].list:
+                       x[1].save()
+               self.close(True,self.session)
+
+       def cancel(self):
+               #print "cancel"
+               for x in self["config"].list:
+                       x[1].cancel()
+               self.close(False,self.session)
+               
+       def help(self):
+               self.session.open(Console,_("Showing Elektro readme.txt"),["cat %s" % elektro_readme])
+
+
+class DoElektro(Screen):
+       skin = """ <screen position="100,100" size="300,300" title="Elektro Plugin Menu" > </screen>"""
+       
+       def __init__(self,session):
+               Screen.__init__(self,session)
+               
+               print "[Elektro] Starting up Version " + elektro_pluginversion
+               
+               self.session = session
+               
+               # Make sure wakeup time is set.
+               self.setNextWakeuptime()
+               
+               # If we didn't wake up by a timer we don't want to go to sleep any more.
+               # Unforturnately it is not possible to use getFPWasTimerWakeup()
+               # Therfore we're checking wheter there is a recording starting within
+               # the next five min             
+               self.dontsleep = False
+               
+               #Let's assume we got woken up manually
+               timerWakeup = False
+               
+               #Is a recording already runniong ->woken up by a timer
+               if self.session.nav.RecordTimer.isRecording():
+                       timerWakeup = True
+               # Is the next timer within 5 min -> woken up by a timer 
+               if abs(self.session.nav.RecordTimer.getNextRecordingTime() - time()) <= 360:
+                       timerWakeup = True
+                       
+               # Did we wake up by Elektro?
+               # Let's hope this get's run early enaugh, and this get's run
+               # before the requested wakeup-time (should be the case)
+               #
+               if abs(ElektroWakeUpTime - time()) <= 360:
+                       timerWakeup = True      
+                       
+               # If the was a manual wakeup: Don't go to sleep 
+               if timerWakeup == False:
+                       self.dontsleep = True
+               
+               
+               #Check whether we should try to sleep:
+               trysleep = config.plugins.elektro.standbyOnBoot.value
+               
+               #Don't go to sleep when this was a manual wakeup and the box shouldn't go to standby
+               if timerWakeup == False and     config.plugins.elektro.standbyOnManualBoot.value == False:
+                       trysleep = False
+                       
+       
+               #if waken up by timer and configured ask whether to go to sleep.
+               if trysleep:
+                       self.TimerStandby = eTimer()
+                       self.TimerStandby.callback.append(self.CheckStandby)
+                       self.TimerStandby.startLongTimer(elektrosleeptime)
+                       print "[Elektro] Set up standby timer"
+
+               self.TimerSleep = eTimer()
+               self.TimerSleep.callback.append(self.CheckElektro)
+               self.TimerSleep.startLongTimer(elektrostarttime)
+               print "[Elektro] Set up sleep timer"
+               print "[Elektro] Translation test: " + _("Standby on boot")
+               
+       def clkToTime(self, clock):
+               return ( (clock.value[0]) * 60 + (int)(clock.value[1]) )  * 60
+               
+       def getTime(self):
+               ltime = localtime();
+               return ( (int)(ltime.tm_hour) * 60 + (int)(ltime.tm_min) ) * 60
+       
+       def getPrintTime(self, secs):
+               return strftime("%H:%M:%S", gmtime(secs))
+
+       
+       # This function converts the time into the relative Timezone where the day starts at "nextday"
+       # This is done by substracting nextday from the current time. Negative times are corrected using the mod-operator
+       def getReltime(self, time):
+               nextday = self.clkToTime(config.plugins.elektro.nextday)
+               return (time - nextday) %  (24 * 60 * 60)
+               
+       
+       def CheckStandby(self):
+               print "[Elektro] Showing Standby Sceen "
+               try:
+                       self.session.openWithCallback(self.DoElektroStandby,MessageBox,_("Go to Standby now?"),type = MessageBox.TYPE_YESNO,
+                                       timeout = config.plugins.elektro.standbyOnBootTimeout.value)            
+               except:
+                       # Couldn't be shown. Restart timer.
+                       print "[Elektro] Failed Showing Standby Sceen "
+                       self.TimerStandby.startLongTimer(elektrostarttime)
+
+
+       def DoElektroStandby(self,retval):
+               if (retval):
+                       #Yes, go to sleep
+                       Notifications.AddNotification(Standby.Standby)
+               
+
+                       
+       def setNextWakeuptime(self):
+               # Do not set a wakeup time if
+               #  - Elektro isn't enabled
+               #  - Elektro shouldn't wake up
+               #  - Holiday mode is turned on
+               if ((config.plugins.elektro.enable.value == False) 
+                     or (config.plugins.elektro.dontwakeup.value == True)
+                     or config.plugins.elektro.holiday.value == True): 
+                       global ElektroWakeUpTime
+                       ElektroWakeUpTime = -1
+                       return
+                       
+               time_s = self.getTime()
+               ltime = localtime()
+               
+               #print "Nextday:" + time.ctime(self.clkToTime(config.plugins.elektro.nextday))
+               # If it isn't past next-day time we need yesterdays settings
+               if time_s < self.clkToTime(config.plugins.elektro.nextday):
+                       day = (ltime.tm_wday - 1) % 7
+               else:
+                       day = ltime.tm_wday
+               
+               #Check whether we wake up today or tomorrow
+               # Relative Time is needed for this
+               time_s = self.getReltime(time_s)
+               wakeuptime = self.getReltime(self.clkToTime(config.plugins.elektro.wakeup[day]))
+               
+               # Lets see if we already woke up today
+               if wakeuptime < time_s:
+                       #yes we did -> Next wakeup is tomorrow
+                       #print "Elektro: Wakeup tomorrow"
+                       day = (day + 1) % 7
+                       wakeuptime = self.getReltime(self.clkToTime(config.plugins.elektro.wakeup[day]))
+               
+               # Tomorrow we'll wake up erly-> Add a full day.
+               if wakeuptime < time_s:
+                       wakeuptime = wakeuptime + 24 * 60 * 60
+               
+               # The next wakeup will be in wakupin seconds
+               wakeupin = wakeuptime - time_s
+               
+               # Now add this to the current time to get the wakeuptime
+               wakeuptime = (int)(time()) + wakeupin
+               
+               #Write everything to the global variable
+               ElektroWakeUpTime = wakeuptime
+                       
+                       
+       def CheckElektro(self):
+               # first set the next wakeuptime - it would be much better to call that function on sleep. This will be a todo!
+               self.setNextWakeuptime()
+       
+               #convert to seconds
+               time_s = self.getTime()
+               ltime = localtime()
+               
+               print "[Elektro] Testtime; " + self.getPrintTime(2 * 60 * 60)
+               
+               #Which day is it? The next day starts at nextday
+               print "[Elektro] wday 1: " + str(ltime.tm_wday)
+               if time_s < self.clkToTime(config.plugins.elektro.nextday):
+                       day = (ltime.tm_wday - 1) % 7
+               else:
+                       day = ltime.tm_wday
+                       
+               print "[Elektro] wday 2: " + str(day)
+               
+               #Let's get the day
+               wakeuptime = self.clkToTime(config.plugins.elektro.wakeup[day])
+               sleeptime = self.clkToTime(config.plugins.elektro.sleep[day])
+               print "[Elektro] Current time: " + self.getPrintTime(time_s)
+               print "[Elektro] Wakeup time: " + self.getPrintTime(wakeuptime)
+               print "[Elektro] Sleep time: " + self.getPrintTime(sleeptime)
+               
+               #convert into relative Times
+               time_s = self.getReltime(time_s)
+               wakeuptime  = self.getReltime(wakeuptime)
+               sleeptime = self.getReltime(sleeptime)
+               
+               print "[Elektro] Current Rel-time: " + self.getPrintTime(time_s)
+               print "[Elektro] Wakeup Rel-time: " + self.getPrintTime(wakeuptime)
+               print "[Elektro] Sleep Rel-time: " + self.getPrintTime(sleeptime)
+               
+               
+               #let's see if we should be sleeping
+               trysleep = False
+               if time_s < (wakeuptime - elektroShutdownThreshold): # Wakeup is in the future -> sleep!
+                       trysleep = True
+                       print "[Elektro] Wakeup!" + str(time_s) + " < " + str(wakeuptime)
+               if sleeptime < time_s : #Sleep is in the past -> sleep!
+                       trysleep = True
+                       print "[Elektro] Sleep: " + str(sleeptime) + " < " + str(time_s)
+               
+               #We are not tying to go to sleep anymore -> maybe go to sleep again the next time
+               if trysleep == False:
+                       self.dontsleep = False
+               
+               #The User aborted to got to sleep -> Don't go to sleep.
+               if self.dontsleep:
+                       trysleep = False
+                       
+               # If we are in holydaymode we should try to got to sleep anyway
+               # This should be set after self.dontsleep has been handled
+               if config.plugins.elektro.holiday.value:
+                       trysleep = True
+               
+               # We are not enabled -> Dont go to sleep (This could have been catched earlier!)
+               if config.plugins.elektro.enable.value == False:
+                       trysleep = False
+               
+               # Only go to sleep if we are in standby or sleep is forced by settings
+               if  not ((Standby.inStandby) or (config.plugins.elektro.force.value == True) ):
+                       trysleep = False
+               
+               # No Sleep while recording
+               if self.session.nav.RecordTimer.isRecording():
+                       trysleep = False
+               
+               # Will there be a recording in a short while?
+               nextRecTime = self.session.nav.RecordTimer.getNextRecordingTime()
+               if  (nextRecTime > 0) and (nextRecTime - (int)(time()) <  elektroShutdownThreshold):
+                       trysleep = False
+                       
+               # Looks like there really is a reason to go to sleep -> Lets try it!
+               if trysleep:
+                       #self.();
+                       try:
+                               self.session.openWithCallback(self.DoElektroSleep, MessageBox, _("Go to sleep now?"),type = MessageBox.TYPE_YESNO,timeout = 60) 
+                       except:
+                               #reset the timer and try again
+                               self.TimerSleep.startLongTimer(elektrostarttime) 
+                               
+               #set Timer, which calls this function again.
+               self.TimerSleep.startLongTimer(elektrostarttime) 
+               
+               
+
+
+       def DoElektroSleep(self,retval):
+               if (retval):
+                       # os.system("wall 'Powermanagent does Deepsleep now'")
+                       #  Notifications.AddNotification(TryQuitMainloop,1)
+                       # 1 = Deep Standby -> enigma2:/doc/RETURNCODES
+                       
+                       global inTryQuitMainloop
+                       if Standby.inTryQuitMainloop == False:
+                               self.session.open(Standby.TryQuitMainloop, 1) # <- This might not work reliably
+                               #quitMainloop(1)
+               else:
+                       # Dont try to sleep until next wakeup
+                       self.dontsleep = True
+                       #Start the timer again
+                       self.TimerSleep.startLongTimer(elektrostarttime) 
+                       
diff --git a/elektro/src/readme.txt b/elektro/src/readme.txt
new file mode 100644 (file)
index 0000000..6821d08
--- /dev/null
@@ -0,0 +1,230 @@
+====================================================
+Elektro Power Save for Dreambox 7025 
+Version 1 & 2 by gutemine
+Version 3 by Morty <morty@gmx.net>
+====================================================
+Release infos 
+====================================================
+1.0   first version, as usually completely 
+      untested - have Fun !
+1.1   now after boot the Dreambox will go 
+      immediately to normal Standby
+1.2   some bugfixes on Plugin Text and 
+      make standby on boot configurable
+2.0   make ipk kit, add info messages before standby 
+      and prevent deepstandby if timer is running
+2.1   bug fixes and support for new images with TryQuit
+      mainloop (which is since mid January 2007 in CVS)
+2.2   still alive 
+2.3   make compatible with latest CVS changes
+      probably last version by gutemine
+
+3.0   Rewritten by Morty, lots of new features
+3.0.2 It's now possible to adjust the how long to
+      show the shutdown screen
+3.0.4 Bugfix
+3.0.5 Fixed problem where the box shuts down again
+      when it boots up too fast
+3.1.0 Removed unneeded dependencies
+      Don't shut down if woken up manually
+3.2.0 Recording detection should work now
+      Holiday mode has been implemented
+3.2.1 Fixed Bug not recognizing a wakeup by Elektro 
+3.2.2 Added the Italian translation by Spaeleus     
+3.2.3 Fixed problem with auto-Timers
+3.3.0 Added an option to choose whether to go to 
+      standby on manual boot
+3.3.1 Fixed problem when the global session was not
+      available
+3.3.2 Fixed some problems shutting down on latest
+         versions of enigma2.
+====================================================
+The English Documentation follows the German one 
+====================================================
+
+1) Voraussetzung
+----------------
+Power Save sollte auf den meisten Systemen mit Enigma2
+funktionieren. Muss aber nicht.
+DM7025 + DM8000: Wird unterstützt.
+DM800: Kann nicht alleine aufwachen, wird daher nicht
+wirklich unterstützt.
+
+2) Installation
+---------------
+
+Zuerst kopiert das elektro*.ipk File vom 
+elektro*.zip auf /tmp mit ftp (TCP/IP muss
+natürlich schon funktionieren). 
+
+Wenn Ihr ein Image geflashed habt, das ein Blue 
+Pannel hat könnt Ihr damit mit Manual Install das
+ipk file installieren.
+
+Wenn nicht, dann installiert elektro mit folgenden 
+Kommandos im Telnet:
+
+cd /
+ipkg install /tmp/elektro*.ipk
+
+Beim ipk install wird enigma auch gleich 
+restarted, um das Elektro Plugin bei den 
+Spielen/Erweiterungen angezeigt zu bekommen. 
+Wenn es dort nicht auftaucht, 
+probieren sie einen manuellen Reboot.
+
+3) Funktionsweise
+-----------------
+
+Das Elektro Power Save Plugin sorgt dafür, zu die Box
+zu bestimmten Zeiten in den Ruhezustand (Deep Standby)
+heruntergefahren wird. Dies passiert nur, wenn sie
+sich in Standby befindet und keine Aufnahme läuft
+oder in den nächsten 20 Minuten gestartet wird.
+
+Zu Aufnahmen und nach Ende der Ruhezeit wacht die Box
+von alleine wieder auf, so dass man nicht ewig warten
+muss, bis sie Bereit ist.
+
+4) Optionen
+-----------
+Hauptmenü -> Erweiterungen -> Elektro Power Save
+
+ - Elektro Power Save aktivieren
+   Aktiviert das Plugin
+   
+ - Nach dem Booten in den Standby
+   Geht nach dem Booten in den Standby
+   
+ - Nach dem manuellen Booten in den Standby
+   Soll nach einem manuellen Bootvorgang in den 
+   Standby gegangen werden? Die Box geht nach 
+   einem manuellen Bootvorgang erst in der nächsten
+   den Ruhezeit in den Ruhezustand, selbst wenn
+   diese Option aktiviert ist.
+   Diese Option wird nur ausgewertet, wenn "Nach 
+   dem Booten in den Standby" aktiviert ist.
+   
+ - In-den-Standby-Bildschirm Anzeigezeit
+   Stellt ein wie lange die Stanby-Abfrge angezeigt
+   wird. Dieser Wert kann erhöht werden um sicher zu
+   stellen, dass sich die Box während der Ruhe-Zeit 
+   nicht zu schnell wieder abschaltet.
+   
+ - Erzwinge Ruhezustand
+   Erzwingt den Ruhezustand auch, wenn die Box nicht
+   im Standby ist. Auf Aufnahmen hat dies keinen Ein-
+   fluss.
+   
+ - Nicht aufwachen
+   Die Box wacht nach dem eine der Ruhe-Zeit nicht von
+   alleine auf.
+   
+ - Urlaubsmodus
+   Die Box geht immer schlafen, wenn nicht gerade
+   aufgenommen wird.
+   
+ - Die nächste Tag beginnt um und sostige Zeiten
+   Soll die Box Montag Nacht um 1 in den Ruhezustand,
+   ist es genau genommen schon Dienstag. Damit dies
+   trotzdem möglich ist, muss angegeben werden wann 
+   der nächste Tag anfängt.
+   Der Rest ist hoffentlich selbsterklärend.
+   
+
+
+
+====================================================
+Viel Spass mit dem Stromsparen und Umweltschützen
+mit dem Elektro Plugin auf der Dreambox 7025 !!!!
+====================================================
+
+
+1) Prerequisites
+----------------
+
+Should work on most systems using Enigma2, but this 
+isn't granted.
+DM7025 + DM8000: Supported.
+DM800: Can not wake up by itself. It therefore isn't
+really supported.
+
+2) Installation
+---------------
+
+First copy the elektro*.ipk file from elektro*.zip
+to /tmp with ftp (TCP/IP must be working already). 
+
+If you have flashed an image that offer in Blue 
+Pannel Manual Addon Install you can use this 
+functionality to install the ipk file.
+
+If not, then install Elektro by entering the 
+following commands in a Telnet session:
+
+cd /
+ipkg install /tmp/elektro*.ipk
+
+The ipkg install will also restart enigma for 
+you to get the Elektro Plugin shown in addons 
+menu. If it doesn't show up try to reboot 
+manually.
+
+3) Mode of operation    
+--------------------
+The Elektro Power Save Plugin puts the box from 
+stand by to sleep mode (Deep Standby) at certain 
+times. This only happens if the box is in standby
+and no recording is running or sheduled in the 
+next 20 minutes.
+
+The box automatically wakes up for recordings or
+at the end of the sleep time. You therefore don't
+have to wait until it is on again.
+
+4) Optiones
+-----------
+Main menu -> Extensions -> Elektro Power Save
+
+ - Enable Elektro Power Save
+   Enables the Plugin.
+   
+ - Standby on boot
+   Puts the box in standby after boot.  
+   
+ - Standby on manual boot
+   Whether to put the box in standby when booted
+   manually. On manual boot the box will not go
+   to sleep until the next sleep intervall eaven
+   when this is turned on.
+   This option is only evaluated if Standby on
+   boot is turned on.  
+   
+ - Standby on boot screen timeout
+   How long to show the standby on boot screen.
+   This value can be encreased to ensure the box
+   does not shut down again to quickly during
+   sleep times.
+   
+ - Force sleep 
+   Forces sleep, even when not in standby. This
+   has influence on sheduled recordings.
+   
+ - Dont wake up
+   Do not wake up at the end of the sleep time.
+   
+ - Holiday mode
+   The box goes to sleep when not recording   
+   
+ - Next day starts at and other times
+   If the box is supposed to go to sleep Monday night
+   at 1 it is actually already Thuesday. To make this
+   nonetheless possible, it must be known when the
+   next day Starts.
+   Hopefully the rest is self-explanatory. 
+
+
+======================================================
+Have Fun to let Elektro Save Power and the 
+Environment with your Dreambox 7025 !!!!
+======================================================
\ No newline at end of file