From 6c3ab8ac75a4a823da3151cc524f63d18a632157 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Moritz=20Str=C3=BCbe?= Date: Sat, 11 Jul 2009 12:24:20 +0000 Subject: [PATCH] Added Elektro - Please check --- elektro/CONTROL/control | 10 + elektro/Makefile.am | 1 + elektro/po/Makefile.am | 57 ++++++ elektro/po/de.po | 110 +++++++++++ elektro/po/it.po | 107 +++++++++++ elektro/src/Makefile.am | 4 + elektro/src/__init__.py | 0 elektro/src/elektro.png | Bin 0 -> 3882 bytes elektro/src/plugin.py | 496 ++++++++++++++++++++++++++++++++++++++++++++++++ elektro/src/readme.txt | 230 ++++++++++++++++++++++ 10 files changed, 1015 insertions(+) create mode 100644 elektro/CONTROL/control create mode 100644 elektro/Makefile.am create mode 100644 elektro/po/Makefile.am create mode 100644 elektro/po/de.po create mode 100644 elektro/po/it.po create mode 100644 elektro/src/Makefile.am create mode 100644 elektro/src/__init__.py create mode 100644 elektro/src/elektro.png create mode 100644 elektro/src/plugin.py create mode 100644 elektro/src/readme.txt diff --git a/elektro/CONTROL/control b/elektro/CONTROL/control new file mode 100644 index 0000000..dd20c76 --- /dev/null +++ b/elektro/CONTROL/control @@ -0,0 +1,10 @@ +Package: enigma2-plugin-extensions-elektro +Version: 20090711 +Description: Automatically shut down your box when you don't need it. +Architecture: mipsel +Section: extra +Priority: optional +Maintainer: Morty +Homepage: http://wiki.blue-panel.com/index.php/Elektro +Depends: enigma2 +Source: http://enigma2-plugins.schwerkraft.elitedvb.net/ diff --git a/elektro/Makefile.am b/elektro/Makefile.am new file mode 100644 index 0000000..8078aa5 --- /dev/null +++ b/elektro/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = src po diff --git a/elektro/po/Makefile.am b/elektro/po/Makefile.am new file mode 100644 index 0000000..00e7998 --- /dev/null +++ b/elektro/po/Makefile.am @@ -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=EPGSearch +installdir = /usr/lib/enigma2/python/Plugins/Extensions/$(DOMAIN) +#GETTEXT=./pygettext.py +GETTEXT=xgettext + +#MSGFMT = ./msgfmt.py +MSGFMT = msgfmt + +LANGS := de it +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/elektro/po/de.po b/elektro/po/de.po new file mode 100644 index 0000000..b68eaaa --- /dev/null +++ b/elektro/po/de.po @@ -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 \n" +"Language-Team: Morty \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 index 0000000..eee3545 --- /dev/null +++ b/elektro/po/it.po @@ -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 \n" +"Language-Team: www.linsat.net \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 index 0000000..58a4f66 --- /dev/null +++ b/elektro/src/Makefile.am @@ -0,0 +1,4 @@ +installdir = /usr/lib/enigma2/python/Plugins/Extensions/Elektro + +install_PYTHON = *.py +install_DATA = readme.txt elektro.png diff --git a/elektro/src/__init__.py b/elektro/src/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/elektro/src/elektro.png b/elektro/src/elektro.png new file mode 100644 index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D6v+LLLMedNbU+Y6(h8ex5u}p-`ZQ zKuPmZxFiye2$CYgQ$JFF`c5(_JJj>dKR$nB!-jEjFJ??xw`1lV9*35PF1xS)RFOQBQ{m8?J=DV1ZAY>7l9=0M^zbIxx){cqWePlNyY z`v>ojk4v5$6D8BD4R$#D{6RmAPlwZW&}@K==nTc5e*N7Z-XI9vAFe`q<>ks%Dg`R! zK}AeBffHj zq4MP2$34|UvCO#xPOd|^6uD?ZvQ_NC1r~vbA^D;i86V#b>=A@QHwu%+PFg)_I7W&} ziLY#S9%E{4KCgOm9Ms=?bMaUu{n zw-_8zW=5+o_;%{|-wNVl<6hdZQ3h{EFUh#2&HLdtVbpE2SuAkJh8vNoWYdnyW9OUi zKJW*F&%zPP#W2*ca*?V4woO#@lcYp}Aqa=S2zi^lzI`LfDIzOqexiFdu0=g zk001?*>ADgDvBW=#t$z*bT+Rl4EKR6+-bY00S zZb9OgEGk%BP>_!R#DtW}Bl8}UA|o8=#w>kP>%P!UbU7vw6jBtjvghGnH8scWHk%C) zmST&&^wDTOe|z|& zrf7HN+6v^PwA>Cl`}Om2l9e;3tN*p?^+k&d6v~1E)bL7W-u(H1K^$y0*x<~XH7jf9 zi6*#u{nT?K1t777Uw-lDH&%}yH$18E>mN@|)K{)GtTg~+zkPq*;S)c;JGj}0&b$?& s{Oi?41q+nQ1@I^p^HI+ONU2c%5AJw@*%;4ELjV8(07*qoM6N<$g8H06O#lD@ literal 0 HcmV?d00001 diff --git a/elektro/src/plugin.py b/elektro/src/plugin.py new file mode 100644 index 0000000..9ad38e9 --- /dev/null +++ b/elektro/src/plugin.py @@ -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 = """ + + + + + + + + + + + """ + + 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 = """ """ + + 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 index 0000000..6821d08 --- /dev/null +++ b/elektro/src/readme.txt @@ -0,0 +1,230 @@ +==================================================== +Elektro Power Save for Dreambox 7025 +Version 1 & 2 by gutemine +Version 3 by Morty +==================================================== +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 -- 2.7.4