[tuxdroid-svn] r5311 - in software_suite_v3/software/plugin/plugin-battery/trunk: executables reso
Status: Beta
Brought to you by:
ks156
|
From: gwadavel <c2m...@c2...> - 2009-08-18 15:19:12
|
Author: gwadavel
Date: 2009-08-18 17:18:42 +0200 (Tue, 18 Aug 2009)
New Revision: 5311
Modified:
software_suite_v3/software/plugin/plugin-battery/trunk/executables/plugin-battery.py
software_suite_v3/software/plugin/plugin-battery/trunk/resources/fr.po
software_suite_v3/software/plugin/plugin-battery/trunk/resources/plugin.xml
Log:
add check command
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-08-14 14:31:02 UTC (rev 5310)
+++ software_suite_v3/software/plugin/plugin-battery/trunk/executables/plugin-battery.py 2009-08-18 15:18:42 UTC (rev 5311)
@@ -40,12 +40,38 @@
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)
@@ -55,10 +81,7 @@
'''
self.plugin = plug
- # Test language, ip, port
- if "tgp_language" in os.environ:
- self.tgp_language = os.environ["tgp_language"]
-
+ # Test ip, port
if "tgp_ip" in os.environ:
self.tgp_ip = os.environ["tgp_ip"]
@@ -103,7 +126,7 @@
if self.tuxConnect():
if not self.tux.radio.getConnected():
- plugin.throwTrace("I can't find my fish. Please, make sure I'm connected.")
+ plugin.throwTrace("I can't find my fish. Please, make sure I'm connected.")
else:
level = self.getLevel()
state = self.getState()
@@ -112,7 +135,19 @@
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):
"""
"""
@@ -133,19 +168,35 @@
# 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.
"""
- self.run()
+ if self.getCommand() == "run":
+ self.run()
+ elif self.getCommand() == "check":
+ self.check()
+ else:
+ 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.
"""
@@ -154,4 +205,4 @@
if __name__ == "__main__":
plugin = BatteryPlugin()
- plugin.boot(sys.argv[1:], SimplePluginConfiguration())
+ plugin.boot(sys.argv[1:], Configuration())
Modified: software_suite_v3/software/plugin/plugin-battery/trunk/resources/fr.po
===================================================================
--- software_suite_v3/software/plugin/plugin-battery/trunk/resources/fr.po 2009-08-14 14:31:02 UTC (rev 5310)
+++ software_suite_v3/software/plugin/plugin-battery/trunk/resources/fr.po 2009-08-18 15:18:42 UTC (rev 5311)
@@ -1,9 +1,9 @@
msgid "Battery Level"
-msgstr ""
+msgstr "Niveau de la batterie"
msgid "Says battery level"
-msgstr ""
+msgstr "Indique le niveau de la batterie"
msgid "Says the battery level and it state"
-msgstr ""
+msgstr "Indique le niveau de la batterie et son etat"
Modified: software_suite_v3/software/plugin/plugin-battery/trunk/resources/plugin.xml
===================================================================
--- software_suite_v3/software/plugin/plugin-battery/trunk/resources/plugin.xml 2009-08-14 14:31:02 UTC (rev 5310)
+++ software_suite_v3/software/plugin/plugin-battery/trunk/resources/plugin.xml 2009-08-18 15:18:42 UTC (rev 5311)
@@ -14,12 +14,50 @@
<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>
|