[tuxdroid-svn] r5324 - in software_suite_v3/software/plugin/plugin-battery/trunk: executables reso
Status: Beta
Brought to you by:
ks156
|
From: gwadavel <c2m...@c2...> - 2009-09-03 13:03:42
|
Author: gwadavel
Date: 2009-09-03 15:03:26 +0200 (Thu, 03 Sep 2009)
New Revision: 5324
Modified:
software_suite_v3/software/plugin/plugin-battery/trunk/executables/plugin-battery.py
software_suite_v3/software/plugin/plugin-battery/trunk/resources/en.po
software_suite_v3/software/plugin/plugin-battery/trunk/resources/fr.po
software_suite_v3/software/plugin/plugin-battery/trunk/resources/plugin.pot
software_suite_v3/software/plugin/plugin-battery/trunk/resources/plugin.xml
Log:
use {0} for throwMessage
Modified: software_suite_v3/software/plugin/plugin-battery/trunk/executables/plugin-battery.py
===================================================================
--- software_suite_v3/software/plugin/plugin-battery/trunk/executables/plugin-battery.py 2009-09-03 12:18:14 UTC (rev 5323)
+++ software_suite_v3/software/plugin/plugin-battery/trunk/executables/plugin-battery.py 2009-09-03 13:03:26 UTC (rev 5324)
@@ -40,38 +40,12 @@
from util.SimplePlugin.SimplePluginConfiguration import SimplePluginConfiguration
from util.SimplePlugin.SimplePlugin import SimplePlugin
-
-class Configuration(SimplePluginConfiguration):
- """This class make an access to the plugin parameters.
- Parameters are automatically filled by the SimplePlugin class at plugin
- starting.
- """
-
- def __init__(self):
- """Initialization of the class.
- It's necessary to initialize the values because the type of the python
- variables is set by value assignation. If we don't initialize the
- parameters the simple plugin class can't check and validate the values
- passed by the plugins server through the os environment variables.
- """
- # Call the super class
- SimplePluginConfiguration.__init__(self)
- # Initialize the parameters
-
- self.__enumState = ""
-
- def getEnumState(self):
- return self.__enumState
-
- def setEnumState(self, enumState):
- self.__enumState = enumState
-
-
class Battery(object):
"""
Manage the battery.
"""
+ tgp_language = "en"
tgp_ip = "127.0.0.1"
tgp_port = 270
tux = TuxAPI("127.0.0.1", 270)
@@ -81,7 +55,10 @@
'''
self.plugin = plug
- # Test ip, port
+ # Test language, ip, port
+ if "tgp_language" in os.environ:
+ self.tgp_language = os.environ["tgp_language"]
+
if "tgp_ip" in os.environ:
self.tgp_ip = os.environ["tgp_ip"]
@@ -128,26 +105,11 @@
if not self.tux.radio.getConnected():
plugin.throwTrace("I can't find my fish. Please, make sure I'm connected.")
else:
- level = self.getLevel()
- state = self.getState()
- message = "the battery level is %1.2f it state is %s" %(level, state)
- plugin.throwMessage(message)
-
+ plugin.throwMessage("The battery level is {0}", "%1.2f"%self.getLevel())
+ plugin.throwMessage("The battery state is {0}", self.getState())
self.stop()
- def check(self):
- """
- """
- if self.tuxConnect():
-
- if not self.tux.radio.getConnected():
- plugin.throwTrace("I can't find my fish. Please, make sure I'm connected.")
- else:
- state = self.getState()
- self.tux.access.release()
- return state
-
def stop(self):
"""
"""
@@ -168,35 +130,19 @@
# Call the super class
SimplePlugin.__init__(self)
self.sbattery = Battery(self)
+
def start(self):
"""Plugin entry point.
This method should be used to dispatch commands.
"""
- if self.getCommand() == "run":
- self.run()
- elif self.getCommand() == "check":
- self.check()
- else:
- self.run()
+ self.run()
def run(self):
"""Plugin entry point for the "run" command.
"""
self.sbattery.start()
- def check(self):
- """Plugin entry point for the "check" command.
- """
- # Check if battery state == battery state to check
- print self.sbattery.check()
- print self.configuration().getEnumState()
- if self.sbattery.check() == self.configuration().getEnumState():
- checkResult = True
- # Return the check result
- self.throwResult(checkResult)
- self.throwMessage("Battery state is %s" %self.sbattery.getState())
-
def onPluginStop(self):
"""Callback on plugin stop.
"""
@@ -205,4 +151,4 @@
if __name__ == "__main__":
plugin = BatteryPlugin()
- plugin.boot(sys.argv[1:], Configuration())
+ plugin.boot(sys.argv[1:], SimplePluginConfiguration())
Modified: software_suite_v3/software/plugin/plugin-battery/trunk/resources/en.po
===================================================================
--- software_suite_v3/software/plugin/plugin-battery/trunk/resources/en.po 2009-09-03 12:18:14 UTC (rev 5323)
+++ software_suite_v3/software/plugin/plugin-battery/trunk/resources/en.po 2009-09-03 13:03:26 UTC (rev 5324)
@@ -7,3 +7,20 @@
msgid "Says the battery level and it state"
msgstr "Says the battery level and it state"
+msgid "The battery level is {0}"
+msgstr "The battery level is {0}"
+
+msgid "The battery state is {0}"
+msgstr "The battery state is {0}"
+
+msgid "EMPTY"
+msgstr "empty"
+
+msgid "LOW"
+msgstr "low"
+
+msgid "HIGH"
+msgstr "high"
+
+msgid "FULL"
+msgstr "full"
Modified: software_suite_v3/software/plugin/plugin-battery/trunk/resources/fr.po
===================================================================
--- software_suite_v3/software/plugin/plugin-battery/trunk/resources/fr.po 2009-09-03 12:18:14 UTC (rev 5323)
+++ software_suite_v3/software/plugin/plugin-battery/trunk/resources/fr.po 2009-09-03 13:03:26 UTC (rev 5324)
@@ -7,3 +7,20 @@
msgid "Says the battery level and it state"
msgstr "Indique le niveau de la batterie et son etat"
+msgid "The battery level is {0}"
+msgstr "Le niveau de batterie est de {0}"
+
+msgid "The battery state is {0}"
+msgstr "La batterie est {0}"
+
+msgid "EMPTY"
+msgstr "vide"
+
+msgid "LOW"
+msgstr "faible"
+
+msgid "HIGH"
+msgstr "haute"
+
+msgid "FULL"
+msgstr "pleine"
Modified: software_suite_v3/software/plugin/plugin-battery/trunk/resources/plugin.pot
===================================================================
--- software_suite_v3/software/plugin/plugin-battery/trunk/resources/plugin.pot 2009-09-03 12:18:14 UTC (rev 5323)
+++ software_suite_v3/software/plugin/plugin-battery/trunk/resources/plugin.pot 2009-09-03 13:03:26 UTC (rev 5324)
@@ -7,3 +7,20 @@
msgid "Says the battery level and it state"
msgstr ""
+msgid "The battery level is {0}"
+msgstr ""
+
+msgid "The battery state is {0}"
+msgstr ""
+
+msgid "EMPTY"
+msgstr ""
+
+msgid "LOW"
+msgstr ""
+
+msgid "HIGH"
+msgstr ""
+
+msgid "FULL"
+msgstr ""
Modified: software_suite_v3/software/plugin/plugin-battery/trunk/resources/plugin.xml
===================================================================
--- software_suite_v3/software/plugin/plugin-battery/trunk/resources/plugin.xml 2009-09-03 12:18:14 UTC (rev 5323)
+++ software_suite_v3/software/plugin/plugin-battery/trunk/resources/plugin.xml 2009-09-03 13:03:26 UTC (rev 5324)
@@ -14,50 +14,12 @@
<uuid>868a9389-01a9-4a8c-b63e-68414d154798</uuid>
<platform>all</platform>
</description>
- <parameters>
- <parameter
- name="enumState"
- description="Battery state to Check"
- type="enum(FULL,HIGH,LOW,EMPTY)"
- defaultValue="LOW"
- platform="all"/>
- </parameters>
<commands>
<command
name="run"
description="Says the battery level and it state"
daemon="false" />
- <command
- name="check"
- description="Check battery state"
- daemon="false" />
</commands>
<tasks>
- <task
- name="My checker"
- description="Check battery state every x minutes"
- command="check"
- type="every x"
- activated="false"
-
- weekMask="true,false,false,false,false,false,false"
- weekMaskType="exclusive"
- weekMaskVisible="true"
-
- date="0000/00/00"
- dateVisible="false"
-
- hoursBegin="00:00:00"
- hoursBeginMask="true,true,false"
- hoursBeginVisible="true"
-
- hoursEnd="23:59:00"
- hoursEndMask="true,true,false"
- hoursEndVisible="true"
-
- delay="00:01:00"
- delayMask="false,true,false"
- delayVisible="true"
- />
</tasks>
</plugin>
|