Author: jerome
Date: 2009-03-12 13:57:59 +0100 (Thu, 12 Mar 2009)
New Revision: 3996

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/fr.po
   
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/gadget.pot
   
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/help.html
Log:
* Fixed some litle things to be completally compatible with CC ( tested on 
Linux and Windblows ).

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-03-12 12:56:34 UTC (rev 3995)
+++ 
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/executables/tuxdroid-gadget-maxlight.py
   2009-03-12 12:57:59 UTC (rev 3996)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 # -----------------------------------------------------------------------------
@@ -25,6 +25,8 @@
 """
 CHANGES
 =======
+2009/12/03 - version 0.6
+    - Updated the gadget to work with the control center.
 2008/12/19 - version 0.5:
     - Add says the % of light at the end
     - Test if tgp_ip and tgp_port exist
@@ -58,67 +60,38 @@
 __license__ = "GPL"
 
 
-
-from tuxisalive.api import *
 import os
+import locale
+import gettext
+from tuxisalive.api import *
 from time import sleep
 
-LANGUAGE = ""
 
-FR = {"search": "Je commence la recherche", "stop": "La lumière maximum est 
ici",
-"charger": "Déconnectez le chargeur et relancez le programme"}
-
-EN = {"search": "I began research", "stop": "Light up is here",
-"charger": "Unplugged the charger and restart the program"}
-
-
-def lang():
-    """ Search LANGUAGE in os.environ """
-
-    global LANGUAGE
-    
-    if "fr" == os.environ['tgp_language']: 
-        locutor = os.environ['tgp_locutor'] 
-        pitch = int(os.environ['tgp_pitch'])
-        LANGUAGE = FR
-    elif "en" == os.environ['tgp_language']:
-        locutor = os.environ['tgp_locutor'] 
-        pitch = int(os.environ['tgp_pitch'])
-        LANGUAGE = EN 
-    else: # for other language
-        locutor = "Ryan" 
-        pitch = 100
-        LANGUAGE = EN
-    tux.tts.setLocutor(locutor)
-    tux.tts.setPitch(pitch)
-
 def message(mes):
-    """ get message from langage dictionary """
+    '''
+    Get message from langage dictionary 
+    '''
+    print "message \"" + mes + "\""  
     
-    text = LANGUAGE[mes]
-    speak(text)  
-    
-def speak(text):
-    """ Tux talks """
-    
-    tux.mouth.open()
-    tux.tts.speak(text)
-    tux.mouth.close()
 
 def tuxConnect():
-    """ Wait connected """
+    '''
+    Wait connected
+    '''
 
-    tux.server.autoConnect(CLIENT_LEVEL_RESTRICTED, 'TuxMaxLight', 'NONE')
+    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)
 
+    
 def search():
-       """ Search maximum light """
+       '''
+    Search maximum light
+    '''
 
        l_max = 0 # Light Max
-       message("search")
        tux.spinning.leftOnAsync((2.0), 4)
        # Turn on left 2 turns, asynchrone mode
        sleep(1) # wait Tux began to turn
@@ -129,9 +102,12 @@
                        l_max = lum // 1
        return l_max # Return Light Max
 
+    
 def stop(l_stop):
-    """ 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 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, 2)
     sleep(1)
@@ -142,20 +118,26 @@
         if lum >= l_stop:
             tux.spinning.off()
             break
-    message("stop")
-    speak(str(int(lum)) + "%%")
+    message("Light up is here")
+    message(str(int(lum)) + "%%")
 
+
+tgp_language = "en"
+tgp_ip = "127.0.0.1"
+tgp_port = 270    
+
+if "tgp_language" in os.environ:
+    tgp_language = os.environ["tgp_language"]
+
 # Test if tgp_ip and tgp_port exist
-if "tgp_ip" not in os.environ:
-    tgp_ip = "127.0.0.1"
-if "tgp_port" not in os.environ:
-    tgp_port = 270
+if "tgp_ip" in os.environ:
+    tgp_ip = os.environ["tgp_ip"]
+if "tgp_port" in os.environ:
+    tgp_port = int(os.environ["tgp_port"])
 
 tux = TuxAPI(tgp_ip, tgp_port)
 
 if tuxConnect():
-    tux.tts.setEncoding(encoding='utf-8')
-    lang()
 
     # Test if charger are plugged
     if tux.status.requestOne('charger_state')[0] == 'UNPLUGGED':
@@ -165,7 +147,7 @@
         stop(light)    # stop
         tux.flippers.down()
     else:
-        message("charger")
+        message("Unplugged the charger and restart the program")
 tux.access.release()
 tux.server.disconnect()
 tux.destroy()

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-03-12 12:56:34 UTC (rev 3995)
+++ 
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/fr.po
   2009-03-12 12:57:59 UTC (rev 3996)
@@ -1,5 +1,12 @@
+
 msgid "Max light gadget"
-msgstr "Gadget Lumière maximum"
+msgstr "Gadget lumière maximum"
 
 msgid "Tux seeks maximum light"
-msgstr "Tux cherche la lumière maximum"
+msgstr "Tux cherche la lumière maximum"
+
+msgid "Light up is here"
+msgstr "La lumière maximum est ici"
+
+msgid "Unplugged the charger and restart the program"
+msgstr "Déconnectez le chargeur et relancez le programme"

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-03-12 12:56:34 UTC (rev 3995)
+++ 
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/gadget.pot
      2009-03-12 12:57:59 UTC (rev 3996)
@@ -1,3 +1,4 @@
+
 msgid "Max light gadget"
 msgstr ""
 
@@ -2,2 +3,8 @@
 msgid "Tux seeks maximum light"
+msgstr ""
+
+msgid "Light up is here"
+msgstr ""
+
+msgid "Unplugged the charger and restart the program"
 msgstr ""

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-03-12 12:56:34 UTC (rev 3995)
+++ 
software_suite_v2/software/gadgets/tuxdroid-gadget-maxlight/trunk/resources/help.html
       2009-03-12 12:57:59 UTC (rev 3996)
@@ -1,6 +1,6 @@
 <html>
 <body>
-<font size="3" face="Verdana, Arial, Helvetica, sans-serif">This gadget will 
make Tux Dro�d 
+<font size="3" face="Verdana, Arial, Helvetica, sans-serif">This gadget will 
make Tux Droïd 
 seeks maximum light. Drag-and-drop this gadget into "My Favorites" or "My 
alerts" to enable it,
  make sure to unplug charger <br>
 </font> 


------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to