Author: Gwadavel
Date: 2009-04-08 16:38:25 +0200 (Wed, 08 Apr 2009)
New Revision: 4416

Modified:
   software_suite_v2/software/scripts/pidgin/branches/api_0.3.0/tux_pidgin.py
   software_suite_v2/software/scripts/pidgin/trunk/tux_pidgin.py
Log:
Adde test if server, dongle, radio are connected and for TTS

Modified: 
software_suite_v2/software/scripts/pidgin/branches/api_0.3.0/tux_pidgin.py
===================================================================
--- software_suite_v2/software/scripts/pidgin/branches/api_0.3.0/tux_pidgin.py  
2009-04-08 13:52:39 UTC (rev 4415)
+++ software_suite_v2/software/scripts/pidgin/branches/api_0.3.0/tux_pidgin.py  
2009-04-08 14:38:25 UTC (rev 4416)
@@ -25,6 +25,9 @@
 """
 CHANGES
 =======
+2009/04/08 - version 0.5
+    - Add "cia" says "svn commit" if alias = CIA , channel #tuxdroid on irc
+    - Add test if server, dongle, radio are connected and for TTS
 2008/12/19 - version 0.4
     - Add "away" speaks only if your statut are "away"
 2008/11/26 - version 0.3
@@ -46,8 +49,8 @@
 __author__  = "Thomas CARPENTIER <[email protected]> & Julien Ruchaud \
 & Gwadavel"
 __appname__ = "TuxPidgin"
-__version__ = "0.4"
-__date__    = "2008/12/19"
+__version__ = "0.5"
+__date__    = "2009/04/08"
 __license__ = "GPL"
 
 # -----------------------------------------------
@@ -62,7 +65,7 @@
 import re
 import time
 import sgmllib
-from tuxisalive.api.TuxAPI import *
+from tuxisalive.api.TuxAPI import * # For api 0.3.0
 #------------------------------------------------
 #------------------------------------------------
 
@@ -138,13 +141,22 @@
 
        
 def tuxConnect():
-       """ Wait connected """
-       
-       tux.server.autoConnect(CLIENT_LEVEL_RESTRICTED, 'TuxPidgin', 'NONE')
-       tux.server.waitConnected(10.0)
-       tux.dongle.waitConnected(10.0)
-       tux.radio.waitConnected(10.0)
-       
+    """ Wait connected """
+    tux.server.autoConnect(CLIENT_LEVEL_RESTRICTED, 'TuxPidgin', 'NONE')    
+    if tux.server.waitConnected(10.0):
+        if tux.dongle.waitConnected(10.0):  
+            if tux.radio.waitConnected(10.0):
+                return True
+            else:
+                print "radio not connected"
+                return False
+        else:
+            print "radio not connected"
+            return False
+    else:
+        print "server not connected"
+        return False
+
 def away():
     """ Test status away ou available """
     
@@ -169,13 +181,12 @@
         alias = purple.PurpleBuddyGetAlias(buddy)
     else:
         alias = name     
-    #text = re.sub("<.*?>", "", text)#html2text
-    if tgp_cia and alias[:3].upper() == "CIA":
-        text = LANGUAGE["commit"]
-    else:
-        MessageP = MessageParser()
-        message = MessageP.strip(message)
-        text = "%s %s %s" % (alias, LANGUAGE["say"], message)
+        if tgp_cia and alias[:3].upper() == "CIA":
+            text = LANGUAGE["commit"]
+        else:
+            MessageP = MessageParser()
+            message = MessageP.strip(message)
+            text = "%s %s %s" % (alias, LANGUAGE["say"], message)
     text = text.encode('utf-8')
     tux_speak(text)  
   
@@ -195,18 +206,19 @@
        return        
     if tux.access.waitAcquire(10.0, ACCESS_PRIORITY_NORMAL):
         tux.mouth.open()
-        tux.tts.speak(text)
+        if not tux.tts.speak(text):
+            print "TTS error"
         tux.mouth.close()
         tux.access.release()
 
 # Main
 
 tux = TuxAPI(tgp_ip, tgp_port)
-tuxConnect()
+if not tuxConnect():
+    sys.exit(1)
 tux.tts.setEncoding("utf-8")
+lang()
 
-
-lang()
 bus = dbus.SessionBus()
 
 try:
@@ -217,11 +229,12 @@
     tux_speak(LANGUAGE["pidginoff"])
     sys.exit(1)
 
-if tgp_im: bus.add_signal_receiver(received_im_msg,
+if tgp_im: 
+    bus.add_signal_receiver(received_im_msg,
                         dbus_interface = "im.pidgin.purple.PurpleInterface",
                         signal_name = "ReceivedImMsg")
 
-bus.add_signal_receiver(buddy_signed_on,
+    bus.add_signal_receiver(buddy_signed_on,
                         dbus_interface = "im.pidgin.purple.PurpleInterface",
                         signal_name = "BuddySignedOn")
                         
@@ -231,7 +244,9 @@
                         signal_name = "ReceivedChatMsg")                       
                        
 
 tux_speak(LANGUAGE["pidginon"])
+
 loop = gobject.MainLoop()
 loop.run()
+
 tux.server.disconnect()
 tux.destroy()

Modified: software_suite_v2/software/scripts/pidgin/trunk/tux_pidgin.py
===================================================================
--- software_suite_v2/software/scripts/pidgin/trunk/tux_pidgin.py       
2009-04-08 13:52:39 UTC (rev 4415)
+++ software_suite_v2/software/scripts/pidgin/trunk/tux_pidgin.py       
2009-04-08 14:38:25 UTC (rev 4416)
@@ -25,6 +25,9 @@
 """
 CHANGES
 =======
