tux-droid-svn Mailing List for Tux Droid CE (Page 56)
Status: Beta
Brought to you by:
ks156
You can subscribe to this list here.
| 2007 |
Jan
|
Feb
(32) |
Mar
(108) |
Apr
(71) |
May
(38) |
Jun
(128) |
Jul
(1) |
Aug
(14) |
Sep
(77) |
Oct
(104) |
Nov
(90) |
Dec
(71) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2008 |
Jan
(81) |
Feb
(18) |
Mar
(40) |
Apr
(102) |
May
(151) |
Jun
(74) |
Jul
(151) |
Aug
(257) |
Sep
(447) |
Oct
(379) |
Nov
(404) |
Dec
(430) |
| 2009 |
Jan
(173) |
Feb
(236) |
Mar
(519) |
Apr
(300) |
May
(112) |
Jun
(232) |
Jul
(314) |
Aug
(58) |
Sep
(203) |
Oct
(293) |
Nov
(26) |
Dec
(109) |
| 2010 |
Jan
(19) |
Feb
(25) |
Mar
(33) |
Apr
(1) |
May
|
Jun
(3) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: jerome <c2m...@c2...> - 2009-05-15 08:01:40
|
Author: jerome Date: 2009-05-15 10:01:26 +0200 (Fri, 15 May 2009) New Revision: 4655 Removed: software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/n.po Log: * Removed a bad translation file. Deleted: software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/n.po =================================================================== --- software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/n.po 2009-05-15 07:59:14 UTC (rev 4654) +++ software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/n.po 2009-05-15 08:01:26 UTC (rev 4655) @@ -1 +0,0 @@ - |
|
From: jerome <c2m...@c2...> - 2009-05-15 07:59:28
|
Author: jerome Date: 2009-05-15 09:59:14 +0200 (Fri, 15 May 2009) New Revision: 4654 Modified: software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/help_en.html software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/help_es.html software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/help_fr.html software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/help_nl.html Log: * Updated all html files with updated template. Modified: software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/help_en.html =================================================================== --- software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/help_en.html 2009-05-15 07:37:26 UTC (rev 4653) +++ software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/help_en.html 2009-05-15 07:59:14 UTC (rev 4654) @@ -1,6 +1,6 @@ <html> <body> - <font size="3" face="Verdana, Arial, Helvetica, sans-serif">The Max Light gadget will make Tux Droid rotate towards the brightest light source. Drag-and-drop the gadget into "My Favorites" to enable it. Also, make sure to unplug the charger so Tux Droid can spin while searching for the light source. <br> + <font size="2" face="Verdana, Arial, Helvetica, sans-serif">The Max Light gadget will make Tux Droid rotate towards the brightest light source. Drag-and-drop the gadget into "My Favorites" to enable it. Also, make sure to unplug the charger so Tux Droid can spin while searching for the light source. <br> </font> </body> </html> \ No newline at end of file Modified: software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/help_es.html =================================================================== --- software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/help_es.html 2009-05-15 07:37:26 UTC (rev 4653) +++ software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/help_es.html 2009-05-15 07:59:14 UTC (rev 4654) @@ -1,6 +1,6 @@ <html> <body> - <font size="3" face="Verdana, Arial, Helvetica, sans-serif">El gadget de Luz Maxima hará que Tux Droid gire hacia la fuente de luz mas brillante. Arrastre el gadget dentro de 'Mis Favoritos' para activarlo. Asegurese tambien de desconectar el cargador para que Tux Droid pueda girar en busca de la fuente de luz. <br> + <font size="2" face="Verdana, Arial, Helvetica, sans-serif">El gadget de Luz Maxima hará que Tux Droid gire hacia la fuente de luz mas brillante. Arrastre el gadget dentro de 'Mis Favoritos' para activarlo. Asegurese tambien de desconectar el cargador para que Tux Droid pueda girar en busca de la fuente de luz. <br> </font> </body> </html> \ No newline at end of file Modified: software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/help_fr.html =================================================================== --- software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/help_fr.html 2009-05-15 07:37:26 UTC (rev 4653) +++ software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/help_fr.html 2009-05-15 07:59:14 UTC (rev 4654) @@ -1,6 +1,6 @@ <html> <body> - <font size="3" face="Verdana, Arial, Helvetica, sans-serif">Le gadget lumière maximum fait tourner Tux Droid pour trouver l'endroit le plus lumineux. Copiez-Collez le gadget dans "Mes Favoris" pour l'utiliser. Assurez vous d'avoir déconnecté le chargeur pour que Tux Droid puisse tourner. <br> + <font size="2" face="Verdana, Arial, Helvetica, sans-serif">Le gadget lumière maximum fait tourner Tux Droid pour trouver l'endroit le plus lumineux. Copiez-Collez le gadget dans "Mes Favoris" pour l'utiliser. Assurez vous d'avoir déconnecté le chargeur pour que Tux Droid puisse tourner. <br> </font> </body> </html> \ No newline at end of file Modified: software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/help_nl.html =================================================================== --- software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/help_nl.html 2009-05-15 07:37:26 UTC (rev 4653) +++ software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/help_nl.html 2009-05-15 07:59:14 UTC (rev 4654) @@ -1,6 +1,6 @@ <html> <body> - <font size="3" face="Verdana, Arial, Helvetica, sans-serif">De Max Light gadget zal Tux Droid laten draaien in de richting van de helderste lichtbron. Sleep de gadget in "Mijn favorieten" om het te activeren. Vergeet niet de oplader los te koppelen zodat Tux Droid kan ronddraaien om de lichtbron te zoeken. <br> + <font size="2" face="Verdana, Arial, Helvetica, sans-serif">De Max Light gadget zal Tux Droid laten draaien in de richting van de helderste lichtbron. Sleep de gadget in "Mijn favorieten" om het te activeren. Vergeet niet de oplader los te koppelen zodat Tux Droid kan ronddraaien om de lichtbron te zoeken. <br> </font> </body> </html> \ No newline at end of file |
|
From: jerome <c2m...@c2...> - 2009-05-15 07:37:42
|
Author: jerome Date: 2009-05-15 09:37:26 +0200 (Fri, 15 May 2009) New Revision: 4653 Modified: software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/help.html Log: * Fixed font size. Modified: software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/help.html =================================================================== --- software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/help.html 2009-05-14 13:36:16 UTC (rev 4652) +++ software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/help.html 2009-05-15 07:37:26 UTC (rev 4653) @@ -1,6 +1,6 @@ <html> <body> -<font size="3" face="Verdana, Arial, Helvetica, sans-serif">The Max Light gadget will make Tux Droid rotate towards the brightest light source. +<font size="2" face="Verdana, Arial, Helvetica, sans-serif">The Max Light gadget will make Tux Droid rotate towards the brightest light source. Drag-and-drop the gadget into "My Favorites" to enable it. Also, make sure to unplug the charger so Tux Droid can spin while searching for the light source. <br> </font> |
|
From: jerome <c2m...@c2...> - 2009-05-14 14:11:54
|
Author: jerome Date: 2009-05-14 15:36:16 +0200 (Thu, 14 May 2009) New Revision: 4652 Modified: software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/en.po software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/es.po software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/fr.po software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/nl.po Log: * Translated a new string. Modified: software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/en.po =================================================================== --- software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/en.po 2009-05-12 09:45:58 UTC (rev 4651) +++ software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/en.po 2009-05-14 13:36:16 UTC (rev 4652) @@ -1,6 +1,6 @@ msgid "" -msgstr "Project-Id-Version: PACKAGE VERSION\nReport-Msgid-Bugs-To: \nPOT-Creation-Date: 2009-04-24 10:01+0200\nPO-Revision-Date: 2009-04-24 10:03+0200\nLast-Translator: jerome <jer...@ky...>\nLanguage-Team: LANGUAGE <LL...@li...>\nLanguage: en\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\nPlural-Forms: nplurals=2; plural=(n != 1);\nX-Generator: Pootle 1.2.1\n" +msgstr "Project-Id-Version: PACKAGE VERSION\nReport-Msgid-Bugs-To: \nPOT-Creation-Date: 2009-05-12 11:58+0200\nPO-Revision-Date: 2009-05-12 11:59+0200\nLast-Translator: jerome <jer...@ky...>\nLanguage-Team: LANGUAGE <LL...@li...>\nLanguage: en\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\nPlural-Forms: nplurals=2; plural=(n != 1);\nX-Generator: Pootle 1.2.1\n" msgid "Max Light Gadget" msgstr "Max Light Gadget" @@ -14,6 +14,12 @@ msgid "Unplug my charger first and try again." msgstr "Unplug my charger first and try again." +msgid "Sorry, I'm not sure where the light is coming from" +msgstr "Sorry, I'm not sure where the light is coming from" + +msgid "I can't find my fish. Please, make sure I'm connected." +msgstr "I can't find my fish. Please, make sure I'm connected." + msgid "Looking for the brightest light source" msgstr "Looking for the brightest light source" Modified: software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/es.po =================================================================== --- software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/es.po 2009-05-12 09:45:58 UTC (rev 4651) +++ software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/es.po 2009-05-14 13:36:16 UTC (rev 4652) @@ -1,6 +1,6 @@ msgid "" -msgstr "Project-Id-Version: PACKAGE VERSION\nReport-Msgid-Bugs-To: \nPOT-Creation-Date: 2009-04-24 10:01+0200\nPO-Revision-Date: 2009-04-24 13:20+0200\nLast-Translator: Santiago Perez <san...@gm...>\nLanguage-Team: LANGUAGE <LL...@li...>\nLanguage: es\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\nPlural-Forms: nplurals=2; plural=(n != 1);\nX-Generator: Pootle 1.2.1\n" +msgstr "Project-Id-Version: PACKAGE VERSION\nReport-Msgid-Bugs-To: \nPOT-Creation-Date: 2009-05-12 11:58+0200\nPO-Revision-Date: 2009-05-14 14:46+0200\nLast-Translator: jerome <jer...@ky...>\nLanguage-Team: LANGUAGE <LL...@li...>\nLanguage: es\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\nPlural-Forms: nplurals=2; plural=(n != 1);\nX-Generator: Pootle 1.2.1\n" msgid "Max Light Gadget" msgstr "Gadget Luz Maxima" @@ -14,6 +14,12 @@ msgid "Unplug my charger first and try again." msgstr "Desconecte primero mi cargador e intentelo de nuevo." +msgid "Sorry, I'm not sure where the light is coming from" +msgstr "Lo sentimos, no estoy seguro de que la luz proviene" + +msgid "I can't find my fish. Please, make sure I'm connected." +msgstr "" + msgid "Looking for the brightest light source" msgstr "Buscando la fuente de luz mas brillante." Modified: software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/fr.po =================================================================== --- software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/fr.po 2009-05-12 09:45:58 UTC (rev 4651) +++ software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/fr.po 2009-05-14 13:36:16 UTC (rev 4652) @@ -1,6 +1,6 @@ msgid "" -msgstr "Project-Id-Version: PACKAGE VERSION\nReport-Msgid-Bugs-To: \nPOT-Creation-Date: 2009-04-24 10:01+0200\nPO-Revision-Date: 2009-04-24 10:08+0200\nLast-Translator: jerome <jer...@ky...>\nLanguage-Team: LANGUAGE <LL...@li...>\nLanguage: fr\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\nPlural-Forms: nplurals=2; plural=(n > 1);\nX-Generator: Pootle 1.2.1\n" +msgstr "Project-Id-Version: PACKAGE VERSION\nReport-Msgid-Bugs-To: \nPOT-Creation-Date: 2009-05-12 11:58+0200\nPO-Revision-Date: 2009-05-12 12:04+0200\nLast-Translator: jerome <jer...@ky...>\nLanguage-Team: LANGUAGE <LL...@li...>\nLanguage: fr\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\nPlural-Forms: nplurals=2; plural=(n > 1);\nX-Generator: Pootle 1.2.1\n" msgid "Max Light Gadget" msgstr "Gadget lumière maximum" @@ -14,6 +14,12 @@ msgid "Unplug my charger first and try again." msgstr "Débranchez mon chargeur et essayez à nouveau." +msgid "Sorry, I'm not sure where the light is coming from" +msgstr "Désolé, je n'arrive pas à déterminer d'où vient la lumière." + +msgid "I can't find my fish. Please, make sure I'm connected." +msgstr "Je ne trouve pas mon poisson, assurez vous que je soit connecté." + msgid "Looking for the brightest light source" msgstr "Je cherche l'endroit le plus lumineux." Modified: software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/nl.po =================================================================== --- software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/nl.po 2009-05-12 09:45:58 UTC (rev 4651) +++ software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/nl.po 2009-05-14 13:36:16 UTC (rev 4652) @@ -1,9 +1,9 @@ msgid "" -msgstr "Project-Id-Version: PACKAGE VERSION\nReport-Msgid-Bugs-To: \nPOT-Creation-Date: 2009-04-24 10:01+0200\nPO-Revision-Date: 2009-04-24 10:18+0200\nLast-Translator: Sebastiaan Vanpoucke <se...@ky...>\nLanguage-Team: LANGUAGE <LL...@li...>\nLanguage: nl\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\nPlural-Forms: nplurals=2; plural=(n != 1);\nX-Generator: Pootle 1.2.1\n" +msgstr "Project-Id-Version: PACKAGE VERSION\nReport-Msgid-Bugs-To: \nPOT-Creation-Date: 2009-05-12 11:58+0200\nPO-Revision-Date: 2009-05-12 15:40+0200\nLast-Translator: Sebastiaan Vanpoucke <se...@ky...>\nLanguage-Team: LANGUAGE <LL...@li...>\nLanguage: nl\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\nPlural-Forms: nplurals=2; plural=(n != 1);\nX-Generator: Pootle 1.2.1\n" msgid "Max Light Gadget" -msgstr "Max Light Gadget" +msgstr "Max Licht Gadget" msgid "The Max Light gadget will make Tux Droid rotate towards the direction of the brightest light source." msgstr "De Max Light gadget zal Tux Droid laten draaien in de richting van de helderste lichtbron." @@ -14,6 +14,12 @@ msgid "Unplug my charger first and try again." msgstr "Koppel eerst de oplader los en probeer dan opnieuw." +msgid "Sorry, I'm not sure where the light is coming from" +msgstr "Sorry, ik kan de lichtbron niet vinden" + +msgid "I can't find my fish. Please, make sure I'm connected." +msgstr "Ik kan mijn vis niet zien. Gelieve te controleren of de vis geconnecteerd is" + msgid "Looking for the brightest light source" msgstr "Ik ben nu aan het zoeken naar de helderste lichtbron." |
|
From: jerome <c2m...@c2...> - 2009-05-12 09:46:05
|
Author: jerome Date: 2009-05-12 11:45:58 +0200 (Tue, 12 May 2009) New Revision: 4651 Modified: software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/gadget.pot Log: * Updated new string. Modified: software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/gadget.pot =================================================================== --- software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/gadget.pot 2009-05-07 10:26:46 UTC (rev 4650) +++ software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/gadget.pot 2009-05-12 09:45:58 UTC (rev 4651) @@ -10,7 +10,7 @@ msgid "Unplug my charger first and try again." msgstr "" -msgid "Sorry I'm not sure where the most of the light is coming from" +msgid "Sorry, I'm not sure where the light is coming from" msgstr "" msgid "I can't find my fish. Please, make sure I'm connected." |
|
From: jerome <c2m...@c2...> - 2009-05-07 10:27:04
|
Author: jerome
Date: 2009-05-07 12:26:46 +0200 (Thu, 07 May 2009)
New Revision: 4650
Modified:
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/tuxdroid-gadget-maxlight.py
Log:
* Updated delays between two statuses requests.
Modified: software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/tuxdroid-gadget-maxlight.py
===================================================================
--- software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/tuxdroid-gadget-maxlight.py 2009-05-07 09:55:43 UTC (rev 4649)
+++ software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/tuxdroid-gadget-maxlight.py 2009-05-07 10:26:46 UTC (rev 4650)
@@ -85,7 +85,7 @@
'''
Start tux spinning.
'''
- tux.spinning.leftOn(4.0, speed = SPV_SLOW);
+ tux.spinning.leftOn(2.0, speed = SPV_SLOW);
@@ -101,7 +101,7 @@
thread.start()
# wait Tux began to turn
- sleep(1.0)
+ sleep(1.5)
isTurning = tux.status.requestOne(ST_NAME_SPIN_LEFT_MOTOR_ON)[0]
@@ -114,7 +114,7 @@
lum = float(tux.status.requestOne('light_level')[0]) # Light
- sleep(0.25)
+ sleep(0.1)
if lum > l_max: # Light Max ?
l_max = lum // 1
@@ -131,17 +131,18 @@
monitor gadget for TuxDroid V1 Tux turn a little, wait and turn while light < light max
'''
brk = False
+ l_stop = l_stop - 4.0 #Because of Windblows.
while 1:
tux.spinning.leftOnDuring(0.1, speed=SPV_VERYSLOW)
- sleep(0.4)
+ sleep(1.0)
lum = float(tux.status.requestOne('light_level')[0])
if lum >= l_stop:
tux.spinning.off()
break
- if (int(time()) - currentTime) >= 20:
+ if (int(time()) - currentTime) >= 30:
GadgetHelper.throwMessage("Sorry I'm not sure where the most of the light is coming from")
tux.spinning.off()
brk = True
|
|
From: jerome <c2m...@c2...> - 2009-05-07 09:55:52
|
Author: jerome
Date: 2009-05-07 11:55:43 +0200 (Thu, 07 May 2009)
New Revision: 4649
Modified:
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/tuxdroid-gadget-maxlight.py
Log:
* Fixed a dummy bug.
Modified: software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/tuxdroid-gadget-maxlight.py
===================================================================
--- software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/tuxdroid-gadget-maxlight.py 2009-05-07 08:19:30 UTC (rev 4648)
+++ software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/tuxdroid-gadget-maxlight.py 2009-05-07 09:55:43 UTC (rev 4649)
@@ -67,10 +67,8 @@
from tuxisalive.api import *
from time import sleep, time
from GadgetHelper import GadgetHelper
-import threading
+import threading
-currentTime = 0;
-
def tuxConnect():
'''
Wait connected
@@ -132,6 +130,7 @@
Tux stop when it finds light up Modified by ks156 who wrote light
monitor gadget for TuxDroid V1 Tux turn a little, wait and turn while light < light max
'''
+ brk = False
while 1:
tux.spinning.leftOnDuring(0.1, speed=SPV_VERYSLOW)
@@ -143,12 +142,13 @@
break
if (int(time()) - currentTime) >= 20:
- throwMessage("Sorry I'm not sure where the most of the light is coming from")
- break;
+ GadgetHelper.throwMessage("Sorry I'm not sure where the most of the light is coming from")
+ tux.spinning.off()
+ brk = True
+ break
- currentTime = int(time())
-
- GadgetHelper.throwMessage("I think most of the light is coming from this direction.")
+ if not brk:
+ GadgetHelper.throwMessage("I think most of the light is coming from this direction.")
tgp_language = "en"
@@ -181,8 +181,7 @@
tux.eyes.open()
tux.flippers.up()
light = search() # search light up
- currentTime = int(time())
- stop(light, currentTime) # stop
+ stop(light, int(time())) # stop
tux.flippers.down()
tux.access.release()
|
|
From: jerome <c2m...@c2...> - 2009-05-07 08:19:35
|
Author: jerome
Date: 2009-05-07 10:19:30 +0200 (Thu, 07 May 2009)
New Revision: 4648
Modified:
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/tuxdroid-gadget-maxlight.py
Log:
* Removed a print.
Modified: software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/tuxdroid-gadget-maxlight.py
===================================================================
--- software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/tuxdroid-gadget-maxlight.py 2009-05-07 08:13:22 UTC (rev 4647)
+++ software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/tuxdroid-gadget-maxlight.py 2009-05-07 08:19:30 UTC (rev 4648)
@@ -177,7 +177,6 @@
elif not ( tux.status.requestOne('charger_state')[0] == 'UNPLUGGED' ) :
GadgetHelper.throwMessage("Unplug my charger first and try again.")
else:
- start = int(time())
GadgetHelper.throwMessage("Looking for the brightest light source")
tux.eyes.open()
tux.flippers.up()
@@ -185,8 +184,6 @@
currentTime = int(time())
stop(light, currentTime) # stop
tux.flippers.down()
- stop = int(time())
- print( stop - start )
tux.access.release()
tux.server.disconnect()
|
|
From: jerome <c2m...@c2...> - 2009-05-07 08:13:29
|
Author: jerome
Date: 2009-05-07 10:13:22 +0200 (Thu, 07 May 2009)
New Revision: 4647
Modified:
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/tuxdroid-gadget-maxlight.py
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/gadget.pot
Log:
*Added a 20 seconds delay if the research takes too times
Modified: software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/tuxdroid-gadget-maxlight.py
===================================================================
--- software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/tuxdroid-gadget-maxlight.py 2009-05-06 15:24:20 UTC (rev 4646)
+++ software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/tuxdroid-gadget-maxlight.py 2009-05-07 08:13:22 UTC (rev 4647)
@@ -121,7 +121,6 @@
if lum > l_max: # Light Max ?
l_max = lum // 1
- sleep(0.25)
mutex.release()
return l_max # Return Light Max
@@ -133,21 +132,19 @@
Tux stop when it finds light up Modified by ks156 who wrote light
monitor gadget for TuxDroid V1 Tux turn a little, wait and turn while light < light max
'''
- tux.spinning.leftOnAsync(0.25, speed=SPV_VERYSLOW)
- sleep(1)
-
while 1:
- tux.spinning.leftOnDuring(0.1, speed=1)
- sleep(0.3)
+ tux.spinning.leftOnDuring(0.1, speed=SPV_VERYSLOW)
+ sleep(0.4)
lum = float(tux.status.requestOne('light_level')[0])
if lum >= l_stop:
tux.spinning.off()
break
- #if (int(time()) - currentTime) >= 15:
- #break;
+ if (int(time()) - currentTime) >= 20:
+ throwMessage("Sorry I'm not sure where the most of the light is coming from")
+ break;
currentTime = int(time())
@@ -180,6 +177,7 @@
elif not ( tux.status.requestOne('charger_state')[0] == 'UNPLUGGED' ) :
GadgetHelper.throwMessage("Unplug my charger first and try again.")
else:
+ start = int(time())
GadgetHelper.throwMessage("Looking for the brightest light source")
tux.eyes.open()
tux.flippers.up()
@@ -187,6 +185,8 @@
currentTime = int(time())
stop(light, currentTime) # stop
tux.flippers.down()
+ stop = int(time())
+ print( stop - start )
tux.access.release()
tux.server.disconnect()
Modified: software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/gadget.pot
===================================================================
--- software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/gadget.pot 2009-05-06 15:24:20 UTC (rev 4646)
+++ software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/gadget.pot 2009-05-07 08:13:22 UTC (rev 4647)
@@ -10,6 +10,9 @@
msgid "Unplug my charger first and try again."
msgstr ""
+msgid "Sorry I'm not sure where the most of the light is coming from"
+msgstr ""
+
msgid "I can't find my fish. Please, make sure I'm connected."
msgstr ""
|
|
From: jerome <c2m...@c2...> - 2009-05-06 15:24:34
|
Author: jerome
Date: 2009-05-06 17:24:20 +0200 (Wed, 06 May 2009)
New Revision: 4646
Modified:
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/tuxdroid-gadget-maxlight.py
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/gadget.pot
Log:
* improved the light research.
Modified: software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/tuxdroid-gadget-maxlight.py
===================================================================
--- software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/tuxdroid-gadget-maxlight.py 2009-05-06 10:33:45 UTC (rev 4645)
+++ software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/tuxdroid-gadget-maxlight.py 2009-05-06 15:24:20 UTC (rev 4646)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
@@ -33,16 +33,16 @@
- Test if tgp_ip and tgp_port exist
2008/10/03 - version 0.4:
- - Add TTS + Internalization TTS
+ - Add TTS + Internalization TTS
2008/10/03 - version 0.3.1:
- - Add charger test
+ - Add charger test
2008/10/03 - version 0.3:
- - Function stop modified by ks156
+ - Function stop modified by ks156
2008/10/02 - version 0.2:
- - add DEBUG
+ - add DEBUG
2008/10/02 - version 0.1:
- Initial version
@@ -67,44 +67,68 @@
from tuxisalive.api import *
from time import sleep, time
from GadgetHelper import GadgetHelper
-
+import threading
+currentTime = 0;
+
def tuxConnect():
'''
Wait connected
'''
tux.server.autoConnect(CLIENT_LEVEL_RESTRICTED, 'TuxMaxLight', 'tuxdroid-gadget-maxlight')
- tux.server.waitConnected(10.0)
- tux.dongle.waitConnected(10.0)
- tux.radio.waitConnected(10.0)
- return tux.access.waitAcquire(10.0, ACCESS_PRIORITY_NORMAL)
+ tux.server.waitConnected(5.0)
+ tux.dongle.waitConnected(5.0)
+ tux.radio.waitConnected(5.0)
+ return tux.access.waitAcquire(5.0, ACCESS_PRIORITY_NORMAL)
+
+def startSpinning():
+ '''
+ Start tux spinning.
+ '''
+ tux.spinning.leftOn(4.0, speed = SPV_SLOW);
+
def search():
- '''
+ '''
Search maximum light
'''
- l_max = 0 # Light Max
- tux.spinning.leftOnAsync(2.0, speed = SPV_NORMAL)
-
- # Turn on left 2 turns, asynchrone mode
- sleep(1) # wait Tux began to turn
-
- while tux.spinning.getLeftMovingState():
- # While tux spins
- lum = float(tux.status.requestOne('light_level')[0]) # Light
-
- if lum > l_max: # Light Max ?
- l_max = lum // 1
-
- return l_max # Return Light Max
+ l_max = 0 # Light Max
+
+ # Turn on left 2 turns, asynchrone mode
+ thread = threading.Thread(target = startSpinning, args = [])
+ thread.start()
+
+ # wait Tux began to turn
+ sleep(1.0)
+
+ isTurning = tux.status.requestOne(ST_NAME_SPIN_LEFT_MOTOR_ON)[0]
+
+ mutex = threading.Lock()
+
+ while isTurning == "True":
+
+ mutex.acquire()
+ isTurning = tux.status.requestOne(ST_NAME_SPIN_LEFT_MOTOR_ON)[0]
+
+ lum = float(tux.status.requestOne('light_level')[0]) # Light
+
+ sleep(0.25)
+
+ if lum > l_max: # Light Max ?
+ l_max = lum // 1
+
+ sleep(0.25)
+ mutex.release()
+
+ return l_max # Return Light Max
+
-
-def stop(l_stop):
+def stop(l_stop, currentTime):
'''
Tux stop when it finds light up Modified by ks156 who wrote light
monitor gadget for TuxDroid V1 Tux turn a little, wait and turn while light < light max
@@ -113,21 +137,26 @@
sleep(1)
while 1:
- print(time())
+
tux.spinning.leftOnDuring(0.1, speed=1)
sleep(0.3)
lum = float(tux.status.requestOne('light_level')[0])
-
+
if lum >= l_stop:
tux.spinning.off()
break
+ #if (int(time()) - currentTime) >= 15:
+ #break;
+
+ currentTime = int(time())
+
GadgetHelper.throwMessage("I think most of the light is coming from this direction.")
tgp_language = "en"
tgp_ip = "127.0.0.1"
-tgp_port = 270
+tgp_port = 270
if "tgp_language" in os.environ:
@@ -155,7 +184,8 @@
tux.eyes.open()
tux.flippers.up()
light = search() # search light up
- stop(light) # stop
+ currentTime = int(time())
+ stop(light, currentTime) # stop
tux.flippers.down()
tux.access.release()
Modified: software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/gadget.pot
===================================================================
--- software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/gadget.pot 2009-05-06 10:33:45 UTC (rev 4645)
+++ software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/gadget.pot 2009-05-06 15:24:20 UTC (rev 4646)
@@ -11,6 +11,7 @@
msgstr ""
msgid "I can't find my fish. Please, make sure I'm connected."
+msgstr ""
msgid "Looking for the brightest light source"
msgstr ""
|
|
From: jerome <c2m...@c2...> - 2009-05-06 10:33:58
|
Author: jerome
Date: 2009-05-06 12:33:45 +0200 (Wed, 06 May 2009)
New Revision: 4645
Modified:
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/tuxdroid-gadget-maxlight.py
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/gadget.pot
Log:
* Added a tts message when radio is not detected.
Modified: software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/tuxdroid-gadget-maxlight.py
===================================================================
--- software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/tuxdroid-gadget-maxlight.py 2009-05-05 14:46:45 UTC (rev 4644)
+++ software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/tuxdroid-gadget-maxlight.py 2009-05-06 10:33:45 UTC (rev 4645)
@@ -65,7 +65,7 @@
import locale
import gettext
from tuxisalive.api import *
-from time import sleep
+from time import sleep, time
from GadgetHelper import GadgetHelper
@@ -109,12 +109,11 @@
Tux stop when it finds light up Modified by ks156 who wrote light
monitor gadget for TuxDroid V1 Tux turn a little, wait and turn while light < light max
'''
-
tux.spinning.leftOnAsync(0.25, speed=SPV_VERYSLOW)
-
sleep(1)
while 1:
+ print(time())
tux.spinning.leftOnDuring(0.1, speed=1)
sleep(0.3)
lum = float(tux.status.requestOne('light_level')[0])
@@ -145,17 +144,19 @@
if tuxConnect():
+ if not tux.radio.getConnected():
+ GadgetHelper.throwMessage("I can't find my fish. Please, make sure I'm connected.")
+
# Test if charger are plugged
- if tux.status.requestOne('charger_state')[0] == 'UNPLUGGED':
+ elif not ( tux.status.requestOne('charger_state')[0] == 'UNPLUGGED' ) :
+ GadgetHelper.throwMessage("Unplug my charger first and try again.")
+ else:
GadgetHelper.throwMessage("Looking for the brightest light source")
tux.eyes.open()
tux.flippers.up()
light = search() # search light up
stop(light) # stop
tux.flippers.down()
-
- else:
- GadgetHelper.throwMessage("Unplug my charger first and try again.")
tux.access.release()
tux.server.disconnect()
Modified: software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/gadget.pot
===================================================================
--- software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/gadget.pot 2009-05-05 14:46:45 UTC (rev 4644)
+++ software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/gadget.pot 2009-05-06 10:33:45 UTC (rev 4645)
@@ -10,6 +10,8 @@
msgid "Unplug my charger first and try again."
msgstr ""
+msgid "I can't find my fish. Please, make sure I'm connected."
+
msgid "Looking for the brightest light source"
msgstr ""
|
|
From: remi <c2m...@c2...> - 2009-05-05 14:46:58
|
Author: remi Date: 2009-05-05 16:46:45 +0200 (Tue, 05 May 2009) New Revision: 4644 Added: software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/builder/PluginPackager.py software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/executables/plugin-skeleton.py Removed: software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/builder/GadgetPackager.py software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/executables/tux-gadget-skeleton.py Modified: software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/build.py software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/resources/plugin.xml Log: * fixed terminology "gadget" -> "plugin" in the python plugin skeleton Modified: software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/build.py =================================================================== --- software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/build.py 2009-05-05 14:33:22 UTC (rev 4643) +++ software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/build.py 2009-05-05 14:46:45 UTC (rev 4644) @@ -5,7 +5,7 @@ # Distributed under the terms of the GNU General Public License # http://www.gnu.org/copyleft/gpl.html -from builder.GadgetPackager import GadgetPackager +from builder.PluginPackager import PluginPackager if __name__ == "__main__": - GadgetPackager().createTgf("tuxdroid-gadget-pySkeleton.tpg") + PluginPackager().createScp("plugin-pySkeleton.scp") Deleted: software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/builder/GadgetPackager.py =================================================================== --- software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/builder/GadgetPackager.py 2009-05-05 14:33:22 UTC (rev 4643) +++ software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/builder/GadgetPackager.py 2009-05-05 14:46:45 UTC (rev 4644) @@ -1,78 +0,0 @@ -# -*- coding: utf-8 -*- - -import version -__author__ = version.author -__date__ = version.date -__version__ = version.version -__licence__ = version.licence -del version - -# Copyleft (C) 2009 C2ME Sa -# Remi Jocaille <rem...@c2...> -# Distributed under the terms of the GNU General Public License -# http://www.gnu.org/copyleft/gpl.html - -import os -from zipfile import * - -from util.misc.DirectoriesAndFilesTools import * - -# ------------------------------------------------------------------------------ -# Class to create a TGF file from the main directory of a python gadget project. -# ------------------------------------------------------------------------------ -class GadgetPackager(object): - """Class to create a TGF file from the main directory of a python gadget - project. - """ - - # -------------------------------------------------------------------------- - # Create a tgf file. - # -------------------------------------------------------------------------- - def createTgf(self, tgfFileName): - """Create a tgf file. - @param tgfFileName: Tux Gadget Format file name. - @return: The success of the file creation. - """ - self.__sourcePath = os.path.realpath("") - if not os.path.isdir(self.__sourcePath): - return False - if not os.path.isdir(os.path.join(self.__sourcePath, "executables")): - return False - if not os.path.isdir(os.path.join(self.__sourcePath, "resources")): - return False - # Get some paths - SRC_EXECUTABLES_PATH = os.path.join(self.__sourcePath, "executables") - SRC_RESOURCES_PATH = os.path.join(self.__sourcePath, "resources") - TMP_BUILD_PATH = os.path.join(self.__sourcePath, "tmp") - DEST_EXECUTABLES_PATH = os.path.join(TMP_BUILD_PATH, "executables") - DEST_RESOURCES_PATH = os.path.join(TMP_BUILD_PATH, "resources") - DEST_TGF_FILENAME = os.path.join(self.__sourcePath, tgfFileName) - # Create the temporary build path - MKDirsF(TMP_BUILD_PATH) - # Copy "executables" directory - CPDir(SRC_EXECUTABLES_PATH, DEST_EXECUTABLES_PATH) - # Copy "resources" directory - CPDir(SRC_RESOURCES_PATH, DEST_RESOURCES_PATH) - # Filtering the content of temporary path - RMWithFilters(TMP_BUILD_PATH, filters = ['.svn', '.pyc']) - # Create a zip file - directory = TMP_BUILD_PATH - last_cwd = os.getcwd() - os.chdir(TMP_BUILD_PATH) - zf = ZipFile(DEST_TGF_FILENAME, 'w', compression = ZIP_DEFLATED) - def walker(zip, directory, files, root = directory): - for file in files: - file = os.path.join(directory, file) - name = file[len(TMP_BUILD_PATH) + 1:] - if os.path.isfile(file): - zip.write(file, name, ZIP_DEFLATED) - elif os.path.isdir(file): - file = os.path.join(file, "") - name = os.path.join(name, "") - zip.writestr(name, name) - os.path.walk(TMP_BUILD_PATH, walker, zf) - zf.close() - os.chdir(os.path.abspath(last_cwd)) - # Remove the temporary directory - RMDirs(TMP_BUILD_PATH) - return True Copied: software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/builder/PluginPackager.py (from rev 4620, software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/builder/GadgetPackager.py) =================================================================== --- software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/builder/PluginPackager.py (rev 0) +++ software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/builder/PluginPackager.py 2009-05-05 14:46:45 UTC (rev 4644) @@ -0,0 +1,78 @@ +# -*- coding: utf-8 -*- + +import version +__author__ = version.author +__date__ = version.date +__version__ = version.version +__licence__ = version.licence +del version + +# Copyleft (C) 2009 C2ME Sa +# Remi Jocaille <rem...@c2...> +# Distributed under the terms of the GNU General Public License +# http://www.gnu.org/copyleft/gpl.html + +import os +from zipfile import * + +from util.misc.DirectoriesAndFilesTools import * + +# ------------------------------------------------------------------------------ +# Class to create a SCP file from the main directory of a python plugin project. +# ------------------------------------------------------------------------------ +class PluginPackager(object): + """Class to create a SCP file from the main directory of a python plugin + project. + """ + + # -------------------------------------------------------------------------- + # Create a scp file. + # -------------------------------------------------------------------------- + def createScp(self, scpFileName): + """Create a scp file. + @param scpFileName: Smart-Core Plugin file name. + @return: The success of the file creation. + """ + self.__sourcePath = os.path.realpath("") + if not os.path.isdir(self.__sourcePath): + return False + if not os.path.isdir(os.path.join(self.__sourcePath, "executables")): + return False + if not os.path.isdir(os.path.join(self.__sourcePath, "resources")): + return False + # Get some paths + SRC_EXECUTABLES_PATH = os.path.join(self.__sourcePath, "executables") + SRC_RESOURCES_PATH = os.path.join(self.__sourcePath, "resources") + TMP_BUILD_PATH = os.path.join(self.__sourcePath, "tmp") + DEST_EXECUTABLES_PATH = os.path.join(TMP_BUILD_PATH, "executables") + DEST_RESOURCES_PATH = os.path.join(TMP_BUILD_PATH, "resources") + DEST_SCP_FILENAME = os.path.join(self.__sourcePath, scpFileName) + # Create the temporary build path + MKDirsF(TMP_BUILD_PATH) + # Copy "executables" directory + CPDir(SRC_EXECUTABLES_PATH, DEST_EXECUTABLES_PATH) + # Copy "resources" directory + CPDir(SRC_RESOURCES_PATH, DEST_RESOURCES_PATH) + # Filtering the content of temporary path + RMWithFilters(TMP_BUILD_PATH, filters = ['.svn', '.pyc']) + # Create a zip file + directory = TMP_BUILD_PATH + last_cwd = os.getcwd() + os.chdir(TMP_BUILD_PATH) + zf = ZipFile(DEST_SCP_FILENAME, 'w', compression = ZIP_DEFLATED) + def walker(zip, directory, files, root = directory): + for file in files: + file = os.path.join(directory, file) + name = file[len(TMP_BUILD_PATH) + 1:] + if os.path.isfile(file): + zip.write(file, name, ZIP_DEFLATED) + elif os.path.isdir(file): + file = os.path.join(file, "") + name = os.path.join(name, "") + zip.writestr(name, name) + os.path.walk(TMP_BUILD_PATH, walker, zf) + zf.close() + os.chdir(os.path.abspath(last_cwd)) + # Remove the temporary directory + RMDirs(TMP_BUILD_PATH) + return True Copied: software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/executables/plugin-skeleton.py (from rev 4620, software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/executables/tux-gadget-skeleton.py) =================================================================== --- software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/executables/plugin-skeleton.py (rev 0) +++ software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/executables/plugin-skeleton.py 2009-05-05 14:46:45 UTC (rev 4644) @@ -0,0 +1,146 @@ +# -*- coding: utf-8 -*- + +# Copyright (C) 2009 Kysoh Sa +# Remi Jocaille <rem...@c2...> +# Distributed under the terms of the GNU General Public License +# http://www.gnu.org/copyleft/gpl.html + +__author__ = "Kysoh" +__appname__ = "Python plugin skeleton" +__version__ = "0.0.1" +__date__ = "2009/05/05" +__license__ = "GPL" + +import os +import time +import sys + +sys.path.append(os.environ['TUXDROID_SERVER_PYTHON_UTIL']) + +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.__stringParam = "" + self.__integerParam = 0 + self.__booleanParam = False + self.__enumeratedParam = "" + self.__linuxParam = "" + self.__windowsParam = "" + + def getStringParam(self): + return self.__stringParam + + def setStringParam(self, stringParam): + self.__stringParam = stringParam + + def getIntegerParam(self): + return self.__integerParam + + def setIntegerParam(self, integerParam): + self.__integerParam = integerParam + + def getBooleanParam(self): + return self.__booleanParam + + def setBooleanParam(self, booleanParam): + self.__booleanParam = booleanParam + + def getEnumeratedParam(self): + return self.__enumeratedParam + + def setEnumeratedParam(self, enumeratedParam): + self.__enumeratedParam = enumeratedParam + + def getLinuxParam(self): + return self.__linuxParam + + def setLinuxParam(self, linuxParam): + self.__linuxParam = linuxParam + + def getWindowsParam(self): + return self.__windowsParam + + def setWindowsParam(self, windowsParam): + self.__windowsParam = windowsParam + + +class SkeletonPlugin(SimplePlugin): + """This class override the SimplePlugin class to make easy + the plugin coding. + """ + + def __init__(self): + """Initialization of the class. + """ + # Call the super class + SimplePlugin.__init__(self) + # Initialize some values ... + self.__daemonRun = False + + def start(self): + """Plugin entry point. + This method should be used to dispatch commands. + """ + if self.getCommand() == "run": + self.run() + elif self.getCommand() == "run_daemon": + self.runDaemon() + elif self.getCommand() == "check": + self.check() + else: + self.run() + + def run(self): + """Plugin entry point for the "run" command. + """ + if self.isWindows(): + self.throwMessage(self.configuration().getWindowsParam()) + else: + self.throwMessage(self.configuration().getLinuxParam()) + self.throwMessage("I finished my work ...") + + def runDaemon(self): + """Plugin entry point for the "run_daemon" command. + """ + # Start a fake daemon loop ... + # Warning the daemonRun flag is not safe-thread (in order to have a + # clean code in this plugin example) + self.__daemonRun = True + while self.__daemonRun: + time.sleep(0.5) + + def check(self): + """Plugin entry point for the "check" command. + """ + # Check a condition ... + # For example get the value of the parameter "booleanParam" + checkResult = self.configuration().getBooleanParam() + # Return the check result + self.throwResult(checkResult) + self.throwMessage("I throwed my result, so I can die. RIP ...") + + def onPluginStop(self): + """Callback on plugin stop. + """ + # Stop the fake daemon loop + self.__daemonRun = False + +if __name__ == "__main__": + plugin = SkeletonPlugin() + plugin.boot(sys.argv[1:], Configuration()) Deleted: software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/executables/tux-gadget-skeleton.py =================================================================== --- software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/executables/tux-gadget-skeleton.py 2009-05-05 14:33:22 UTC (rev 4643) +++ software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/executables/tux-gadget-skeleton.py 2009-05-05 14:46:45 UTC (rev 4644) @@ -1,146 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (C) 2009 Kysoh Sa -# Remi Jocaille <rem...@c2...> -# Distributed under the terms of the GNU General Public License -# http://www.gnu.org/copyleft/gpl.html - -__author__ = "Kysoh" -__appname__ = "Python gadget skeleton" -__version__ = "0.0.1" -__date__ = "2009/03/31" -__license__ = "GPL" - -import os -import time -import sys - -sys.path.append(os.environ['TUXDROID_SERVER_PYTHON_UTIL']) - -from util.SimpleGadget.SimpleGadgetConfiguration import SimpleGadgetConfiguration -from util.SimpleGadget.SimpleGadget import SimpleGadget - -class Configuration(SimpleGadgetConfiguration): - """This class make an access to the gadget parameters. - Parameters are automatically filled by the SimpleGadget class at gadget - 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 gadget class can't check and validate the values - passed by the framework through the os environment variables. - """ - # Call the super class - SimpleGadgetConfiguration.__init__(self) - # Initialize the parameters - self.__stringParam = "" - self.__integerParam = 0 - self.__booleanParam = False - self.__enumeratedParam = "" - self.__linuxParam = "" - self.__windowsParam = "" - - def getStringParam(self): - return self.__stringParam - - def setStringParam(self, stringParam): - self.__stringParam = stringParam - - def getIntegerParam(self): - return self.__integerParam - - def setIntegerParam(self, integerParam): - self.__integerParam = integerParam - - def getBooleanParam(self): - return self.__booleanParam - - def setBooleanParam(self, booleanParam): - self.__booleanParam = booleanParam - - def getEnumeratedParam(self): - return self.__enumeratedParam - - def setEnumeratedParam(self, enumeratedParam): - self.__enumeratedParam = enumeratedParam - - def getLinuxParam(self): - return self.__linuxParam - - def setLinuxParam(self, linuxParam): - self.__linuxParam = linuxParam - - def getWindowsParam(self): - return self.__windowsParam - - def setWindowsParam(self, windowsParam): - self.__windowsParam = windowsParam - - -class SkeletonGadget(SimpleGadget): - """This class override the SimpleGadget class to make easy - the gadget coding. - """ - - def __init__(self): - """Initialization of the class. - """ - # Call the super class - SimpleGadget.__init__(self) - # Initialize some values ... - self.__daemonRun = False - - def start(self): - """Gadget entry point. - This method should be used to dispatch commands. - """ - if self.getCommand() == "run": - self.run() - elif self.getCommand() == "run_daemon": - self.runDaemon() - elif self.getCommand() == "check": - self.check() - else: - self.run() - - def run(self): - """Gadget entry point for the "run" command. - """ - if self.isWindows(): - self.throwMessage(self.configuration().getWindowsParam()) - else: - self.throwMessage(self.configuration().getLinuxParam()) - self.throwMessage("I finished my work ...") - - def runDaemon(self): - """Gadget entry point for the "run_daemon" command. - """ - # Start a fake daemon loop ... - # Warning the daemonRun flag is not safe-thread (in order to have a - # clean code in this gadget example) - self.__daemonRun = True - while self.__daemonRun: - time.sleep(0.5) - - def check(self): - """Gadget entry point for the "check" command. - """ - # Check a condition ... - # For example get the value of the parameter "booleanParam" - checkResult = self.configuration().getBooleanParam() - # Return the check result - self.throwResult(checkResult) - self.throwMessage("I throwed my result, so I can die. RIP ...") - - def onGadgetStop(self): - """Callback on gadget stop. - """ - # Stop the fake daemon loop - self.__daemonRun = False - -if __name__ == "__main__": - gadget = SkeletonGadget() - gadget.boot(sys.argv[1:], Configuration()) Modified: software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/resources/plugin.xml =================================================================== --- software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/resources/plugin.xml 2009-05-05 14:33:22 UTC (rev 4643) +++ software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/resources/plugin.xml 2009-05-05 14:46:45 UTC (rev 4644) @@ -1,7 +1,7 @@ <plugin> <interpreter kind="python"> - <executable>executables/tux-gadget-skeleton.py</executable> + <executable>executables/plugin-skeleton.py</executable> </interpreter> <description> <name>Python plugin skeleton</name> |
|
From: remi <c2m...@c2...> - 2009-05-05 14:33:39
|
Author: remi Date: 2009-05-05 16:33:22 +0200 (Tue, 05 May 2009) New Revision: 4643 Added: software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/SimplePlugin.py software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/SimplePluginConfiguration.py Removed: software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/SimpleGadget.py software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/SimpleGadgetConfiguration.py Log: * fixed terminology "gadget" -> "plugin" in the classe names Deleted: software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/SimpleGadget.py =================================================================== --- software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/SimpleGadget.py 2009-05-05 14:32:13 UTC (rev 4642) +++ software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/SimpleGadget.py 2009-05-05 14:33:22 UTC (rev 4643) @@ -1,394 +0,0 @@ -# -*- coding: latin1 -*- - -import version -__author__ = version.author -__date__ = version.date -__version__ = version.version -__licence__ = version.licence -del version - -# Copyright (C) 2009 C2ME Sa -# Remi Jocaille <rem...@c2...> -# Distributed under the terms of the GNU General Public License -# http://www.gnu.org/copyleft/gpl.html -# -# This module is a portage of the java package write by "Yoran Brault" -# "com.kysoh.tuxdroid.gadget.framework.gadget" - -import os -import sys -import traceback -import random -import platform -import threading -import time - -ENVIRONEMENT_PREFIX = "tgp_" - -# ------------------------------------------------------------------------------ -# This class is the base class helper for builder python plugins. -# ------------------------------------------------------------------------------ -class SimplePlugin(object): - """This class is the base class helper for builder python plugins. - """ - - # -------------------------------------------------------------------------- - # Constructor of the class. - # -------------------------------------------------------------------------- - def __init__(self): - """Constructor of the class. - """ - self.__configuration = None - self.__command = None - self.__runMutex = threading.Lock() - self.__run = False - self.__stdInThread = None - - # -------------------------------------------------------------------------- - # On plugin stop event. Must be overrided - # -------------------------------------------------------------------------- - def onPluginStop(self): - """On plugin stop event. Must be overrided - """ - pass - - # -------------------------------------------------------------------------- - # Stop the plugin. - # -------------------------------------------------------------------------- - def stop(self): - """Stop the plugin. - """ - if self.__stdInThread != None: - if self.__stdInThread.isAlive(): - self.__stdInThread._Thread__stop() - self.onPluginStop() - self.throwNotification("plugin", "exit") - - # -------------------------------------------------------------------------- - # Set the run flag value. - # -------------------------------------------------------------------------- - def __setRun(self, value): - """Set the run flag value. - @param value: Flag value. <True|False> - """ - self.__runMutex.acquire() - self.__run = value - self.__runMutex.release() - - # -------------------------------------------------------------------------- - # Get the run flag value. - # -------------------------------------------------------------------------- - def __getRun(self): - """Get the run flag value. - @return: True or False. - """ - self.__runMutex.acquire() - result = self.__run - self.__runMutex.release() - return result - - # -------------------------------------------------------------------------- - # Stdin polling loop. - # -------------------------------------------------------------------------- - def __stdInLoop(self): - """Stdin polling loop. - """ - while self.__getRun(): - line = sys.stdin.readline() - if line.lower().find("stop") == 0: - self.onPluginStop() - self.__setRun(False) - time.sleep(0.1) - - # -------------------------------------------------------------------------- - # Get the configuration object. - # -------------------------------------------------------------------------- - def configuration(self): - """Get the configuration object. - @return: A SimplePluginConfiguration object. - """ - return self.__configuration - - # -------------------------------------------------------------------------- - # Get the command of the gagdet. - # -------------------------------------------------------------------------- - def getCommand(self): - """Get the command of the gagdet. - @return: A string. - """ - return self.__command - - # -------------------------------------------------------------------------- - # Set the command of the gagdet. - # -------------------------------------------------------------------------- - def setCommand(self, command): - """Set the command of the gagdet. - @param command: The command of the gagdet. - """ - self.__command = command - - # -------------------------------------------------------------------------- - # Get if the platform is Windows or not. - # -------------------------------------------------------------------------- - def isWindows(self): - """Get if the platform is Windows or not. - @return: A boolean. - """ - platformName = platform.system().lower() - return (platformName == "microsoft") or (platformName == "windows") - - # -------------------------------------------------------------------------- - # Load the environement data to the plugin parameters. - # -------------------------------------------------------------------------- - def __loadEnvironementData(self): - """Load the environement data to the plugin parameters. - """ - if self.__configuration == None: - return - # Extract configuration object class names - baseConfClassName = "_SimplePluginConfiguration" - confClassName = str(self.__configuration.__class__) - confClassName = confClassName.split("'")[1].split(".")[1] - confClassName = "_" + confClassName - # Filtering the fields of the configuration object - confFields = dir(self.__configuration) - filteredFileds = [] - for field in confFields: - if field.find(baseConfClassName) == 0: - filteredFileds.append([field[len(baseConfClassName):].lower(), - field]) - if field.find(confClassName) == 0: - filteredFileds.append([field[len(confClassName):].lower(), - field]) - # Fill the configuration parameters with the environement values - self.throwTrace("Loading environement") - for key in os.environ: - fKey = key.lower() - if fKey.find(ENVIRONEMENT_PREFIX) == 0: - environName = fKey[len(ENVIRONEMENT_PREFIX):] - for field in filteredFileds: - if field[0][2:] == environName: - # Get the value in the configuration object - paramName = field[1] - paramValue = getattr(self.__configuration, paramName) - paramType = str(type(paramValue)) - paramType = paramType.split("'")[1] - # Get the value in the os environ - environValue = os.environ[key] - self.throwTrace(" " + field[0][2:] + ":" + environValue); - # Check parameters type - if paramType == 'str': - pass - elif paramType == 'int': - try: - environValue = int(environValue) - except: - # Environ value type not match with the parameter - self.throwError("", True) - continue - elif paramType == 'float': - try: - environValue = float(environValue) - except: - # Environ value type not match with the parameter - self.throwError("", True) - continue - elif paramType == 'bool': - if environValue == "true": - environValue = True - else: - environValue = False - else: - # Unknow parameter type - self.throwError("Unknow parameter type (%s)" % paramType) - continue - # Set the environment value to the parameter - setattr(self.__configuration, paramName, environValue) - - # -------------------------------------------------------------------------- - # Starting point of the plugin. - # -------------------------------------------------------------------------- - def boot(self, arguments, configuration): - """Starting point of the plugin. - @param arguments: - """ - try: - if len(arguments) > 0: - self.__command = arguments[0] - self.__configuration = configuration - self.__loadEnvironementData() - self.__setRun(True) - if self.__configuration.isDaemon(): - self.__stdInThread = threading.Thread( - target = self.__stdInLoop) - self.__stdInThread.start() - self.start() - if not self.__configuration.isDaemon(): - self.onPluginStop() - except: - self.throwError("Error on plugin boot", True) - - # -------------------------------------------------------------------------- - # Start method of the plugin. Must be overrided. - # -------------------------------------------------------------------------- - def start(self): - """Start method of the plugin. (Must be overrided) - """ - pass - - # -------------------------------------------------------------------------- - # Get the full path of a file located in the "state" directory of a deployed - # plugin. - # -------------------------------------------------------------------------- - def __getStateFile(self, fileName): - """Get the full path of a file located in the "state" directory of a - deployed plugin. - @param fileName: Base file name. - @return: A full file path. - """ - path = "states" - if not os.path.isdir(path): - try: - os.makedirs(path) - except: - return None - return os.path.join(path, fileName) - - # -------------------------------------------------------------------------- - # Read a serialized object from a file. - # -------------------------------------------------------------------------- - def readState(self, fileName): - """Read a serialized object from a file. - @param fileName: File name of the serialized object. - @return: An object or None if fail. - """ - sessionFile = self.__getStateFile(fileName) - if sessionFile == None: - return None - if not os.path.isfile(sessionFile): - return None - try: - f = open(sessionFile, "r") - state = eval(f.read()) - f.close() - except: - return None - return state - - # -------------------------------------------------------------------------- - # Write a file with a serialized object. - # -------------------------------------------------------------------------- - def writeState(self, myObject, fileName): - """Write a file with a serialized object. - @param myObject: Object to serialize. - @param fileName: File name of the serialized object. - """ - sessionFile = self.__getStateFile(fileName) - try: - f = open(sessionFile, "w") - f.write(str(myObject)) - f.close() - except: - pass - - # -------------------------------------------------------------------------- - # Write a pid file. - # -------------------------------------------------------------------------- - def writePid(self, pid): - """Write a pid file. - @param pid: Process id. - """ - fileName = str(random.random()).replace('.', '') + ".pid" - sessionFile = self.__getStateFile(fileName) - try: - f = open(sessionFile, "w") - f.write(str(pid)) - f.close() - except: - pass - - # -------------------------------------------------------------------------- - # Throw a generic notification to the framework. - # -------------------------------------------------------------------------- - def throwNotification(self, messageId, *args): - """Throw a generic notification to the framework. - @param messageId: Message Id. - @param args: List of objects. - """ - stringBuffer = messageId - for arg in args: - stringBuffer += " '" - stringBuffer += str(arg).replace("'", "\\'") - stringBuffer += "'" - sys.stdout.write(stringBuffer + "\n") - sys.stdout.flush() - - # -------------------------------------------------------------------------- - # Throw a message to the framework. - # -------------------------------------------------------------------------- - def throwMessage(self, content, *args): - """Throw a message to the framework. - @param content: Content of the message. - @param args: Arguments for the message. - """ - tmp = [content,] - for arg in args: - tmp.append(arg) - self.throwNotification("message", *tmp) - - # -------------------------------------------------------------------------- - # Throw a trace message to the framework. - # -------------------------------------------------------------------------- - def throwTrace(self, message): - """Throw a trace message to the framework. - @param message: Throwed message. - """ - if not self.__configuration.isTraces(): - return - self.throwNotification("trace", message) - - # -------------------------------------------------------------------------- - # Throw the result of the "check" command to the framework. - # -------------------------------------------------------------------------- - def throwResult(self, result): - """Throw the result of the "check" command to the framework. - @param result: A boolean. - """ - if result: - resultValue = "true" - else: - resultValue = "false" - self.throwNotification("check_result", resultValue) - - # -------------------------------------------------------------------------- - # Throw an error message to the plugins server. - # -------------------------------------------------------------------------- - def throwError(self, message, force = False): - """Throw an error message to the plugins server. - @param message: Thowed message if the plugin don't want to be traced. - - if the plugin is traced, the traceback will be sent instead of the - message. - @param force: For to send the traceback. Default False. - """ - if not force: - if self.__configuration.isTraces(): - message = self.__formatException() - else: - message = self.__formatException() - message = message.split("\n") - self.throwNotification("error", *message) - - # -------------------------------------------------------------------------- - # Get the formated traceback of the last exception. - # -------------------------------------------------------------------------- - def __formatException(self): - """Get the formated traceback of the last exception. - @return: A string. - """ - fList = traceback.format_exception(sys.exc_info()[0], - sys.exc_info()[1], - sys.exc_info()[2]) - result = "" - for line in fList: - result += line - return result Deleted: software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/SimpleGadgetConfiguration.py =================================================================== --- software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/SimpleGadgetConfiguration.py 2009-05-05 14:32:13 UTC (rev 4642) +++ software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/SimpleGadgetConfiguration.py 2009-05-05 14:33:22 UTC (rev 4643) @@ -1,135 +0,0 @@ -# -*- coding: latin1 -*- - -import version -__author__ = version.author -__date__ = version.date -__version__ = version.version -__licence__ = version.licence -del version - -# Copyright (C) 2009 C2ME Sa -# Remi Jocaille <rem...@c2...> -# Distributed under the terms of the GNU General Public License -# http://www.gnu.org/copyleft/gpl.html -# -# This module is a portage of the java package write by "Yoran Brault" -# "com.kysoh.tuxdroid.gadget.framework.gadget" - -# ------------------------------------------------------------------------------ -# Class of the default plugin configuration. -# ------------------------------------------------------------------------------ -class SimplePluginConfiguration(object): - """Class of the default plugin configuration. - """ - - # -------------------------------------------------------------------------- - # Constructor of the class. - # -------------------------------------------------------------------------- - def __init__(self): - """Constructor of the class. - """ - self.__traces = True - self.__pitch = 100 - self.__language = "en" - self.__country = "US" - self.__locutor = "Ryan" - self.__daemon = False - - # -------------------------------------------------------------------------- - # Get the pitch value. - # -------------------------------------------------------------------------- - def getPitch(self): - """Get the pitch value. - @return: An integer. - """ - return self.__pitch - - # -------------------------------------------------------------------------- - # Set the pitch value. - # -------------------------------------------------------------------------- - def setPitch(self, pitch): - """Set the pitch value. - @param pitch: The pitch. - """ - self.__pitch = pitch - - # -------------------------------------------------------------------------- - # Get the language. - # -------------------------------------------------------------------------- - def getLanguage(self): - """Get the language. - @return: A string. - """ - return self.__language - - # -------------------------------------------------------------------------- - # Set the language. - # -------------------------------------------------------------------------- - def setLanguage(self, language): - """Set the language. - @param language: The language. - """ - self.__language = language - - # -------------------------------------------------------------------------- - # Get the country. - # -------------------------------------------------------------------------- - def getCountry(self): - """Get the country. - @return: A string. - """ - return self.__country - - # -------------------------------------------------------------------------- - # Set the country. - # -------------------------------------------------------------------------- - def setCountry(self, country): - """Set the country. - @param country: The country. - """ - self.__country = country - - # -------------------------------------------------------------------------- - # Get the locutor. - # -------------------------------------------------------------------------- - def getLocutor(self): - """Get the locutor. - @return: A string. - """ - return self.__locutor - - # -------------------------------------------------------------------------- - # Set the locutor. - # -------------------------------------------------------------------------- - def setLocutor(self, locutor): - """Set the locutor. - @param locutor: The locutor. - """ - self.__locutor = locutor - - # -------------------------------------------------------------------------- - # Get if the plugin is traced or not. - # -------------------------------------------------------------------------- - def isTraces(self): - """Get if the plugin is traced or not. - @return: A boolean. - """ - return self.__traces - - # -------------------------------------------------------------------------- - # Set if the plugin is traced or not. - # -------------------------------------------------------------------------- - def setTraces(self, traces): - """Set if the plugin is traced or not. - @param traces: Is traced or not. - """ - self.__traces = traces - - # -------------------------------------------------------------------------- - # Get if the plugin is a daemon or not. - # -------------------------------------------------------------------------- - def isDaemon(self): - """Get if the plugin is a daemon or not. - @return: A boolean. - """ - return self.__daemon Copied: software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/SimplePlugin.py (from rev 4642, software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/SimpleGadget.py) =================================================================== --- software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/SimplePlugin.py (rev 0) +++ software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/SimplePlugin.py 2009-05-05 14:33:22 UTC (rev 4643) @@ -0,0 +1,394 @@ +# -*- coding: latin1 -*- + +import version +__author__ = version.author +__date__ = version.date +__version__ = version.version +__licence__ = version.licence +del version + +# Copyright (C) 2009 C2ME Sa +# Remi Jocaille <rem...@c2...> +# Distributed under the terms of the GNU General Public License +# http://www.gnu.org/copyleft/gpl.html +# +# This module is a portage of the java package write by "Yoran Brault" +# "com.kysoh.tuxdroid.gadget.framework.gadget" + +import os +import sys +import traceback +import random +import platform +import threading +import time + +ENVIRONEMENT_PREFIX = "tgp_" + +# ------------------------------------------------------------------------------ +# This class is the base class helper for builder python plugins. +# ------------------------------------------------------------------------------ +class SimplePlugin(object): + """This class is the base class helper for builder python plugins. + """ + + # -------------------------------------------------------------------------- + # Constructor of the class. + # -------------------------------------------------------------------------- + def __init__(self): + """Constructor of the class. + """ + self.__configuration = None + self.__command = None + self.__runMutex = threading.Lock() + self.__run = False + self.__stdInThread = None + + # -------------------------------------------------------------------------- + # On plugin stop event. Must be overrided + # -------------------------------------------------------------------------- + def onPluginStop(self): + """On plugin stop event. Must be overrided + """ + pass + + # -------------------------------------------------------------------------- + # Stop the plugin. + # -------------------------------------------------------------------------- + def stop(self): + """Stop the plugin. + """ + if self.__stdInThread != None: + if self.__stdInThread.isAlive(): + self.__stdInThread._Thread__stop() + self.onPluginStop() + self.throwNotification("plugin", "exit") + + # -------------------------------------------------------------------------- + # Set the run flag value. + # -------------------------------------------------------------------------- + def __setRun(self, value): + """Set the run flag value. + @param value: Flag value. <True|False> + """ + self.__runMutex.acquire() + self.__run = value + self.__runMutex.release() + + # -------------------------------------------------------------------------- + # Get the run flag value. + # -------------------------------------------------------------------------- + def __getRun(self): + """Get the run flag value. + @return: True or False. + """ + self.__runMutex.acquire() + result = self.__run + self.__runMutex.release() + return result + + # -------------------------------------------------------------------------- + # Stdin polling loop. + # -------------------------------------------------------------------------- + def __stdInLoop(self): + """Stdin polling loop. + """ + while self.__getRun(): + line = sys.stdin.readline() + if line.lower().find("stop") == 0: + self.onPluginStop() + self.__setRun(False) + time.sleep(0.1) + + # -------------------------------------------------------------------------- + # Get the configuration object. + # -------------------------------------------------------------------------- + def configuration(self): + """Get the configuration object. + @return: A SimplePluginConfiguration object. + """ + return self.__configuration + + # -------------------------------------------------------------------------- + # Get the command of the gagdet. + # -------------------------------------------------------------------------- + def getCommand(self): + """Get the command of the gagdet. + @return: A string. + """ + return self.__command + + # -------------------------------------------------------------------------- + # Set the command of the gagdet. + # -------------------------------------------------------------------------- + def setCommand(self, command): + """Set the command of the gagdet. + @param command: The command of the gagdet. + """ + self.__command = command + + # -------------------------------------------------------------------------- + # Get if the platform is Windows or not. + # -------------------------------------------------------------------------- + def isWindows(self): + """Get if the platform is Windows or not. + @return: A boolean. + """ + platformName = platform.system().lower() + return (platformName == "microsoft") or (platformName == "windows") + + # -------------------------------------------------------------------------- + # Load the environement data to the plugin parameters. + # -------------------------------------------------------------------------- + def __loadEnvironementData(self): + """Load the environement data to the plugin parameters. + """ + if self.__configuration == None: + return + # Extract configuration object class names + baseConfClassName = "_SimplePluginConfiguration" + confClassName = str(self.__configuration.__class__) + confClassName = confClassName.split("'")[1].split(".")[1] + confClassName = "_" + confClassName + # Filtering the fields of the configuration object + confFields = dir(self.__configuration) + filteredFileds = [] + for field in confFields: + if field.find(baseConfClassName) == 0: + filteredFileds.append([field[len(baseConfClassName):].lower(), + field]) + if field.find(confClassName) == 0: + filteredFileds.append([field[len(confClassName):].lower(), + field]) + # Fill the configuration parameters with the environement values + self.throwTrace("Loading environement") + for key in os.environ: + fKey = key.lower() + if fKey.find(ENVIRONEMENT_PREFIX) == 0: + environName = fKey[len(ENVIRONEMENT_PREFIX):] + for field in filteredFileds: + if field[0][2:] == environName: + # Get the value in the configuration object + paramName = field[1] + paramValue = getattr(self.__configuration, paramName) + paramType = str(type(paramValue)) + paramType = paramType.split("'")[1] + # Get the value in the os environ + environValue = os.environ[key] + self.throwTrace(" " + field[0][2:] + ":" + environValue); + # Check parameters type + if paramType == 'str': + pass + elif paramType == 'int': + try: + environValue = int(environValue) + except: + # Environ value type not match with the parameter + self.throwError("", True) + continue + elif paramType == 'float': + try: + environValue = float(environValue) + except: + # Environ value type not match with the parameter + self.throwError("", True) + continue + elif paramType == 'bool': + if environValue == "true": + environValue = True + else: + environValue = False + else: + # Unknow parameter type + self.throwError("Unknow parameter type (%s)" % paramType) + continue + # Set the environment value to the parameter + setattr(self.__configuration, paramName, environValue) + + # -------------------------------------------------------------------------- + # Starting point of the plugin. + # -------------------------------------------------------------------------- + def boot(self, arguments, configuration): + """Starting point of the plugin. + @param arguments: + """ + try: + if len(arguments) > 0: + self.__command = arguments[0] + self.__configuration = configuration + self.__loadEnvironementData() + self.__setRun(True) + if self.__configuration.isDaemon(): + self.__stdInThread = threading.Thread( + target = self.__stdInLoop) + self.__stdInThread.start() + self.start() + if not self.__configuration.isDaemon(): + self.onPluginStop() + except: + self.throwError("Error on plugin boot", True) + + # -------------------------------------------------------------------------- + # Start method of the plugin. Must be overrided. + # -------------------------------------------------------------------------- + def start(self): + """Start method of the plugin. (Must be overrided) + """ + pass + + # -------------------------------------------------------------------------- + # Get the full path of a file located in the "state" directory of a deployed + # plugin. + # -------------------------------------------------------------------------- + def __getStateFile(self, fileName): + """Get the full path of a file located in the "state" directory of a + deployed plugin. + @param fileName: Base file name. + @return: A full file path. + """ + path = "states" + if not os.path.isdir(path): + try: + os.makedirs(path) + except: + return None + return os.path.join(path, fileName) + + # -------------------------------------------------------------------------- + # Read a serialized object from a file. + # -------------------------------------------------------------------------- + def readState(self, fileName): + """Read a serialized object from a file. + @param fileName: File name of the serialized object. + @return: An object or None if fail. + """ + sessionFile = self.__getStateFile(fileName) + if sessionFile == None: + return None + if not os.path.isfile(sessionFile): + return None + try: + f = open(sessionFile, "r") + state = eval(f.read()) + f.close() + except: + return None + return state + + # -------------------------------------------------------------------------- + # Write a file with a serialized object. + # -------------------------------------------------------------------------- + def writeState(self, myObject, fileName): + """Write a file with a serialized object. + @param myObject: Object to serialize. + @param fileName: File name of the serialized object. + """ + sessionFile = self.__getStateFile(fileName) + try: + f = open(sessionFile, "w") + f.write(str(myObject)) + f.close() + except: + pass + + # -------------------------------------------------------------------------- + # Write a pid file. + # -------------------------------------------------------------------------- + def writePid(self, pid): + """Write a pid file. + @param pid: Process id. + """ + fileName = str(random.random()).replace('.', '') + ".pid" + sessionFile = self.__getStateFile(fileName) + try: + f = open(sessionFile, "w") + f.write(str(pid)) + f.close() + except: + pass + + # -------------------------------------------------------------------------- + # Throw a generic notification to the framework. + # -------------------------------------------------------------------------- + def throwNotification(self, messageId, *args): + """Throw a generic notification to the framework. + @param messageId: Message Id. + @param args: List of objects. + """ + stringBuffer = messageId + for arg in args: + stringBuffer += " '" + stringBuffer += str(arg).replace("'", "\\'") + stringBuffer += "'" + sys.stdout.write(stringBuffer + "\n") + sys.stdout.flush() + + # -------------------------------------------------------------------------- + # Throw a message to the framework. + # -------------------------------------------------------------------------- + def throwMessage(self, content, *args): + """Throw a message to the framework. + @param content: Content of the message. + @param args: Arguments for the message. + """ + tmp = [content,] + for arg in args: + tmp.append(arg) + self.throwNotification("message", *tmp) + + # -------------------------------------------------------------------------- + # Throw a trace message to the framework. + # -------------------------------------------------------------------------- + def throwTrace(self, message): + """Throw a trace message to the framework. + @param message: Throwed message. + """ + if not self.__configuration.isTraces(): + return + self.throwNotification("trace", message) + + # -------------------------------------------------------------------------- + # Throw the result of the "check" command to the framework. + # -------------------------------------------------------------------------- + def throwResult(self, result): + """Throw the result of the "check" command to the framework. + @param result: A boolean. + """ + if result: + resultValue = "true" + else: + resultValue = "false" + self.throwNotification("check_result", resultValue) + + # -------------------------------------------------------------------------- + # Throw an error message to the plugins server. + # -------------------------------------------------------------------------- + def throwError(self, message, force = False): + """Throw an error message to the plugins server. + @param message: Thowed message if the plugin don't want to be traced. + - if the plugin is traced, the traceback will be sent instead of the + message. + @param force: For to send the traceback. Default False. + """ + if not force: + if self.__configuration.isTraces(): + message = self.__formatException() + else: + message = self.__formatException() + message = message.split("\n") + self.throwNotification("error", *message) + + # -------------------------------------------------------------------------- + # Get the formated traceback of the last exception. + # -------------------------------------------------------------------------- + def __formatException(self): + """Get the formated traceback of the last exception. + @return: A string. + """ + fList = traceback.format_exception(sys.exc_info()[0], + sys.exc_info()[1], + sys.exc_info()[2]) + result = "" + for line in fList: + result += line + return result Copied: software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/SimplePluginConfiguration.py (from rev 4642, software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/SimpleGadgetConfiguration.py) =================================================================== --- software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/SimplePluginConfiguration.py (rev 0) +++ software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/SimplePluginConfiguration.py 2009-05-05 14:33:22 UTC (rev 4643) @@ -0,0 +1,135 @@ +# -*- coding: latin1 -*- + +import version +__author__ = version.author +__date__ = version.date +__version__ = version.version +__licence__ = version.licence +del version + +# Copyright (C) 2009 C2ME Sa +# Remi Jocaille <rem...@c2...> +# Distributed under the terms of the GNU General Public License +# http://www.gnu.org/copyleft/gpl.html +# +# This module is a portage of the java package write by "Yoran Brault" +# "com.kysoh.tuxdroid.gadget.framework.gadget" + +# ------------------------------------------------------------------------------ +# Class of the default plugin configuration. +# ------------------------------------------------------------------------------ +class SimplePluginConfiguration(object): + """Class of the default plugin configuration. + """ + + # -------------------------------------------------------------------------- + # Constructor of the class. + # -------------------------------------------------------------------------- + def __init__(self): + """Constructor of the class. + """ + self.__traces = True + self.__pitch = 100 + self.__language = "en" + self.__country = "US" + self.__locutor = "Ryan" + self.__daemon = False + + # -------------------------------------------------------------------------- + # Get the pitch value. + # -------------------------------------------------------------------------- + def getPitch(self): + """Get the pitch value. + @return: An integer. + """ + return self.__pitch + + # -------------------------------------------------------------------------- + # Set the pitch value. + # -------------------------------------------------------------------------- + def setPitch(self, pitch): + """Set the pitch value. + @param pitch: The pitch. + """ + self.__pitch = pitch + + # -------------------------------------------------------------------------- + # Get the language. + # -------------------------------------------------------------------------- + def getLanguage(self): + """Get the language. + @return: A string. + """ + return self.__language + + # -------------------------------------------------------------------------- + # Set the language. + # -------------------------------------------------------------------------- + def setLanguage(self, language): + """Set the language. + @param language: The language. + """ + self.__language = language + + # -------------------------------------------------------------------------- + # Get the country. + # -------------------------------------------------------------------------- + def getCountry(self): + """Get the country. + @return: A string. + """ + return self.__country + + # -------------------------------------------------------------------------- + # Set the country. + # -------------------------------------------------------------------------- + def setCountry(self, country): + """Set the country. + @param country: The country. + """ + self.__country = country + + # -------------------------------------------------------------------------- + # Get the locutor. + # -------------------------------------------------------------------------- + def getLocutor(self): + """Get the locutor. + @return: A string. + """ + return self.__locutor + + # -------------------------------------------------------------------------- + # Set the locutor. + # -------------------------------------------------------------------------- + def setLocutor(self, locutor): + """Set the locutor. + @param locutor: The locutor. + """ + self.__locutor = locutor + + # -------------------------------------------------------------------------- + # Get if the plugin is traced or not. + # -------------------------------------------------------------------------- + def isTraces(self): + """Get if the plugin is traced or not. + @return: A boolean. + """ + return self.__traces + + # -------------------------------------------------------------------------- + # Set if the plugin is traced or not. + # -------------------------------------------------------------------------- + def setTraces(self, traces): + """Set if the plugin is traced or not. + @param traces: Is traced or not. + """ + self.__traces = traces + + # -------------------------------------------------------------------------- + # Get if the plugin is a daemon or not. + # -------------------------------------------------------------------------- + def isDaemon(self): + """Get if the plugin is a daemon or not. + @return: A boolean. + """ + return self.__daemon |
|
From: remi <c2m...@c2...> - 2009-05-05 14:32:35
|
Author: remi
Date: 2009-05-05 16:32:13 +0200 (Tue, 05 May 2009)
New Revision: 4642
Modified:
software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/SimpleGadget.py
software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/SimpleGadgetConfiguration.py
Log:
* fixed terminology "gadget" -> "plugin" in the classes
Modified: software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/SimpleGadget.py
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/SimpleGadget.py 2009-05-05 14:29:50 UTC (rev 4641)
+++ software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/SimpleGadget.py 2009-05-05 14:32:13 UTC (rev 4642)
@@ -26,10 +26,10 @@
ENVIRONEMENT_PREFIX = "tgp_"
# ------------------------------------------------------------------------------
-# This class is the base class helper for builder python gadgets.
+# This class is the base class helper for builder python plugins.
# ------------------------------------------------------------------------------
-class SimpleGadget(object):
- """This class is the base class helper for builder python gadgets.
+class SimplePlugin(object):
+ """This class is the base class helper for builder python plugins.
"""
# --------------------------------------------------------------------------
@@ -45,24 +45,24 @@
self.__stdInThread = None
# --------------------------------------------------------------------------
- # On gadget stop event. Must be overrided
+ # On plugin stop event. Must be overrided
# --------------------------------------------------------------------------
- def onGadgetStop(self):
- """On gadget stop event. Must be overrided
+ def onPluginStop(self):
+ """On plugin stop event. Must be overrided
"""
pass
# --------------------------------------------------------------------------
- # Stop the gadget.
+ # Stop the plugin.
# --------------------------------------------------------------------------
def stop(self):
- """Stop the gadget.
+ """Stop the plugin.
"""
if self.__stdInThread != None:
if self.__stdInThread.isAlive():
self.__stdInThread._Thread__stop()
- self.onGadgetStop()
- self.throwNotification("gadget", "exit")
+ self.onPluginStop()
+ self.throwNotification("plugin", "exit")
# --------------------------------------------------------------------------
# Set the run flag value.
@@ -96,7 +96,7 @@
while self.__getRun():
line = sys.stdin.readline()
if line.lower().find("stop") == 0:
- self.onGadgetStop()
+ self.onPluginStop()
self.__setRun(False)
time.sleep(0.1)
@@ -105,7 +105,7 @@
# --------------------------------------------------------------------------
def configuration(self):
"""Get the configuration object.
- @return: A SimpleGadgetConfiguration object.
+ @return: A SimplePluginConfiguration object.
"""
return self.__configuration
@@ -138,15 +138,15 @@
return (platformName == "microsoft") or (platformName == "windows")
# --------------------------------------------------------------------------
- # Load the environement data to the gadget parameters.
+ # Load the environement data to the plugin parameters.
# --------------------------------------------------------------------------
def __loadEnvironementData(self):
- """Load the environement data to the gadget parameters.
+ """Load the environement data to the plugin parameters.
"""
if self.__configuration == None:
return
# Extract configuration object class names
- baseConfClassName = "_SimpleGadgetConfiguration"
+ baseConfClassName = "_SimplePluginConfiguration"
confClassName = str(self.__configuration.__class__)
confClassName = confClassName.split("'")[1].split(".")[1]
confClassName = "_" + confClassName
@@ -206,10 +206,10 @@
setattr(self.__configuration, paramName, environValue)
# --------------------------------------------------------------------------
- # Starting point of the gadget.
+ # Starting point of the plugin.
# --------------------------------------------------------------------------
def boot(self, arguments, configuration):
- """Starting point of the gadget.
+ """Starting point of the plugin.
@param arguments:
"""
try:
@@ -224,25 +224,25 @@
self.__stdInThread.start()
self.start()
if not self.__configuration.isDaemon():
- self.onGadgetStop()
+ self.onPluginStop()
except:
- self.throwError("Error on gadget boot", True)
+ self.throwError("Error on plugin boot", True)
# --------------------------------------------------------------------------
- # Start method of the gadget. Must be overrided.
+ # Start method of the plugin. Must be overrided.
# --------------------------------------------------------------------------
def start(self):
- """Start method of the gadget. (Must be overrided)
+ """Start method of the plugin. (Must be overrided)
"""
pass
# --------------------------------------------------------------------------
# Get the full path of a file located in the "state" directory of a deployed
- # gadget.
+ # plugin.
# --------------------------------------------------------------------------
def __getStateFile(self, fileName):
"""Get the full path of a file located in the "state" directory of a
- deployed gadget.
+ deployed plugin.
@param fileName: Base file name.
@return: A full file path.
"""
@@ -361,12 +361,12 @@
self.throwNotification("check_result", resultValue)
# --------------------------------------------------------------------------
- # Throw an error message to the framework.
+ # Throw an error message to the plugins server.
# --------------------------------------------------------------------------
def throwError(self, message, force = False):
- """Throw an error message to the framework.
- @param message: Thowed message if the gadget don't want to be traced.
- - if the gadget is traced, the traceback will be sent instead of the
+ """Throw an error message to the plugins server.
+ @param message: Thowed message if the plugin don't want to be traced.
+ - if the plugin is traced, the traceback will be sent instead of the
message.
@param force: For to send the traceback. Default False.
"""
Modified: software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/SimpleGadgetConfiguration.py
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/SimpleGadgetConfiguration.py 2009-05-05 14:29:50 UTC (rev 4641)
+++ software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/SimpleGadgetConfiguration.py 2009-05-05 14:32:13 UTC (rev 4642)
@@ -16,10 +16,10 @@
# "com.kysoh.tuxdroid.gadget.framework.gadget"
# ------------------------------------------------------------------------------
-# Class of the default gadget configuration.
+# Class of the default plugin configuration.
# ------------------------------------------------------------------------------
-class SimpleGadgetConfiguration(object):
- """Class of the default gadget configuration.
+class SimplePluginConfiguration(object):
+ """Class of the default plugin configuration.
"""
# --------------------------------------------------------------------------
@@ -108,28 +108,28 @@
self.__locutor = locutor
# --------------------------------------------------------------------------
- # Get if the gadget is traced or not.
+ # Get if the plugin is traced or not.
# --------------------------------------------------------------------------
def isTraces(self):
- """Get if the gadget is traced or not.
+ """Get if the plugin is traced or not.
@return: A boolean.
"""
return self.__traces
# --------------------------------------------------------------------------
- # Set if the gadget is traced or not.
+ # Set if the plugin is traced or not.
# --------------------------------------------------------------------------
def setTraces(self, traces):
- """Set if the gadget is traced or not.
+ """Set if the plugin is traced or not.
@param traces: Is traced or not.
"""
self.__traces = traces
# --------------------------------------------------------------------------
- # Get if the gadget is a daemon or not.
+ # Get if the plugin is a daemon or not.
# --------------------------------------------------------------------------
def isDaemon(self):
- """Get if the gadget is a daemon or not.
+ """Get if the plugin is a daemon or not.
@return: A boolean.
"""
return self.__daemon
|
|
From: remi <c2m...@c2...> - 2009-05-05 14:30:06
|
Author: remi
Date: 2009-05-05 16:29:50 +0200 (Tue, 05 May 2009)
New Revision: 4641
Modified:
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/plugin/interpreters/PluginInterpreter.py
Log:
* message head on plugin exit is now "plugin"
Modified: software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/plugin/interpreters/PluginInterpreter.py
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/plugin/interpreters/PluginInterpreter.py 2009-05-05 14:17:01 UTC (rev 4640)
+++ software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/plugin/interpreters/PluginInterpreter.py 2009-05-05 14:29:50 UTC (rev 4641)
@@ -243,7 +243,7 @@
continue
if line[-1] == "\r":
line = line[:-1]
- if line.lower().find("gadget") == 0:
+ if line.lower().find("plugin") == 0:
if line.lower().find("'exit'") != -1:
self.abort()
if self.__getRun():
|
|
From: remi <c2m...@c2...> - 2009-05-05 14:17:12
|
Author: remi Date: 2009-05-05 16:17:01 +0200 (Tue, 05 May 2009) New Revision: 4640 Removed: software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/GadgetHelper.py Log: * removed useless class. SimplePlugin is the official class to build a python plugin Deleted: software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/GadgetHelper.py =================================================================== --- software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/GadgetHelper.py 2009-05-05 14:14:18 UTC (rev 4639) +++ software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/GadgetHelper.py 2009-05-05 14:17:01 UTC (rev 4640) @@ -1,108 +0,0 @@ -# Copyright (C) 2009 C2ME Sa -# Remi Jocaille <rem...@c2...> -# Distributed under the terms of the GNU General Public License -# http://www.gnu.org/copyleft/gpl.html - -import sys -import traceback -import platform - -# ------------------------------------------------------------------------------ -# This class is the minimal helper for builder python gadgets. -# It's an alternative to the SimpleGadget helper. -# ------------------------------------------------------------------------------ -class GadgetHelper(object): - """This class is the minimal helper for builder python gadgets. - It's an alternative to the SimpleGadget helper. - """ - - # -------------------------------------------------------------------------- - # Get if the platform is Windows or not. - # -------------------------------------------------------------------------- - def isWindows(): - """Get if the platform is Windows or not. - @return: A boolean. - """ - platformName = platform.system().lower() - return (platformName == "microsoft") or (platformName == "windows") - - # -------------------------------------------------------------------------- - # Throw a generic notification to the framework. - # -------------------------------------------------------------------------- - def throwNotification(messageId, *args): - """Throw a generic notification to the framework. - @param messageId: Message Id. - @param args: List of objects. - """ - stringBuffer = messageId - for arg in args: - stringBuffer += " '" - stringBuffer += str(arg).replace("'", "\\'") - stringBuffer += "'" - sys.stdout.write(stringBuffer + "\n") - sys.stdout.flush() - - # -------------------------------------------------------------------------- - # Throw a message to the framework. - # -------------------------------------------------------------------------- - def throwMessage(content, *args): - """Throw a message to the framework. - @param content: Content of the message. - @param args: Arguments for the message. - """ - tmp = [content,] - for arg in args: - tmp.append(arg) - GadgetHelper.throwNotification("message", *tmp) - - # -------------------------------------------------------------------------- - # Throw a trace message to the framework. - # -------------------------------------------------------------------------- - def throwTrace(message): - """Throw a trace message to the framework. - @param message: Throwed message. - """ - GadgetHelper.throwNotification("trace", message) - - # -------------------------------------------------------------------------- - # Throw the result of the "check" command to the framework. - # -------------------------------------------------------------------------- - def throwResult(result): - """Throw the result of the "check" command to the framework. - @param result: A boolean. - """ - if result: - resultValue = "true" - else: - resultValue = "false" - GadgetHelper.throwNotification("check_result", resultValue) - - # -------------------------------------------------------------------------- - # Throw an error message to the framework. - # -------------------------------------------------------------------------- - def throwError(message, sendTraceback = False): - """Throw an error message to the framework. - @param message: Thowed message if the gadget don't want to be traced. - @param sendTraceback: For to send the traceback. Default False. - """ - def formatException(): - fList = traceback.format_exception(sys.exc_info()[0], - sys.exc_info()[1], - sys.exc_info()[2]) - result = "" - for line in fList: - result += line - return result - messagesList = [message,] - if sendTraceback: - tmpList = formatException().split("\n") - for line in tmpList: - messagesList.append(line) - GadgetHelper.throwNotification("error", *messagesList) - - isWindows = staticmethod(isWindows) - throwNotification = staticmethod(throwNotification) - throwMessage = staticmethod(throwMessage) - throwTrace = staticmethod(throwTrace) - throwResult = staticmethod(throwResult) - throwError = staticmethod(throwError) |
|
From: remi <c2m...@c2...> - 2009-05-05 14:14:31
|
Author: remi Date: 2009-05-05 16:14:18 +0200 (Tue, 05 May 2009) New Revision: 4639 Added: software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/ Removed: software_suite_v3/smart-core/smart-server/trunk/util/SimpleGadget/ Log: * renamed directory from "SimpleGadget" to "SimplePlugin" Copied: software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin (from rev 4620, software_suite_v3/smart-core/smart-server/trunk/util/SimpleGadget) |
|
From: remi <c2m...@c2...> - 2009-05-05 14:13:05
|
Author: remi
Date: 2009-05-05 16:12:57 +0200 (Tue, 05 May 2009)
New Revision: 4638
Modified:
software_suite_v3/smart-core/smart-server/trunk/resources/01_robot_system/resourcePluginsServer.py
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/plugin/Plugin.py
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/plugin/PluginsContainer.py
Log:
* updated plugin extension name from TPG to SCP (Smart-Core Plugin)
* updated plugin logs to be showed in the console (useful for the implementation of the plugin/gadget system)
Modified: software_suite_v3/smart-core/smart-server/trunk/resources/01_robot_system/resourcePluginsServer.py
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/resources/01_robot_system/resourcePluginsServer.py 2009-05-05 13:59:27 UTC (rev 4637)
+++ software_suite_v3/smart-core/smart-server/trunk/resources/01_robot_system/resourcePluginsServer.py 2009-05-05 14:12:57 UTC (rev 4638)
@@ -66,7 +66,7 @@
self.logger = SimpleLogger("plugins_server")
self.logger.resetLog()
self.logger.setLevel(LOG_LEVEL_DEBUG)
- self.logger.setTarget(LOG_TARGET_FILE)
+ self.logger.setTarget(LOG_TARGET_BOTH)
self.logger.logInfo("-----------------------------------------------")
self.logger.logInfo("Smart-core Plugins Server")
self.logger.logInfo("Licence : GPL")
@@ -249,11 +249,11 @@
"""
return self.__pluginsContainer
- def insertPluginInContainer(self, tpgFilename):
+ def insertPluginInContainer(self, scpFilename):
"""Insert a plugin in the plugins server container.
- @param tpgFilename: TPG plugin file name.
+ @param scpFilename: SCP plugin file name.
@return: The success.
- - tpgFilename can be a local file or an external file (URL)
+ - scpFilename can be a local file or an external file (URL)
- After the success of the plugin insertion the plugins server will
detected it.
"""
@@ -266,10 +266,10 @@
return False
directory = directories[-1]
# Check the file extension
- if tpgFilename.lower().rfind(".tpg") == -1:
+ if scpFilename.lower().rfind(".scp") == -1:
return False
# Create a cached file with the plugin file
- cFile = filesCacheManager.createFileCache(tpgFilename)
+ cFile = filesCacheManager.createFileCache(scpFilename)
# If the plugin can't be cached then FAIL
if cFile == None:
return False
@@ -277,9 +277,9 @@
result = True
import shutil
try:
- tpgName = os.path.split(tpgFilename)[-1]
- tpgName = os.path.join(directory, tpgName)
- shutil.copy(cFile.getOutputFilePath(), tpgName)
+ scpName = os.path.split(scpFilename)[-1]
+ scpName = os.path.join(directory, scpName)
+ shutil.copy(cFile.getOutputFilePath(), scpName)
except:
result = False
filesCacheManager.destroyFileCache(cFile)
@@ -295,9 +295,9 @@
return False
for plugin in self.__pluginsContainer.getPlugins():
if plugin.getDescription().getUuid() == pluginUuid:
- tpgFile = plugin.getTpgFile()
- # Remove the tpg file
- DirectoriesAndFilesTools.RMFile(tpgFile)
+ scpFile = plugin.getScpFile()
+ # Remove the scp file
+ DirectoriesAndFilesTools.RMFile(scpFile)
return True
return False
Modified: software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/plugin/Plugin.py
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/plugin/Plugin.py 2009-05-05 13:59:27 UTC (rev 4637)
+++ software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/plugin/Plugin.py 2009-05-05 14:12:57 UTC (rev 4638)
@@ -34,11 +34,11 @@
# --------------------------------------------------------------------------
# Constructor of the class.
# --------------------------------------------------------------------------
- def __init__(self, parent, dictionary, tpgFile, workingPath):
+ def __init__(self, parent, dictionary, scpFile, workingPath):
"""Constructor of the class.
@param parent: Parent Plugins container.
@param dictionary: Plugin structure as dictionary.
- @param tpgFile: TPG file name of the plugin.
+ @param scpFile: SCP file name of the plugin.
@param workingPath: Working path of the plugin.
"""
self.__parent = parent
@@ -46,8 +46,8 @@
self.__dictionary = dictionary
# Save the working path
self.__workingPath = workingPath
- # Save the tpg file name
- self.__tpgFile = tpgFile
+ # Save the scp file name
+ self.__scpFile = scpFile
# Create i18n table
self.__i18nList = {}
self.__updateI18nList()
@@ -193,7 +193,7 @@
data['description']['help_file'] = helpContent
data['description']['icon_file'] = "/%s/icon.png" % description.getUuid()
data['description']['working_path'] = self.getWorkingPath()
- data['description']['tpg_file'] = self.getTpgFile()
+ data['description']['scp_file'] = self.getScpFile()
data['default_run_command'] = self.getDefaultRunCommandName()
data['default_check_command'] = self.getDefaultCheckCommandName()
# Parameters
@@ -274,13 +274,13 @@
return self.__workingPath
# --------------------------------------------------------------------------
- # Get the TPG file of the plugin.
+ # Get the SCP file of the plugin.
# --------------------------------------------------------------------------
- def getTpgFile(self):
- """Get the TPG file of the plugin.
+ def getScpFile(self):
+ """Get the SCP file of the plugin.
@return: A string.
"""
- return self.__tpgFile
+ return self.__scpFile
# --------------------------------------------------------------------------
# Get the dictionary of the plugin.
Modified: software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/plugin/PluginsContainer.py
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/plugin/PluginsContainer.py 2009-05-05 13:59:27 UTC (rev 4637)
+++ software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/plugin/PluginsContainer.py 2009-05-05 14:12:57 UTC (rev 4638)
@@ -115,7 +115,7 @@
"""Add a plugins directory to deploy.
@param directory: Directory path.
"""
- self.__autoDeployer.addDirectory(directory, [".tpg",])
+ self.__autoDeployer.addDirectory(directory, [".scp",])
# --------------------------------------------------------------------------
# Remove a plugins directory to deploy.
@@ -358,7 +358,7 @@
if cmpVersionGt(pluginVersion, sPluginVersion):
try:
# Remove the old plugin
- os.remove(sPlugin.getTpgFile())
+ os.remove(sPlugin.getScpFile())
except:
pass
# New plugin is older
|
|
From: remi <c2m...@c2...> - 2009-05-05 13:59:41
|
Author: remi
Date: 2009-05-05 15:59:27 +0200 (Tue, 05 May 2009)
New Revision: 4637
Modified:
software_suite_v3/smart-core/smart-server/trunk/resources/03_advanced_api/resourceTestGadgetMessage.py
Log:
* disabled a resource
Modified: software_suite_v3/smart-core/smart-server/trunk/resources/03_advanced_api/resourceTestGadgetMessage.py
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/resources/03_advanced_api/resourceTestGadgetMessage.py 2009-05-05 13:56:11 UTC (rev 4636)
+++ software_suite_v3/smart-core/smart-server/trunk/resources/03_advanced_api/resourceTestGadgetMessage.py 2009-05-05 13:59:27 UTC (rev 4637)
@@ -1,3 +1,4 @@
+'''
# ==============================================================================
# TTS Resource
# ==============================================================================
@@ -97,3 +98,4 @@
resourceTestGadgetMessage = TDSResourceTestGadgetMessage("resourceTestGadgetMessage")
# Register the resource into the resources manager
resourcesManager.addResource(resourceTestGadgetMessage)
+'''
\ No newline at end of file
|
|
From: remi <c2m...@c2...> - 2009-05-05 13:56:15
|
Author: remi
Date: 2009-05-05 15:56:11 +0200 (Tue, 05 May 2009)
New Revision: 4636
Modified:
software_suite_v3/smart-core/smart-server/trunk/TDSResourcesManager.py
Log:
* added support of png files when a directory is served
Modified: software_suite_v3/smart-core/smart-server/trunk/TDSResourcesManager.py
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/TDSResourcesManager.py 2009-05-05 13:54:49 UTC (rev 4635)
+++ software_suite_v3/smart-core/smart-server/trunk/TDSResourcesManager.py 2009-05-05 13:56:11 UTC (rev 4636)
@@ -372,6 +372,8 @@
headers = [['Content-type', 'js; charset="utf-8"'],]
elif file.lower().rfind(".gif") != -1:
headers = [['Content-type', 'image/gif; charset="utf-8"'],]
+ elif file.lower().rfind(".png") != -1:
+ headers = [['Content-type', 'image/png; charset="utf-8"'],]
elif file.lower().rfind(".css") != -1:
headers = [['Content-type', 'text/css; charset="utf-8"'],]
elif file.lower().rfind(".ico") != -1:
|
|
From: remi <c2m...@c2...> - 2009-05-05 13:55:01
|
Author: remi
Date: 2009-05-05 15:54:49 +0200 (Tue, 05 May 2009)
New Revision: 4635
Removed:
software_suite_v3/smart-core/smart-server/trunk/data/plugins/tuxdroid-gadget-pySkeleton.tpg
software_suite_v3/smart-core/smart-server/trunk/resources/01_robot_system/resourceGadgetFramework.py
software_suite_v3/smart-core/smart-server/trunk/resources/03_advanced_api/resourceTaskCreation.py
software_suite_v3/smart-core/smart-server/trunk/resources/03_advanced_api/resourceUserConfiguration.py
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/gadget/
Modified:
software_suite_v3/smart-core/smart-server/trunk/resources/04_web_interface/resourceWIPlugin.py
Log:
* removed old gadget lib
* removed useless resources
* disable web interface resource
* removed fake plugin
(preparing to implement to new plugin/gadget philosophy)
Deleted: software_suite_v3/smart-core/smart-server/trunk/data/plugins/tuxdroid-gadget-pySkeleton.tpg
===================================================================
(Binary files differ)
Deleted: software_suite_v3/smart-core/smart-server/trunk/resources/01_robot_system/resourceGadgetFramework.py
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/resources/01_robot_system/resourceGadgetFramework.py 2009-05-05 08:17:32 UTC (rev 4634)
+++ software_suite_v3/smart-core/smart-server/trunk/resources/01_robot_system/resourceGadgetFramework.py 2009-05-05 13:54:49 UTC (rev 4635)
@@ -1,926 +0,0 @@
-# ==============================================================================
-# Gadget framework resource.
-# ==============================================================================
-
-from util.applicationserver.gadget.GadgetsContainer import GadgetsContainer
-from util.applicationserver.gadget.Gadget import SUPPORTED_LANGUAGES_LIST
-from util.applicationserver.gadget.ConfiguredGadget import *
-from util.applicationserver.gadget.WebGadgetTools import WebGadgetTools
-from util.misc.tuxPaths import TUXDROID_LANGUAGE
-from util.misc.tuxPaths import TUXDROID_DEFAULT_LOCUTOR
-from util.misc.tuxPaths import USER_BASE_PATH
-from util.logger.SimpleLogger import *
-
-# Framework events/statuses
-ST_NAME_FW_RUN = "framework_run"
-ST_NAME_FW_CONTAINER_DEPLOYED = "framework_container_deployed"
-ST_NAME_FW_CONTAINER_ERROR = "framework_container_error"
-ST_NAME_FW_GADGET_LOADED = "framework_gadget_loaded"
-ST_NAME_FW_GADGET_UNLOADED = "framework_gadget_unloaded"
-ST_NAME_FW_GADGET_MESSAGE = "framework_gadget_message"
-ST_NAME_FW_GADGET_ERROR = "framework_gadget_error"
-ST_NAME_FW_GADGET_TRACE = "framework_gadget_trace"
-ST_NAME_FW_GADGET_RESULT = "framework_gadget_result"
-ST_NAME_FW_GADGET_NOTIFICATION = "framework_gadget_notification"
-ST_NAME_FW_GADGET_STARTING = "framework_gadget_starting"
-ST_NAME_FW_GADGET_STOPPED = "framework_gadget_stopped"
-ST_NAME_FW_CONFIGURATIONS_LOADED = "framework_configurations_loaded"
-ST_NAME_FW_CONFIGURATIONS_UNLOADED = "framework_configurations_unloaded"
-
-# Framework events/statuses list
-SW_NAME_FRAMEWORK = [
- ST_NAME_FW_RUN, # Is sent to clients
- ST_NAME_FW_CONTAINER_DEPLOYED, # Is sent to clients
- ST_NAME_FW_CONTAINER_ERROR, # Is not sent to clients
- ST_NAME_FW_GADGET_LOADED, # Is not sent to clients
- ST_NAME_FW_GADGET_UNLOADED, # Is not sent to clients
- ST_NAME_FW_GADGET_MESSAGE, # Is not sent to clients
- ST_NAME_FW_GADGET_ERROR, # Is not sent to clients
- ST_NAME_FW_GADGET_TRACE, # Is not sent to clients
- ST_NAME_FW_GADGET_RESULT, # Is not sent to clients
- ST_NAME_FW_GADGET_NOTIFICATION, # Is not sent to clients
- ST_NAME_FW_GADGET_STARTING, # Is sent to clients
- ST_NAME_FW_GADGET_STOPPED, # Is sent to clients
- ST_NAME_FW_CONFIGURATIONS_LOADED, # Is sent to clients
- ST_NAME_FW_CONFIGURATIONS_UNLOADED, # Is sent to clients
-]
-
-# ------------------------------------------------------------------------------
-# Declaration of the resource "gadget_framework".
-# ------------------------------------------------------------------------------
-class TDSResourceGadgetFramework(TDSResource):
-
- # --------------------------------------------------------------------------
- # Inherited methods from TDSResource
- # --------------------------------------------------------------------------
-
- def configure(self):
- self.name = "gadget_framework"
- self.comment = "Resource to manage the gadget framework."
- self.fileName = RESOURCE_FILENAME
- # Create a gadgets container
- self.__gadgetsContainer = GadgetsContainer()
- self.__gadgetsContainer.setOnDirectoryDeployedCallback(self.__onDirectoryDeployed)
- self.__gadgetsContainer.setOnDirectoryUndeployedCallback(self.__onDirectoryUndeployed)
- self.__gadgetsContainer.setOnGadgetDeployedCallback(self.__onGadgetDeployed)
- self.__gadgetsContainer.setOnGadgetDeploymentErrorCallback(self.__onGadgetDeploymentError)
- self.__gadgetsContainer.setOnGadgetUndeployedCallback(self.__onGadgetUndeployed)
- self.__gadgetsContainer.setOnConfigurationsLoadedCallback(self.__onConfigurationsLoaded)
- self.__gadgetsContainer.setOnConfigurationsUnloadedCallback(self.__onConfigurationsUnloaded)
- # Registering the framework statuses.
- for statusName in SW_NAME_FRAMEWORK:
- eventsHandler.insert(statusName)
- eventsHandler.getEventHandler(ST_NAME_FW_RUN).updateState("False")
- # Create a logger
- self.logger = SimpleLogger("gadget_framework")
- self.logger.resetLog()
- self.logger.setLevel(LOG_LEVEL_DEBUG)
- self.logger.setTarget(LOG_TARGET_FILE)
- self.logger.logInfo("-----------------------------------------------")
- self.logger.logInfo("Tux Droid Gadget Framework")
- self.logger.logInfo("Licence : GPL")
- self.logger.logInfo("-----------------------------------------------")
-
- def stop(self):
- self.logger.logInfo("Undeploy the gadgets container")
- self.__gadgetsContainer.undeploy()
- self.__publishEvents(True, ST_NAME_FW_RUN, ["False",])
-
- # --------------------------------------------------------------------------
- # Gadget container events
- # --------------------------------------------------------------------------
-
- def __onDirectoryDeployed(self, observerName):
- self.logger.logInfo("Directory deployed [%s]" % observerName)
- self.__publishEvents(True, ST_NAME_FW_CONTAINER_DEPLOYED, ["True",])
-
- def __onDirectoryUndeployed(self, observerName):
- self.logger.logInfo("Directory undeployed [%s]" % observerName)
- self.__publishEvents(True, ST_NAME_FW_CONTAINER_DEPLOYED, ["False",])
-
- def __onGadgetDeployed(self, gadget, gadgetWorkingPath):
- uuid = gadget.getDescription().getUuid()
- pngUrl = '/%s/gadget.png' % uuid
- resourcesManager.addFileToServe(gadget.getDescription().getIconFile(),
- pngUrl)
- for language in SUPPORTED_LANGUAGES_LIST:
- helpFile = gadget.getDescription().getHelpFile(language)
- fileName = helpFile[helpFile.rfind(os.sep) + 1:]
- helpUrl = '/%s/%s' % (uuid, fileName)
- resourcesManager.addFileToServe(helpFile, helpUrl)
- googleGadgetUrl = '/%s/google_gadget_code.txt' % uuid
- googleGadgetCode = WebGadgetTools.generateGoogleGadgetCode(gadget,
- "/gadget_framework/web_gadget?",
- gadget.getCommands()[0].getName(), {})
- resourcesManager.addContentToServe(googleGadgetCode,
- googleGadgetUrl)
- gadget.setOnGadgetNotificationCallback(self.__onGadgetNotification)
- gadget.setOnGadgetMessageCallback(self.__onGadgetMessage)
- gadget.setOnGadgetErrorCallback(self.__onGadgetError)
- gadget.setOnGadgetTraceCallback(self.__onGadgetTrace)
- gadget.setOnGadgetResultCallback(self.__onGadgetResult)
- gadget.setOnGadgetStartingCallback(self.__onGadgetStarting)
- gadget.setOnGadgetStoppedCallback(self.__onGadgetStopped)
- self.logger.logDebug("Gadget deployed [%s] to [%s]" % (
- gadget.getDescription().getName(), gadgetWorkingPath))
- self.__publishEvents(False, ST_NAME_FW_GADGET_LOADED, [uuid,])
-
- def __onGadgetDeploymentError(self, observerName, gadgetFileName, message):
- messagesList = [
- observerName,
- gadgetFileName,
- message,
- ]
- self.logger.logWarning("Gadget deployment error [%s, %s] to (%s)" % (
- observerName, gadgetFileName, message))
- self.__publishEvents(False, ST_NAME_FW_CONTAINER_ERROR, messagesList)
-
- def __onGadgetUndeployed(self, gadget, gadgetWorkingPath):
- uuid = gadget.getDescription().getUuid()
- pngUrl = '/%s/gadget.png' % uuid
- resourcesManager.removeFileToServe(pngUrl)
- for language in SUPPORTED_LANGUAGES_LIST:
- helpFile = gadget.getDescription().getHelpFile(language)
- fileName = helpFile[helpFile.rfind(os.sep) + 1:]
- helpUrl = '/%s/%s' % (uuid, fileName)
- resourcesManager.removeFileToServe(helpUrl)
- googleGadgetUrl = '/%s/google_gadget_code.txt' % uuid
- resourcesManager.removeFileToServe(googleGadgetUrl)
- self.logger.logDebug("Gadget undeployed [%s] to [%s]" % (
- gadget.getDescription().getName(), gadgetWorkingPath))
- self.__publishEvents(False, ST_NAME_FW_GADGET_UNLOADED, [uuid,])
-
- # --------------------------------------------------------------------------
- # Gadget events
- # --------------------------------------------------------------------------
-
- def __onGadgetNotification(self, gadget, instanceParameters, messageId, *args):
- messageStr = ""
- for message in args:
- messageStr += message
- uuid = gadget.getDescription().getUuid()
- locutor = instanceParameters['locutor']
- pitch = instanceParameters['pitch']
- self.logger.logDebug("Gadget NOTIFICATION [%s] (%s : %s)" % (
- gadget.getDescription().getName(), messageId, messageStr))
- self.__publishEvents(False, ST_NAME_FW_GADGET_NOTIFICATION, [uuid, "0",
- locutor, pitch, messageId, messageStr])
-
- def __onGadgetMessage(self, gadget, instanceParameters, message):
- uuid = gadget.getDescription().getUuid()
- locutor = instanceParameters['locutor']
- pitch = instanceParameters['pitch']
- self.logger.logDebug("Gadget MESSAGE [%s] (%s)" % (
- gadget.getDescription().getName(), message))
- self.__publishEvents(False, ST_NAME_FW_GADGET_MESSAGE, [uuid, "0",
- locutor, pitch, message])
-
- def __onGadgetError(self, gadget, instanceParameters, *messagesList):
- messageStr = ""
- for message in messagesList:
- messageStr += message
- self.logger.logError("Gadget ERROR [%s] (%s)" % (
- gadget.getDescription().getName(), messageStr))
- self.__publishEvents(False, ST_NAME_FW_GADGET_ERROR, [
- gadget.getDescription().getUuid(), "0", messageStr])
-
- def __onGadgetTrace(self, gadget, instanceParameters, *messagesList):
- messageStr = ""
- for message in messagesList:
- messageStr += message
- self.logger.logDebug("Gadget TRACE [%s] (%s)" % (
- gadget.getDescription().getName(), messageStr))
- self.__publishEvents(False, ST_NAME_FW_GADGET_TRACE, [
- gadget.getDescription().getUuid(), "0", messageStr])
-
- def __onGadgetResult(self, gadget, instanceParameters, gadgetResult):
- self.logger.logDebug("Gadget RESULT [%s] (%s)" % (
- gadget.getDescription().getName(), str(gadgetResult)))
- self.__publishEvents(False, ST_NAME_FW_GADGET_RESULT, [
- gadget.getDescription().getUuid(), "0", str(gadgetResult)])
-
- def __onGadgetStarting(self, gadget, instanceParameters, instanceCommand,
- instanceIsDaemon):
- uuid = gadget.getDescription().getUuid()
- self.logger.logInfo("Gadget starting [%s] (%s)" % (
- gadget.getDescription().getName(), str(instanceParameters)))
- self.__publishEvents(True, ST_NAME_FW_GADGET_STARTING, [uuid, "FW"])
-
- def __onGadgetStopped(self, gadget, instanceParameters, instanceCommand,
- instanceIsDaemon):
- uuid = gadget.getDescription().getUuid()
- if instanceIsDaemon:
- self.logger.logInfo("Gadget stopped [%s]" % (
- gadget.getDescription().getName()))
- self.__publishEvents(True, ST_NAME_FW_GADGET_STOPPED, [uuid, "FW"])
- self.__publishEvents(True, ST_NAME_FW_GADGET_STOPPED, [uuid, "TTS"])
- else:
- self.__publishEvents(True, ST_NAME_FW_GADGET_STOPPED, [uuid, "FW"])
-
- def __onConfigurationsLoaded(self):
- self.__publishEvents(True, ST_NAME_FW_CONFIGURATIONS_LOADED, ["True",])
-
- def __onConfigurationsUnloaded(self):
- self.__publishEvents(True, ST_NAME_FW_CONFIGURATIONS_UNLOADED,
- ["True",])
-
- # --------------------------------------------------------------------------
- # Private methods
- # --------------------------------------------------------------------------
-
- def __publishEvents(self, sendToClients, eventName, eventValues = []):
- def async():
- values = ""
- for value in eventValues:
- values += value + ":"
- if len(values) > 0:
- values = values[:-1]
- eventStruct = {
- 'name' : eventName,
- 'value' : values,
- 'delay' : "0.0",
- 'type' : "string"
- }
- if sendToClients:
- clientsManager.pushEvents([eventStruct,])
- eventsHandler.emit(eventName, (values, 0.0))
- t = threading.Thread(target = async)
- t.start()
-
- # --------------------------------------------------------------------------
- # Shared methods
- # --------------------------------------------------------------------------
-
- def publishEvents(self, sendToClients, eventName, eventValues = []):
- """
- """
- self.__publishEvents(sendToClients, eventName, eventValues)
-
- def getGadgetsContainer(self):
- """Get the gadgets container.
- @return: The gadgets container.
- """
- return self.__gadgetsContainer
-
- def insertGadgetInContainer(self, tgfFilename):
- """Insert a gadget in the framework container.
- @param tgfFilename: TGF gadget file name.
- @return: The success.
- - tgfFilename can be a local file or an external file (URL)
- - After the success of the gadget insertion the framework will detected it.
- """
- # Check that the framework is started
- if not self.__gadgetsContainer.isDeployed():
- return False
- # Check that the container directory is selected
- directories = self.__gadgetsContainer.getDirectories()
- if len(directories) == 0:
- return False
- directory = directories[-1]
- # Check the file extension
- if tgfFilename.lower().rfind(".tgf") == -1:
- return False
- # Create a cached file with the gadget file
- cFile = filesCacheManager.createFileCache(tgfFilename)
- # If the gadget can't be cached then FAIL
- if cFile == None:
- return False
- # Copy the gadget in the container directory
- result = True
- import shutil
- try:
- tfgName = os.path.split(tgfFilename)[-1]
- tfgName = os.path.join(directory, tfgName)
- shutil.copy(cFile.getOutputFilePath(), tfgName)
- except:
- result = False
- filesCacheManager.destroyFileCache(cFile)
- return result
-
- def removeGadgetFromContainer(self, gadgetUuid):
- """Remove a gadget from the framework container.
- @param gadgetUuid: Gadget uuid.
- @return: The success.
- """
- # Check that the framework is started
- if not self.__gadgetsContainer.isDeployed():
- return False
- for gadget in self.__gadgetsContainer.getGadgets():
- if gadget.getDescription().getUuid() == gadgetUuid:
- if gadget.isConfiguration():
- self.__gadgetsContainer.removeConfiguration(gadget)
- else:
- tgfFile = gadget.getTgfFile()
- # Remove the tfg file
- DirectoriesAndFilesTools.RMFile(tgfFile)
- self.__gadgetsContainer.removeConfigurationsByOriginalGadgetUuid(gadgetUuid)
- return True
- return False
-
- def createConfiguration(self, gadgetUuid, parameters, name,
- hiddenParameters):
- """Create a configuration of a gadget.
- @param gadgetUuid: Gadget uuid.
- @param parameters: Parameters.
- @param name: Name of the configured gadget.
- @param hiddenParameters: Hidden parameters list.
- @return: The success.
- """
- gadget = self.__gadgetsContainer.getGadgetByUuid(gadgetUuid)
- if gadget != None:
- configuredGadget = ConfiguredGadget.createConfiguredGadget(gadget,
- parameters, name, hiddenParameters)
- self.__gadgetsContainer.insertConfiguration(configuredGadget)
- return True
- else:
- return False
-
- def updateConfigurationName(self, gadgetUuid, name):
- """Update the name of a configured gadget.
- @param gadgetUuid: Gadget uuid.
- @param name: Name of the configured gadget.
- @return: The success.
- """
- gadget = self.__gadgetsContainer.getGadgetByUuid(gadgetUuid)
- if gadget != None:
- if not gadget.isConfiguration():
- return False
- gadget.updateName(name)
- self.__gadgetsContainer.storeConfiguration(gadget)
- self.__publishEvents(True, ST_NAME_FW_CONFIGURATIONS_LOADED,
- ["True",])
- return True
- else:
- return False
-
- def updateConfigurationParameters(self, gadgetUuid, parameters,
- hiddenParameters):
- """Update the parameters of a configured gadget.
- @param gadgetUuid: Gadget uuid.
- @param parameters: Parameters.
- @param hiddenParameters: Hidden parameters list.
- @return: The success.
- """
- gadget = self.__gadgetsContainer.getGadgetByUuid(gadgetUuid)
- if gadget != None:
- if not gadget.isConfiguration():
- return False
- gadget.updateParameters(parameters, hiddenParameters)
- self.__gadgetsContainer.storeConfiguration(gadget)
- self.__publishEvents(True, ST_NAME_FW_CONFIGURATIONS_LOADED,
- ["True",])
- return True
- else:
- return False
-
- def startGadget(self, gadgetUuid, command, parameters):
- """Start a gadget.
- @param gadgetUuid: Gadget uuid.
- @param command: Command.
- @param parameters: Parameters.
- @return: True or False.
- """
- gadget = self.__gadgetsContainer.getGadgetByUuid(gadgetUuid)
- if gadget != None:
- return gadget.start(command, parameters)
- else:
- return False
-
- def stopGadget(self, gadgetUuid):
- """Stop a gadget.
- @param gadgetUuid: Gadget uuid.
- """
- gadget = self.__gadgetsContainer.getGadgetByUuid(gadgetUuid)
- if gadget != None:
- gadget.stop()
-
-# Create an instance of the resource
-resourceGadgetFramework = TDSResourceGadgetFramework("resourceGadgetFramework")
-# Register the resource into the resources manager
-resourcesManager.addResource(resourceGadgetFramework)
-
-# ------------------------------------------------------------------------------
-# Declaration of the service "start".
-# ------------------------------------------------------------------------------
-class TDSServiceGadgetFrameworkStart(TDSService):
-
- def configure(self):
- self.parametersDict = {
- 'gadgets_path' : 'string',
- 'configurations_path' : 'string',
- 'language' : 'string',
- 'country' : 'string',
- 'locutor' : 'string',
- 'pitch' : 'uint8',
- }
- self.minimalUserLevel = TDS_CLIENT_LEVEL_ANONYMOUS
- self.exclusiveExecution = False
- self.name = "start"
- self.comment = "Start the gadget framework."
-
- def execute(self, id, parameters):
- headersStruct = self.getDefaultHeadersStruct()
- contentStruct = self.getDefaultContentStruct()
- contentStruct['root']['result'] = getStrError(E_TDREST_SUCCESS)
- # Check the directory
- if not os.path.isdir(parameters['gadgets_path']):
- contentStruct['root']['result'] = getStrError(E_TDREST_FAILED)
- else:
- # Start the framework
- gadgetsContainer = resourceGadgetFramework.getGadgetsContainer()
- resourceGadgetFramework.publishEvents(True, ST_NAME_FW_RUN,
- ["False",])
- resourceGadgetFramework.logger.logInfo("Undeploy the gadgets container.")
- gadgetsContainer.undeploy()
- resourceGadgetFramework.logger.logInfo("Gadgets container is undeployed.")
- for directory in gadgetsContainer.getDirectories():
- resourceGadgetFramework.logger.logInfo("Remove directory from the container [%s]." %\
- directory)
- gadgetsContainer.removeDirectory(directory)
- resourceGadgetFramework.logger.logInfo("Set locales [%s:%s:%s:%s]." % (
- parameters['language'], parameters['country'],
- parameters['locutor'], parameters['pitch']))
- gadgetsContainer.setLocales(parameters['language'],
- parameters['country'], parameters['locutor'],
- parameters['pitch'])
- resourceGadgetFramework.logger.logInfo("Add directory in the container [%s]." %\
- parameters['gadgets_path'])
- gadgetsContainer.addDirectory(parameters['gadgets_path'])
- resourceGadgetFramework.logger.logInfo("Deploy the gadgets container.")
- gadgetsContainer.deploy()
- resourceGadgetFramework.logger.logInfo("Gadgets container is deployed.")
- # Load the configurations
- gadgetsContainer.loadConfigurations(parameters['configurations_path'])
- resourceGadgetFramework.publishEvents(True, ST_NAME_FW_RUN,
- ["True",])
- return headersStruct, contentStruct
-
-# Register the service into the resource
-resourceGadgetFramework.addService(TDSServiceGadgetFrameworkStart)
-
-# ------------------------------------------------------------------------------
-# Declaration of the service "update_locales".
-# ------------------------------------------------------------------------------
-class TDSServiceGadgetFrameworkUpdateLocales(TDSService):
-
- def configure(self):
- self.parametersDict = {
- 'language' : 'string',
- 'country' : 'string',
- 'locutor' : 'string',
- 'pitch' : 'uint8',
- }
- self.minimalUserLevel = TDS_CLIENT_LEVEL_ANONYMOUS
- self.exclusiveExecution = False
- self.name = "update_locales"
- self.comment = "Update the locale values of the framework and reload the gadgets."
-
- def execute(self, id, parameters):
- headersStruct = self.getDefaultHeadersStruct()
- contentStruct = self.getDefaultContentStruct()
- contentStruct['root']['result'] = getStrError(E_TDREST_SUCCESS)
- gadgetsContainer = resourceGadgetFramework.getGadgetsContainer()
- gadgetsContainer.setLocales(parameters['language'],
- parameters['country'], parameters['locutor'], parameters['pitch'])
- return headersStruct, contentStruct
-
-# Register the service into the resource
-resourceGadgetFramework.addService(TDSServiceGadgetFrameworkUpdateLocales)
-
-# ------------------------------------------------------------------------------
-# Declaration of the service "gadgets_infos".
-# ------------------------------------------------------------------------------
-class TDSServiceGadgetFrameworkGadgetsInfos(TDSService):
-
- def configure(self):
- self.parametersDict = {}
- self.minimalUserLevel = TDS_CLIENT_LEVEL_ANONYMOUS
- self.exclusiveExecution = False
- self.name = "gadgets_infos"
- self.comment = "Get the informations from all gadgets."
- self.haveXsl = True
- self.xslPath = "/data/xsl/gadgets.xsl"
-
- def execute(self, id, parameters):
- headersStruct = self.getDefaultHeadersStruct()
- contentStruct = self.getDefaultContentStruct()
- contentStruct['root']['result'] = getStrError(E_TDREST_SUCCESS)
- gadgets = resourceGadgetFramework.getGadgetsContainer().getGadgets()
- gadgetsNameList = []
- for gadget in gadgets:
- gadgetsNameList.append(gadget.getDescription().getName())
- gadgetsNameList.sort()
- for i, gadgetName in enumerate(gadgetsNameList):
- gadget = resourceGadgetFramework.getGadgetsContainer().getGadgetByName(gadgetName)
- d_name = "data|%.3d" % i
- structure = WebGadgetTools.generateWebGadgetStructure(gadget,
- '/gadget_framework/web_gadget?',
- gadget.getDefaultRunCommandName(), {}, [])
- structure['commands'] = {}
- for j, command in enumerate(gadget.getCommands()):
- c_name = "command_%.3d" % j
- structure['commands'][c_name] = {}
- structure['commands'][c_name]['name'] = command.getName()
- structure['commands'][c_name]['translated_name'] = command.getTranslatedName()
- structure['commands'][c_name]['description'] = command.getDescription()
- contentStruct['root'][d_name] = structure
- return headersStruct, contentStruct
-
-# Register the service into the resource
-resourceGadgetFramework.addService(TDSServiceGadgetFrameworkGadgetsInfos)
-
-# ------------------------------------------------------------------------------
-# Declaration of the service "all_of_frames".
-# ------------------------------------------------------------------------------
-class TDSServiceGadgetFrameworkAllOfFrames(TDSService):
-
- def configure(self):
- self.parametersDict = {}
- self.minimalUserLevel = TDS_CLIENT_LEVEL_ANONYMOUS
- self.exclusiveExecution = False
- self.name = "all_of_frames"
- self.comment = "Show all web gadgets."
- self.haveXsl = True
- self.xslPath = "/data/xsl/gadgets_all_of_frames.xsl"
-
- def execute(self, id, parameters):
- headersStruct = self.getDefaultHeadersStruct()
- contentStruct = self.getDefaultContentStruct()
- contentStruct['root']['result'] = getStrError(E_TDREST_SUCCESS)
- gadgets = resourceGadgetFramework.getGadgetsContainer().getGadgets()
- for i, gadget in enumerate(gadgets):
- d_name = "data|%d" % i
- structure = WebGadgetTools.generateWebGadgetStructure(gadget,
- '/gadget_framework/web_gadget?',
- gadget.getDefaultRunCommandName(), {}, [])
- #del structure['command']
- structure['commands'] = {}
- for j, command in enumerate(gadget.getCommands()):
- c_name = "command_%.3d" % j
- structure['commands'][c_name] = {}
- structure['commands'][c_name]['name'] = command.getName()
- structure['commands'][c_name]['translated_name'] = command.getTranslatedName()
- structure['commands'][c_name]['description'] = command.getDescription()
- contentStruct['root'][d_name] = structure
- return headersStruct, contentStruct
-
-# Register the service into the resource
-resourceGadgetFramework.addService(TDSServiceGadgetFrameworkAllOfFrames)
-
-# ------------------------------------------------------------------------------
-# Declaration of the service "web_gadget".
-# ------------------------------------------------------------------------------
-class TDSServiceGadgetFrameworkWebGadget(TDSService):
-
- def configure(self):
- self.parametersDict = {
- 'uuid' : 'string',
- 'command' : 'string',
- 'parameters' : 'string',
- 'hiddenlist' : 'string',
- }
- self.minimalUserLevel = TDS_CLIENT_LEVEL_ANONYMOUS
- self.exclusiveExecution = False
- self.name = "web_gadget"
- self.comment = "Web view of a gadget."
- self.haveXsl = True
- self.xslPath = "/data/xsl/web_gadget.xsl"
-
- def execute(self, id, parameters):
- headersStruct = self.getDefaultHeadersStruct()
- contentStruct = self.getDefaultContentStruct()
- contentStruct['root']['result'] = getStrError(E_TDREST_SUCCESS)
- splParams = parameters['parameters'].split("|")
- params = {}
- for paramStruct in splParams:
- param = paramStruct.split("=")
- if len(param) == 2:
- params[param[0]] = param[1]
- hList = parameters['hiddenlist'].split("|")
- uuid = parameters['uuid']
- gadget = resourceGadgetFramework.getGadgetsContainer().getGadgetByUuid(uuid)
- structure = None
- if gadget != None:
- structure = WebGadgetTools.generateWebGadgetStructure(gadget,
- '/gadget_framework/web_gadget?', parameters['command'], params,
- hList)
- if structure == None:
- contentStruct['root']['result'] = getStrError(E_TDREST_FAILED)
- else:
- contentStruct['root']['data'] = structure
- return headersStruct, contentStruct
-
-# Register the service into the resource
-resourceGadgetFramework.addService(TDSServiceGadgetFrameworkWebGadget)
-
-# ------------------------------------------------------------------------------
-# Declaration of the service "start_gadget_by_uuid".
-# ------------------------------------------------------------------------------
-class TDSServiceGadgetFrameworkStartGadgetByUuid(TDSService):
-
- def configure(self):
- self.parametersDict = {
- 'uuid' : 'string',
- 'command' : 'string',
- 'parameters' : 'string',
- }
- self.minimalUserLevel = TDS_CLIENT_LEVEL_ANONYMOUS
- self.exclusiveExecution = False
- self.name = "start_gadget_by_uuid"
- self.comment = "Start a gadget by it uuid."
-
- def execute(self, id, parameters):
- headersStruct = self.getDefaultHeadersStruct()
- contentStruct = self.getDefaultContentStruct()
- contentStruct['root']['result'] = getStrError(E_TDREST_SUCCESS)
- uuid = parameters['uuid']
- command = parameters['command']
- params = {}
- splParams = parameters['parameters'].split("|")
- for paramStruct in splParams:
- param = paramStruct.split("=")
- if len(param) == 2:
- params[param[0]] = param[1]
- gadgetStarted = False
- gadget = resourceGadgetFramework.getGadgetsContainer().getGadgetByUuid(uuid)
- if gadget != None:
- gadgetStarted = gadget.start(command, params)
- if not gadgetStarted:
- contentStruct['root']['result'] = getStrError(E_TDREST_FAILED)
- return headersStruct, contentStruct
-
-# Register the service into the resource
-resourceGadgetFramework.addService(TDSServiceGadgetFrameworkStartGadgetByUuid)
-
-# ------------------------------------------------------------------------------
-# Declaration of the service "start_gadget_by_name".
-# ------------------------------------------------------------------------------
-class TDSServiceGadgetFrameworkStartGadgetByName(TDSService):
-
- def configure(self):
- self.parametersDict = {
- 'name' : 'string',
- 'command' : 'string',
- 'parameters' : 'string',
- }
- self.minimalUserLevel = TDS_CLIENT_LEVEL_ANONYMOUS
- self.exclusiveExecution = False
- self.name = "start_gadget_by_name"
- self.comment = "Start a gadget by it name."
-
- def execute(self, id, parameters):
- headersStruct = self.getDefaultHeadersStruct()
- contentStruct = self.getDefaultContentStruct()
- contentStruct['root']['result'] = getStrError(E_TDREST_SUCCESS)
- name = parameters['name']
- command = parameters['command']
- params = {}
- splParams = parameters['parameters'].split("|")
- for paramStruct in splParams:
- param = paramStruct.split("=")
- if len(param) == 2:
- params[param[0]] = param[1]
- gadgetStarted = False
- gadget = resourceGadgetFramework.getGadgetsContainer().getGadgetByName(name)
- if gadget != None:
- gadgetStarted = gadget.start(command, params)
- if not gadgetStarted:
- contentStruct['root']['result'] = getStrError(E_TDREST_FAILED)
- return headersStruct, contentStruct
-
-# Register the service into the resource
-resourceGadgetFramework.addService(TDSServiceGadgetFrameworkStartGadgetByName)
-
-# ------------------------------------------------------------------------------
-# Declaration of the service "stop_gadget_by_uuid".
-# ------------------------------------------------------------------------------
-class TDSServiceGadgetFrameworkStopGadgetByUuid(TDSService):
-
- def configure(self):
- self.parametersDict = {
- 'uuid' : 'string',
- }
- self.minimalUserLevel = TDS_CLIENT_LEVEL_ANONYMOUS
- self.exclusiveExecution = False
- self.name = "stop_gadget_by_uuid"
- self.comment = "Stop a gadget by it uuid."
-
- def execute(self, id, parameters):
- headersStruct = self.getDefaultHeadersStruct()
- contentStruct = self.getDefaultContentStruct()
- contentStruct['root']['result'] = getStrError(E_TDREST_SUCCESS)
- uuid = parameters['uuid']
- gadget = resourceGadgetFramework.getGadgetsContainer().getGadgetByUuid(uuid)
- if gadget != None:
- gadget.stop()
- resourceTTS.stackRemoveByUuid(uuid)
- return headersStruct, contentStruct
-
-# Register the service into the resource
-resourceGadgetFramework.addService(TDSServiceGadgetFrameworkStopGadgetByUuid)
-
-# ------------------------------------------------------------------------------
-# Declaration of the service "stop_gadget_by_name".
-# ------------------------------------------------------------------------------
-class TDSServiceGadgetFrameworkStopGadgetByName(TDSService):
-
- def configure(self):
- self.parametersDict = {
- 'name' : 'string',
- }
- self.minimalUserLevel = TDS_CLIENT_LEVEL_ANONYMOUS
- self.exclusiveExecution = False
- self.name = "stop_gadget_by_name"
- self.comment = "Stop a gadget by it name."
-
- def execute(self, id, parameters):
- headersStruct = self.getDefaultHeadersStruct()
- contentStruct = self.getDefaultContentStruct()
- contentStruct['root']['result'] = getStrError(E_TDREST_SUCCESS)
- name = parameters['name']
- gadgetStopped = False
- gadget = resourceGadgetFramework.getGadgetsContainer().getGadgetByName(name)
- if gadget != None:
- gadget.stop()
- resourceTTS.stackRemoveByUuid(gadget.getDescription().getUuid())
- return headersStruct, contentStruct
-
-# Register the service into the resource
-resourceGadgetFramework.addService(TDSServiceGadgetFrameworkStopGadgetByName)
-
-# ------------------------------------------------------------------------------
-# Declaration of the service "stop_all_gadgets".
-# ------------------------------------------------------------------------------
-class TDSServiceGadgetFrameworkStopAllGadgets(TDSService):
-
- def configure(self):
- self.parametersDict = {}
- self.minimalUserLevel = TDS_CLIENT_LEVEL_ANONYMOUS
- self.exclusiveExecution = False
- self.name = "stop_all_gadgets"
- self.comment = "Stop all started gadgets."
-
- def execute(self, id, parameters):
- headersStruct = self.getDefaultHeadersStruct()
- contentStruct = self.getDefaultContentStruct()
- contentStruct['root']['result'] = getStrError(E_TDREST_SUCCESS)
- resourceGadgetFramework.getGadgetsContainer().stopAllGadgets()
- resourceTTS.stackFlushExceptedUuid("0")
- return headersStruct, contentStruct
-
-# Register the service into the resource
-resourceGadgetFramework.addService(TDSServiceGadgetFrameworkStopAllGadgets)
-
-# ------------------------------------------------------------------------------
-# Declaration of the service "insert_gadget".
-# ------------------------------------------------------------------------------
-class TDSServiceGadgetFrameworkInsertGadget(TDSService):
-
- def configure(self):
- self.parametersDict = {
- 'path' : 'string',
- }
- self.minimalUserLevel = TDS_CLIENT_LEVEL_ANONYMOUS
- self.exclusiveExecution = True
- self.name = "insert_gadget"
- self.comment = "Insert a gadget in the container."
-
- def execute(self, id, parameters):
- headersStruct = self.getDefaultHeadersStruct()
- contentStruct = self.getDefaultContentStruct()
- contentStruct['root']['result'] = getStrError(E_TDREST_SUCCESS)
- if not resourceGadgetFramework.insertGadgetInContainer(
- parameters['path']):
- contentStruct['root']['result'] = getStrError(E_TDREST_FAILED)
- return headersStruct, contentStruct
-
-# Register the service into the resource
-resourceGadgetFramework.addService(TDSServiceGadgetFrameworkInsertGadget)
-
-# ------------------------------------------------------------------------------
-# Declaration of the service "remove_gadget".
-# ------------------------------------------------------------------------------
-class TDSServiceGadgetFrameworkRemoveGadget(TDSService):
-
- def configure(self):
- self.parametersDict = {
- 'uuid' : 'string',
- }
- self.minimalUserLevel = TDS_CLIENT_LEVEL_ANONYMOUS
- self.exclusiveExecution = True
- self.name = "remove_gadget"
- self.comment = "Remove a gadget from the container."
-
- def execute(self, id, parameters):
- headersStruct = self.getDefaultHeadersStruct()
- contentStruct = self.getDefaultContentStruct()
- contentStruct['root']['result'] = getStrError(E_TDREST_SUCCESS)
- if not resourceGadgetFramework.removeGadgetFromContainer(
- parameters['uuid']):
- contentStruct['root']['result'] = getStrError(E_TDREST_FAILED)
- return headersStruct, contentStruct
-
-# Register the service into the resource
-resourceGadgetFramework.addService(TDSServiceGadgetFrameworkRemoveGadget)
-
-# ------------------------------------------------------------------------------
-# Declaration of the service "create_configuration".
-# ------------------------------------------------------------------------------
-class TDSServiceGadgetFrameworkCreateConfiguration(TDSService):
-
- def configure(self):
- self.parametersDict = {
- 'uuid' : 'string',
- 'parameters' : 'string',
- 'name' : 'string',
- 'hiddenParameters' : 'string'
- }
- self.minimalUserLevel = TDS_CLIENT_LEVEL_ANONYMOUS
- self.exclusiveExecution = False
- self.name = "create_configuration"
- self.comment = "Create a configuration of gadget."
-
- def execute(self, id, parameters):
- headersStruct = self.getDefaultHeadersStruct()
- contentStruct = self.getDefaultContentStruct()
- contentStruct['root']['result'] = getStrError(E_TDREST_SUCCESS)
- uuid = parameters['uuid']
- params = {}
- splParams = parameters['parameters'].split("|")
- for paramStruct in splParams:
- param = paramStruct.split("=")
- if len(param) == 2:
- params[param[0]] = param[1]
- hiddenParameters = parameters['hiddenParameters'].split("|")
- name = parameters['name']
- if not resourceGadgetFramework.createConfiguration(uuid, params,
- name, hiddenParameters):
- contentStruct['root']['result'] = getStrError(E_TDREST_FAILED)
- return headersStruct, contentStruct
-
-# Register the service into the resource
-resourceGadgetFramework.addService(TDSServiceGadgetFrameworkCreateConfiguration)
-
-# ------------------------------------------------------------------------------
-# Declaration of the service "update_configuration_name".
-# ------------------------------------------------------------------------------
-class TDSServiceGadgetFrameworkUpdateConfigurationName(TDSService):
-
- def configure(self):
- self.parametersDict = {
- 'uuid' : 'string',
- 'name' : 'string',
- }
- self.minimalUserLevel = TDS_CLIENT_LEVEL_ANONYMOUS
- self.exclusiveExecution = False
- self.name = "update_configuration_name"
- self.comment = "Update the name of a configuration."
-
- def execute(self, id, parameters):
- headersStruct = self.getDefaultHeadersStruct()
- contentStruct = self.getDefaultContentStruct()
- contentStruct['root']['result'] = getStrError(E_TDREST_SUCCESS)
- uuid = parameters['uuid']
- name = parameters['name']
- if not resourceGadgetFramework.updateConfigurationName(uuid, name):
- contentStruct['root']['result'] = getStrError(E_TDREST_FAILED)
- return headersStruct, contentStruct
-
-# Register the service into the resource
-resourceGadgetFramework.addService(TDSServiceGadgetFrameworkUpdateConfigurationName)
-
-# ------------------------------------------------------------------------------
-# Declaration of the service "update_configuration_parameters".
-# ------------------------------------------------------------------------------
-class TDSServiceGadgetFrameworkUpdateConfigurationParameters(TDSService):
-
- def configure(self):
- self.parametersDict = {
- 'uuid' : 'string',
- 'parameters' : 'string',
- 'hiddenParameters' : 'string'
- }
- self.minimalUserLevel = TDS_CLIENT_LEVEL_ANONYMOUS
- self.exclusiveExecution = False
- self.name = "update_configuration_parameters"
- self.comment = "Update the parameters of a configuration."
-
- def execute(self, id, parameters):
- headersStruct = self.getDefaultHeadersStruct()
- contentStruct = self.getDefaultContentStruct()
- contentStruct['root']['result'] = getStrError(E_TDREST_SUCCESS)
- uuid = parameters['uuid']
- params = {}
- splParams = parameters['parameters'].split("|")
- for paramStruct in splParams:
- param = paramStruct.split("=")
- if len(param) == 2:
- params[param[0]] = param[1]
- hiddenParameters = parameters['hiddenParameters'].split("|")
- if not resourceGadgetFramework.updateConfigurationParameters(uuid,
- params, hiddenParameters):
- contentStruct['root']['result'] = getStrError(E_TDREST_FAILED)
- return headersStruct, contentStruct
-
-# Register the service into the resource
-resourceGadgetFramework.addService(TDSServiceGadgetFrameworkUpdateConfigurationParameters)
Deleted: software_suite_v3/smart-core/smart-server/trunk/resources/03_advanced_api/resourceTaskCreation.py
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/resources/03_advanced_api/resourceTaskCreation.py 2009-05-05 08:17:32 UTC (rev 4634)
+++ software_suite_v3/smart-core/smart-server/trunk/resources/03_advanced_api/resourceTaskCreation.py 2009-05-05 13:54:49 UTC (rev 4635)
@@ -1,247 +0,0 @@
-# ==============================================================================
-# Task creation resource.
-# ==============================================================================
-
-# ------------------------------------------------------------------------------
-# Declaration of the resource "task_creation".
-# ------------------------------------------------------------------------------
-class TDSResourceTaskCreation(TDSResource):
-
- # --------------------------------------------------------------------------
- # Inherited methods from TDSResource
- # --------------------------------------------------------------------------
-
- def configure(self):
- self.name = "task_creation"
- self.comment = "Resource to create a scheduled tasks."
- self.fileName = RESOURCE_FILENAME
-
- # --------------------------------------------------------------------------
- # Public methods
- # --------------------------------------------------------------------------
-
- def createTaskStartGadget(self, gadgetUuid, gadgetCommand, gadgetParameters,
- taskType, taskName, weekMask, date, hoursBegin, hoursEnd, delay):
- """Create a task to start a gadget.
- @param gadgetUuid: Gadget uuid.
- @param gadgetCommand: Gadget command.
- @param gadgetParameters: Gadget parameters.
- @param taskType: <EVERY X|EVERY X FROM FULL HOUR|DAILY AT|ONCE AT|
- ONCE DELAYED>
- @param taskName: Task name.
- @param weekMask: Week mask. [True, True, True, True, True, True, True]
- @param date: Date. [Year, Month, Day]
- @param hoursBegin: Hours begin. [Hour, Minute, Second]
- @param hoursEnd: Hours end. [Hour, Minute, Second]
- @param delay: Delay. [Hour, Minute, Second]
- """
- command = "resourceGadgetFramework.startGadget"
- arguments = (gadgetUuid, gadgetCommand, gadgetParameters)
- data = {
- 'commandType' : 'gadget_start',
- 'uuid' : gadgetUuid,
- 'command' : gadgetCommand,
- 'parameters' : gadgetParameters,
- }
- return resourceScheduler.createTask(command, arguments, taskType,
- taskName, weekMask, date, hoursBegin, hoursEnd, delay, data)
-
- def createTaskStopGadget(self, gadgetUuid, taskType, taskName, weekMask,
- date, hoursBegin, hoursEnd, delay):
- """Create a sheduled task to stop a gadget.
- @param gadgetUuid: Gadget uuid.
- @param taskType: <EVERY X|EVERY X FROM FULL HOUR|DAILY AT|ONCE AT|
- ONCE DELAYED>
- @param taskName: Task name.
- @param weekMask: Week mask. [True, True, True, True, True, True, True]
- @param date: Date. [Year, Month, Day]
- @param hoursBegin: Hours begin. [Hour, Minute, Second]
- @param hoursEnd: Hours end. [Hour, Minute, Second]
- @param delay: Delay. [Hour, Minute, Second]
- """
- command = "resourceGadgetFramework.stopGadget"
- arguments = (gadgetUuid,)
- data = {
- 'commandType' : 'gadget_stop',
- 'uuid' : gadgetUuid,
- }
- return resourceScheduler.createTask(command, arguments, taskType,
- taskName, weekMask, date, hoursBegin, hoursEnd, delay, data)
-
- def createTaskPlayAttitune(self, attituneName, taskType, taskName, weekMask,
- date, hoursBegin, hoursEnd, delay):
- """Create a task to start an attitune.
- @param attituneName: Attitune name.
- @param taskType: <EVERY X|EVERY X FROM FULL HOUR|DAILY AT|ONCE AT|
- ONCE DELAYED>
- @param taskName: Task name.
- @param weekMask: Week mask. [True, True, True, True, True, True, True]
- @param date: Date. [Year, Month, Day]
- @param hoursBegin: Hours begin. [Hour, Minute, Second]
- @param hoursEnd: Hours end. [Hour, Minute, Second]
- @param delay: Delay. [Hour, Minute, Second]
- """
- command = "resourceAttituneManager.playAttitune"
- arguments = (attituneName, 0.0)
- data = {
- 'commandType' : 'attitune_play',
- 'attituneName' : attituneName,
- }
- return resourceScheduler.createTask(command, arguments, taskType,
- taskName, weekMask, date, hoursBegin, hoursEnd, delay, data)
-
-# Create an instance of the resource
-resourceTaskCreation = TDSResourceTaskCreation("resourceTaskCreation")
-# Register the resource into the resources manager
-resourcesManager.addResource(resourceTaskCreation)
-
-# ------------------------------------------------------------------------------
-# Declaration of the service "start_gadget".
-# ------------------------------------------------------------------------------
-class TDSServiceTaskCreationStartGadgetTask(TDSService):
-
- def configure(self):
- self.parametersDict = {
- 'gadget_uuid' : 'string',
- 'gadget_command' : 'string',
- 'gadget_parameters' : 'string',
- 'task_type' : '<EVERY X|EVERY X FROM FULL HOUR|DAILY AT|ONCE AT|ONCE DELAYED>',
- 'task_name' : 'string',
- 'week_mask' : 'string',
- 'date' : 'string',
- 'hoursBegin' : 'string',
- 'hoursEnd' : 'string',
- 'delay' : 'string',
- }
- self.minimalUserLevel = TDS_CLIENT_LEVEL_ANONYMOUS
- self.exclusiveExecution = False
- self.name = "start_gadget"
- self.comment = "Create a scheduled task to start a gadget."
-
- def execute(self, id, parameters):
- headersStruct = self.getDefaultHeadersStruct()
- contentStruct = self.getDefaultContentStruct()
- contentStruct['root']['result'] = getStrError(E_TDREST_SUCCESS)
- gadgetUuid = parameters['gadget_uuid']
- gadgetCommand = parameters['gadget_command']
- gadgetParameters = {}
- splParams = parameters['gadget_parameters'].split("|")
- for paramStruct in splParams:
- param = paramStruct.split("=")
- if len(param) == 2:
- gadgetParameters[param[0]] = param[1]
- taskType = parameters['task_type']
- taskName = parameters['task_name']
- weekMask = resourceScheduler.weekMaskStringToList(parameters['week_mask'])
- date = resourceScheduler.dateStringToList(parameters['date'])
- hoursBegin = resourceScheduler.timeStringToList(parameters['hoursBegin'])
- hoursEnd = resourceScheduler.timeStringToList(parameters['hoursEnd'])
- delay = resourceScheduler.timeStringToList(parameters['delay'])
- id, name = resourceTaskCreation.createTaskStartGadget(gadgetUuid,
- gadgetCommand, gadgetParameters, taskType, taskName, weekMask, date,
- hoursBegin, hoursEnd, delay)
- if id != None:
- contentStruct['root']['data'] = {
- 'id' : id,
- 'name' : name,
- }
- else:
- contentStruct['root']['result'] = getStrError(E_TDREST_FAILED)
- return headersStruct, contentStruct
-
-# Register the service into the resource
-resourceTaskCreation.addService(TDSServiceTaskCreationStartGadgetTask)
-
-# ------------------------------------------------------------------------------
-# Declaration of the service "stop_gadget".
-# ------------------------------------------------------------------------------
-class TDSServiceTaskCreationStopGadgetTask(TDSService):
-
- def configure(self):
- self.parametersDict = {
- 'gadget_uuid' : 'string',
- 'task_type' : '<EVERY X|EVERY X FROM FULL HOUR|DAILY AT|ONCE AT|ONCE DELAYED>',
- 'task_name' : 'string',
- 'week_mask' : 'string',
- 'date' : 'string',
- 'hoursBegin' : 'string',
- 'hoursEnd' : 'string',
- 'delay' : 'string',
- }
- self.minimalUserLevel = TDS_CLIENT_LEVEL_ANONYMOUS
- self.exclusiveExecution = False
- self.name = "stop_gadget"
- self.comment = "Create a scheduled task to stop a gadget."
-
- def execute(self, id, parameters):
- headersStruct = self.getDefaultHeadersStruct()
- contentStruct = self.getDefaultContentStruct()
- contentStruct['root']['result'] = getStrError(E_TDREST_SUCCESS)
- gadgetUuid = parameters['gadget_uuid']
- taskType = parameters['task_type']
- taskName = parameters['task_name']
- weekMask = resourceScheduler.weekMaskStringToList(parameters['week_mask'])
- date = resourceScheduler.dateStringToList(parameters['date'])
- hoursBegin = resourceScheduler.timeStringToList(parameters['hoursBegin'])
- hoursEnd = resourceScheduler.timeStringToList(parameters['hoursEnd'])
- delay = resourceScheduler.timeStringToList(parameters['delay'])
- id, name = resourceTaskCreation.createTaskStopGadget(gadgetUuid,
- taskType, taskName, weekMask, date, hoursBegin, hoursEnd, delay)
- if id != None:
- contentStruct['root']['data'] = {
- 'id' : id,
- 'name' : name,
- }
- else:
- contentStruct['root']['result'] = getStrError(E_TDREST_FAILED)
- return headersStruct, contentStruct
-
-# Register the service into the resource
-resourceTaskCreation.addService(TDSServiceTaskCreationStopGadgetTask)
-
-# ------------------------------------------------------------------------------
-# Declaration of the service "play_attitune".
-# ------------------------------------------------------------------------------
-class TDSServiceTaskCreationPlayAttitune(TDSService):
-
- def configure(self):
- self.parametersDict = {
- 'attitune_name' : 'string',
- 'task_type' : '<EVERY X|EVERY X FROM FULL HOUR|DAILY AT|ONCE AT|ONCE DELAYED>',
- 'task_name' : 'string',
- 'week_mask' : 'string',
- 'date' : 'string',
- 'hoursBegin' : 'string',
- 'hoursEnd' : 'string',
- 'delay' : 'string',
- }
- self.minimalUserLevel = TDS_CLIENT_LEVEL_ANONYMOUS
- self.exclusiveExecution = False
- self.name = "play_attitune"
- self.comment = "Create a scheduled task to play an attitune."
-
- def execute(self, id, parameters):
- headersStruct = self.getDefaultHeadersStruct()
- contentStruct = self.getDefaultContentStruct()
- contentStruct['root']['result'] = getStrError(E_TDREST_SUCCESS)
- attituneName = parameters['attitune_name']
- taskType = parameters['task_type']
- taskName = parameters['task_name']
- weekMask = resourceScheduler.weekMaskStringToList(parameters['week_mask'])
- date = resourceScheduler.dateStringToList(parameters['date'])
- hoursBegin = resourceScheduler.timeStringToList(parameters['hoursBegin'])
- hoursEnd = resourceScheduler.timeStringToList(parameters['hoursEnd'])
- delay = resourceScheduler.timeStringToList(parameters['delay'])
- id, name = resourceTaskCreation.createTaskPlayAttitune(attituneName,
- taskType, taskName, weekMask, date, hoursBegin, hoursEnd, delay)
- if id != None:
- contentStruct['root']['data'] = {
- 'id' : id,
- 'name' : name,
- }
- else:
- contentStruct['root']['result'] = getStrError(E_TDREST_FAILED)
- return headersStruct, contentStruct
-
-# Register the service into the resource
-resourceTaskCreation.addService(TDSServiceTaskCreationPlayAttitune)
Deleted: software_suite_v3/smart-core/smart-server/trunk/resources/03_advanced_api/resourceUserConfiguration.py
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/resources/03_advanced_api/resourceUserConfiguration.py 2009-05-05 08:17:32 UTC (rev 4634)
+++ software_suite_v3/smart-core/smart-server/trunk/resources/03_advanced_api/resourceUserConfiguration.py 2009-05-05 13:54:49 UTC (rev 4635)
@@ -1,159 +0,0 @@
-# ==============================================================================
-# Task creation resource.
-# ==============================================================================
-
-from util.misc.tuxPaths import TUXDROID_LANGUAGE
-from util.misc.tuxPaths import TUXDROID_DEFAULT_LOCUTOR
-from util.misc.tuxPaths import USER_BASE_PATH
-from util.misc.DirectoriesAndFilesTools import *
-
-# ------------------------------------------------------------------------------
-# Declaration of the resource "user_configuration".
-# ------------------------------------------------------------------------------
-class TDSResourceUserConfiguration(TDSResource):
-
- # --------------------------------------------------------------------------
- # Inherited methods from TDSResource
- # --------------------------------------------------------------------------
-
- def configure(self):
- self.name = "user_configuration"
- self.comment = "Resource to manages the user configurations."
- self.fileName = RESOURCE_FILENAME
- # Default configuration
- self.defaultConfiguration = {
- 'auto-start' : False,
- 'configuration_path' : "",
- }
-
- def stop(self):
- self.getConfigurator().store()
-
- def start(self):
- config = self.getConfigurator().load(
- "resourceUserConfiguration.conf",
- self.defaultConfiguration)
- if config['auto-start']:
- self.loadUserDirectory(config['configuration_path'])
-
- # --------------------------------------------------------------------------
- # Public methods
- # --------------------------------------------------------------------------
-
- def loadUserDirectory(self, userDirectory):
- """Load the configuration from a user directory.
- @param userDirectory: User directory (with "MyTux" ...)
- @return: The success of the configuration loading.
- """
- if not os.path.isdir(userDirectory):
- return False
- if userDirectory.split(os.sep)[-1] != "MyTux":
- return False
- # User directories
- userGadgetsDir = os.path.join(userDirectory, "MyTuxGadgets")
- userGadgetsConfigurationsDir = os.path.join(userDirectory,
- "MyTuxGadgetsConfigurations")
- userAttitunesDir = os.path.join(userDirectory, "MyTuxAttitunes")
- userTasksDir = os.path.join(userDirectory, "MyTuxTasks")
- userLocalesConfigFile = os.path.join(userDirectory, "locales.conf")
- MKDirs(userGadgetsDir)
- MKDirs(userGadgetsConfigurationsDir)
- MKDirs(userAttitunesDir)
- MKDirs(userTasksDir)
- # Read the locales configuration
- if not os.path.isfile(userLocalesConfigFile):
- # Create the locales config
- splitedLC = TUXDROID_LANGUAGE.split("_")
- language = splitedLC[0]
- if len(splitedLC) > 1:
- country = splitedLC[1]
- else:
- country = language.upper()
- locutor = TUXDROID_DEFAULT_LOCUTOR
- pitch = 130
- userLocalesConfigDict = {
- 'language' : language,
- 'country' : country,
- 'locutor' : locutor,
- 'pitch' : pitch,
- 'L1' : language,
- 'L2' : language,
- 'GL' : language,
- }
- try:
- open(userLocalesConfigFile, "wb").write(str(userLocalesConfigDict))
- except:
- RMFile(userLocalesConfigFile)
- return False
- else:
- try:
- userLocalesConfigDict = eval(open(
- userLocalesConfigFile, "rb").read())
- except:
- RMFile(userLocalesConfigFile)
- return False
- def async...
[truncated message content] |
|
From: remi <c2m...@c2...> - 2009-05-05 08:17:44
|
Author: remi Date: 2009-05-05 10:17:32 +0200 (Tue, 05 May 2009) New Revision: 4634 Added: software_suite_v3/smart-core/smart-api/python/branches/ software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/branches/ software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/tags/ software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/branches/ software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/tags/ software_suite_v3/smart-core/smart-server/branches/ Log: * added missing 'branches' and 'tags' directories |
|
From: remi <c2m...@c2...> - 2009-05-05 08:13:53
|
Author: remi Date: 2009-05-05 10:13:36 +0200 (Tue, 05 May 2009) New Revision: 4633 Removed: softwares_suite_v3/ Log: * and removed "softwares_suite_v3" repository |
|
From: remi <c2m...@c2...> - 2009-05-05 08:10:39
|
Author: remi Date: 2009-05-05 10:10:27 +0200 (Tue, 05 May 2009) New Revision: 4632 Removed: softwares_suite_v3/community/ Log: * removed old repository |
|
From: remi <c2m...@c2...> - 2009-05-05 08:09:32
|
Author: remi Date: 2009-05-05 10:09:23 +0200 (Tue, 05 May 2009) New Revision: 4631 Added: software_suite_v3/software/plugin/old-gadget-format-transition-to-v3/ Log: * moved gadget v3 with TGF format in this repository in order to translate its to the plugin format (SCP). Copied: software_suite_v3/software/plugin/old-gadget-format-transition-to-v3 (from rev 4630, softwares_suite_v3/community/gadget) |