+2009/04/08 - version 0.5
+    - Add "cia" says "svn commit" if alias = CIA , channel #tuxdroid on irc
+    - Add test if server, dongle, radio are connected and for TTS
 2008/12/19 - version 0.4
     - Add "away" speaks only if your statut are "away"
 2008/11/26 - version 0.3
@@ -46,8 +49,8 @@
 __author__  = "Thomas CARPENTIER <[email protected]> & Julien Ruchaud \
 & Gwadavel"
 __appname__ = "TuxPidgin"
-__version__ = "0.4"
-__date__    = "2008/12/19"
+__version__ = "0.5"
+__date__    = "2009/04/08"
 __license__ = "GPL"
 
 # -----------------------------------------------
@@ -62,7 +65,7 @@
 import re
 import time
 import sgmllib
-from tuxisalive.api import *
+from tuxisalive.api import * 
 #------------------------------------------------
 #------------------------------------------------
 
@@ -138,13 +141,22 @@
 
        
 def tuxConnect():
-       """ Wait connected """
-       
-       tux.server.autoConnect(CLIENT_LEVEL_RESTRICTED, 'TuxPidgin', 'NONE')
-       tux.server.waitConnected(10.0)
-       tux.dongle.waitConnected(10.0)
-       tux.radio.waitConnected(10.0)
-       
+    """ Wait connected """
+    tux.server.autoConnect(CLIENT_LEVEL_RESTRICTED, 'TuxPidgin', 'NONE')    
+    if tux.server.waitConnected(10.0):
+        if tux.dongle.waitConnected(10.0):  
+            if tux.radio.waitConnected(10.0):
+                return True
+            else:
+                print "radio not connected"
+                return False
+        else:
+            print "radio not connected"
+            return False
+    else:
+        print "server not connected"
+        return False
+
 def away():
     """ Test status away ou available """
     
@@ -169,13 +181,12 @@
         alias = purple.PurpleBuddyGetAlias(buddy)
     else:
         alias = name     
-    #text = re.sub("<.*?>", "", text)#html2text
-    if tgp_cia and alias[:3].upper() == "CIA":
-        text = LANGUAGE["commit"]
-    else:
-        MessageP = MessageParser()
-        message = MessageP.strip(message)
-        text = "%s %s %s" % (alias, LANGUAGE["say"], message)
+        if tgp_cia and alias[:3].upper() == "CIA":
+            text = LANGUAGE["commit"]
+        else:
+            MessageP = MessageParser()
+            message = MessageP.strip(message)
+            text = "%s %s %s" % (alias, LANGUAGE["say"], message)
     text = text.encode('utf-8')
     tux_speak(text)  
   
@@ -195,18 +206,19 @@
        return        
     if tux.access.waitAcquire(10.0, ACCESS_PRIORITY_NORMAL):
         tux.mouth.open()
-        tux.tts.speak(text)
+        if not tux.tts.speak(text):
+            print "TTS error"
         tux.mouth.close()
         tux.access.release()
 
 # Main
 
 tux = TuxAPI(tgp_ip, tgp_port)
-tuxConnect()
+if not tuxConnect():
+    sys.exit(1)
 tux.tts.setEncoding("utf-8")
+lang()
 
-
-lang()
 bus = dbus.SessionBus()
 
 try:
@@ -217,11 +229,12 @@
     tux_speak(LANGUAGE["pidginoff"])
     sys.exit(1)
 
-if tgp_im: bus.add_signal_receiver(received_im_msg,
+if tgp_im: 
+    bus.add_signal_receiver(received_im_msg,
                         dbus_interface = "im.pidgin.purple.PurpleInterface",
                         signal_name = "ReceivedImMsg")
 
-bus.add_signal_receiver(buddy_signed_on,
+    bus.add_signal_receiver(buddy_signed_on,
                         dbus_interface = "im.pidgin.purple.PurpleInterface",
                         signal_name = "BuddySignedOn")
                         
@@ -231,7 +244,9 @@
                         signal_name = "ReceivedChatMsg")                       
                        
 
 tux_speak(LANGUAGE["pidginon"])
+
 loop = gobject.MainLoop()
 loop.run()
+
 tux.server.disconnect()
 tux.destroy()


------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to