[tuxdroid-svn] r376 - api/python/trunk
Status: Beta
Brought to you by:
ks156
From: jaguarondi <c2m...@c2...> - 2007-06-14 22:04:28
|
Author: jaguarondi Date: 2007-06-15 00:02:34 +0200 (Fri, 15 Jun 2007) New Revision: 376 Modified: api/python/trunk/tuxapi_class.py Log: * To follow our python coding style guidelines, lines have been wrapped at 80 characters maximum and the continued lines have been indented by 2 tabs. Modified: api/python/trunk/tuxapi_class.py =================================================================== --- api/python/trunk/tuxapi_class.py 2007-06-14 20:58:04 UTC (rev 375) +++ api/python/trunk/tuxapi_class.py 2007-06-14 22:02:34 UTC (rev 376) @@ -242,7 +242,8 @@ #-------------------------------------------------------------------------- # SYSTEM function #-------------------------------------------------------------------------- - def _insert_lock_in_list(self,data_to_match_list,cond_lock_mutex,returned_data): + def _insert_lock_in_list(self,data_to_match_list,cond_lock_mutex, \ + returned_data): # lock[0] : list of the possible frames to match # lock[1] : condition mutex # lock[2] : data returned @@ -353,10 +354,12 @@ #Remote button if ord(data[4])==DATAS_STATUS_IR_CODE: if self.event.on_remote_bt[ord(data[5])]!=None: - thread.start_new_thread(self.event.on_remote_bt[ord(data[5])], ()) + thread.start_new_thread( \ + self.event.on_remote_bt[ord(data[5])], ()) #self.event.on_remote_bt[ord(data[5])]() if self.event.on_remote!=None: - thread.start_new_thread(self.event.on_remote, (ord(data[5]),)) + thread.start_new_thread( \ + self.event.on_remote, (ord(data[5]),)) #self.event.on_remote(ord(data[5])) #Mouth open if ord(data[4])==DATAS_STATUS_MOUTH_OPEN_POSITION: @@ -678,7 +681,8 @@ Example: >>> var=tux.sys.time() """ - return (time.localtime()[3]*3600)+(time.localtime()[4]*60)+time.localtime()[5] + return (time.localtime()[3]*3600)+(time.localtime()[4]*60)+ \ + time.localtime()[5] #-------------------------------------------------------------------------- # Wait a time in seconds @@ -745,7 +749,8 @@ Example: >>> tux.sys.add_time_event(CT_SHELL,'xmms',9999,99,99,8,5,0) """ - self.events_list.append([cmd_type,cmd,year,month,day,hour,minute,second]) + self.events_list.append([cmd_type,cmd,year,month,day,hour, \ + minute,second]) #-------------------------------------------------------------------------- # Clear the time events of the time event handler @@ -769,11 +774,11 @@ def event_due(event): now = time.localtime() return event[2] in [now[0], 9999]\ - and event[3] in [now[1], 99]\ - and event[4] in [now[2], 99]\ - and event[5] in [now[3], 99]\ - and event[6] in [now[4], 99]\ - and event[7] in [now[5], 99] + and event[3] in [now[1], 99]\ + and event[4] in [now[2], 99]\ + and event[5] in [now[3], 99]\ + and event[6] in [now[4], 99]\ + and event[7] in [now[5], 99] while self.parent.daemon.connected: for event in self.events_list: @@ -1109,14 +1114,14 @@ # create a list of frames to match data_to_match_list = [] # create and insert a frame to match - data_to_match = (SOURCE_TUX,SS_DEFAULT,DATA_TP_RSP,\ - SUBDATA_TP_STATUS,DATA_STATUS,DATA_VALUE,0,0,0,0,0,\ - 0,0,0,0,0) + data_to_match = (SOURCE_TUX,SS_DEFAULT,DATA_TP_RSP,SUBDATA_TP_STATUS, + DATA_STATUS,DATA_VALUE,0,0,0,0,0,0,0,0,0,0) data_to_match_list.append(data_to_match) # create empty frame returned returned_data = [] # insert theses settings in the lock list - self.parent._insert_lock_in_list(data_to_match_list,cond_lock_mutex,returned_data) + self.parent._insert_lock_in_list(data_to_match_list,cond_lock_mutex, \ + returned_data) # wait the lock has unblocked. With a time-out cond_lock_mutex.acquire() cond_lock_mutex.wait(time_out) @@ -1177,24 +1182,22 @@ # create a list of frames to match data_to_match_list = [] # create and insert a frame to match - data_to_match = (SOURCE_TUX,SS_DEFAULT,DATA_TP_RSP,\ - SUBDATA_TP_STATUS,DATAS_STATUS_HEAD_PUSH_SWITCH,1,0,0,0,0,0,\ - 0,0,0,0,0) + data_to_match = (SOURCE_TUX,SS_DEFAULT, DATA_TP_RSP, SUBDATA_TP_STATUS, + DATAS_STATUS_HEAD_PUSH_SWITCH,1,0,0,0,0,0,0,0,0,0,0) data_to_match_list.append(data_to_match) # create and insert a frame to match - data_to_match = (SOURCE_TUX,SS_DEFAULT,DATA_TP_RSP,\ - SUBDATA_TP_STATUS,DATAS_STATUS_LEFT_WING_PUSH,1,0,0,0,0,0,\ - 0,0,0,0,0) + data_to_match = (SOURCE_TUX,SS_DEFAULT,DATA_TP_RSP,SUBDATA_TP_STATUS, + DATAS_STATUS_LEFT_WING_PUSH,1,0,0,0,0,0,0,0,0,0,0) data_to_match_list.append(data_to_match) # create and insert a frame to match - data_to_match = (SOURCE_TUX,SS_DEFAULT,DATA_TP_RSP,\ - SUBDATA_TP_STATUS,DATAS_STATUS_RIGHT_WING_PUSH,1,0,0,0,0,0,\ - 0,0,0,0,0) + data_to_match = (SOURCE_TUX,SS_DEFAULT,DATA_TP_RSP,SUBDATA_TP_STATUS, + DATAS_STATUS_RIGHT_WING_PUSH,1,0,0,0,0,0,0,0,0,0,0) data_to_match_list.append(data_to_match) # create empty frame returned returned_data = [] # insert theses settings in the lock list - self.parent._insert_lock_in_list(data_to_match_list,cond_lock_mutex,returned_data) + self.parent._insert_lock_in_list(data_to_match_list,cond_lock_mutex, \ + returned_data) # wait the lock has unblocked. With a time-out cond_lock_mutex.acquire() cond_lock_mutex.wait(time_out) @@ -1471,14 +1474,14 @@ # create a list of frames to match data_to_match_list = [] # create and insert a frame to match - data_to_match = (SOURCE_TUX,SS_DEFAULT,DATA_TP_ACK_CMD,\ - 999,999,999,999,999,999,999,999,\ - 999,999,999,999,999) + data_to_match = (SOURCE_TUX,SS_DEFAULT,DATA_TP_ACK_CMD, \ + 999,999,999,999,999,999,999,999,999,999,999,999,999) data_to_match_list.append(data_to_match) # create empty frame returned returned_data = [] # insert theses settings in the lock list - self.parent._insert_lock_in_list(data_to_match_list,cond_lock_mutex,returned_data) + self.parent._insert_lock_in_list(data_to_match_list,cond_lock_mutex, \ + returned_data) # wait the lock has unblocked. With a time-out cond_lock_mutex.acquire() cond_lock_mutex.wait(2) @@ -1511,8 +1514,8 @@ """ if not self.parent.daemon.connected: return 2 - data=(DEST_TUX,SD_DEFAULT,DATA_TP_CMD,SUBDATA_TP_STRUCT\ - ,fct,cmd,param1,param2,param3,0,0,0,0,0,0,0) + data=(DEST_TUX,SD_DEFAULT,DATA_TP_CMD,SUBDATA_TP_STRUCT, \ + fct,cmd,param1,param2,param3,0,0,0,0,0,0,0) self.parent.sock.send("".join( [chr(x) for x in data] )) if self.no_ack: return 2 @@ -1539,8 +1542,8 @@ """ if not self.parent.daemon.connected: return 2 - data=(DEST_TUX,SD_DEFAULT,DATA_TP_CMD,SUBDATA_TP_RAW,\ - cmd,param1,param2,param3,0,0,0,0,0,0,0,0) + data=(DEST_TUX,SD_DEFAULT,DATA_TP_CMD,SUBDATA_TP_RAW, \ + cmd,param1,param2,param3,0,0,0,0,0,0,0,0) self.parent.sock.send("".join( [chr(x) for x in data] )) if self.no_ack: return 2 @@ -1562,8 +1565,10 @@ >>> tux.cmd.eyes_on() >>> tux.cmd.eyes_on(2) """ - self.last_ack=self.structured(TUX_CMD_STRUCT_EYES,TUX_CMD_STRUCT_SUB_ON,count,0,0) - self.parent.event.wait_status(DATAS_STATUS_EYES_POSITION_COUNTER,0,(0.3*count)) + self.last_ack=self.structured(TUX_CMD_STRUCT_EYES, \ + TUX_CMD_STRUCT_SUB_ON,count,0,0) + self.parent.event.wait_status(DATAS_STATUS_EYES_POSITION_COUNTER, \ + 0,(0.3*count)) #-------------------------------------------------------------------------- # Send a command to tux for opening the eyes @@ -1621,7 +1626,8 @@ Example: >>> tux.cmd.eyes_off() """ - self.last_ack=self.structured(TUX_CMD_STRUCT_EYES,TUX_CMD_STRUCT_SUB_OFF,0,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_EYES, \ + TUX_CMD_STRUCT_SUB_OFF,0,0,0) #-------------------------------------------------------------------------- # Send a command to tux for moving the mouth @@ -1638,8 +1644,10 @@ >>> tux.cmd.mouth_on() >>> tux.cmd.mouth_on(2) """ - self.last_ack=self.structured(TUX_CMD_STRUCT_MOUTH,TUX_CMD_STRUCT_SUB_ON,count,0,0) - self.parent.event.wait_status(DATAS_STATUS_MOUTH_POSITION_COUNTER,0,(0.3*count)) + self.last_ack=self.structured(TUX_CMD_STRUCT_MOUTH, \ + TUX_CMD_STRUCT_SUB_ON,count,0,0) + self.parent.event.wait_status(DATAS_STATUS_MOUTH_POSITION_COUNTER, \ + 0,(0.3*count)) #-------------------------------------------------------------------------- # Send a command to tux for moving the mouth in free mode @@ -1697,7 +1705,8 @@ Example: >>> tux.cmd.mouth_off() """ - self.last_ack=self.structured(TUX_CMD_STRUCT_MOUTH,TUX_CMD_STRUCT_SUB_OFF,0,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_MOUTH, \ + TUX_CMD_STRUCT_SUB_OFF,0,0,0) #-------------------------------------------------------------------------- # Send a command to tux for moving the wings @@ -1717,10 +1726,10 @@ >>> tux.cmd.wings_on(2) (2 movements) >>> tux.cmd.wings_on(2,5) (2 movements and speed=5) """ - self.last_ack=self.structured(TUX_CMD_STRUCT_WINGS,\ - TUX_CMD_STRUCT_SUB_ON,count,speed,0) - self.parent.event.wait_status(DATAS_STATUS_WINGS_POSITION_COUNTER\ - ,0,(0.6*count)) + self.last_ack=self.structured(TUX_CMD_STRUCT_WINGS, \ + TUX_CMD_STRUCT_SUB_ON,count,speed,0) + self.parent.event.wait_status(DATAS_STATUS_WINGS_POSITION_COUNTER, \ + 0,(0.6*count)) #-------------------------------------------------------------------------- # Send a command to tux for moving the wings in free mode @@ -1755,7 +1764,8 @@ Example: >>> tux.cmd.wings_off() """ - self.last_ack=self.structured(TUX_CMD_STRUCT_WINGS,TUX_CMD_STRUCT_SUB_OFF,0,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_WINGS, \ + TUX_CMD_STRUCT_SUB_OFF,0,0,0) #-------------------------------------------------------------------------- # Send a command to tux to spin to the left @@ -1775,9 +1785,10 @@ >>> tux.cmd.spinl_on(2) (count = 2) >>> tux.cmd.spinl_on(2,5) (count = 2 and speed = 5) """ - self.last_ack=self.structured(TUX_CMD_STRUCT_SPINL,\ - TUX_CMD_STRUCT_SUB_ON,count,speed,0) - self.parent.event.wait_status(DATAS_STATUS_SPIN_POSITION_COUNTER,0,(0.5*count)) + self.last_ack=self.structured(TUX_CMD_STRUCT_SPINL, \ + TUX_CMD_STRUCT_SUB_ON,count,speed,0) + self.parent.event.wait_status(DATAS_STATUS_SPIN_POSITION_COUNTER, \ + 0,(0.5*count)) #-------------------------------------------------------------------------- # Send a command to tux to spin to the left in free mode @@ -1812,7 +1823,8 @@ Example: >>> tux.cmd.spinl_off() """ - self.last_ack=self.structured(TUX_CMD_STRUCT_SPINL,TUX_CMD_STRUCT_SUB_OFF,0,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_SPINL, \ + TUX_CMD_STRUCT_SUB_OFF,0,0,0) #-------------------------------------------------------------------------- # Send a command to tux to spin to the right @@ -1832,10 +1844,10 @@ >>> tux.cmd.spinr_on(2) (count = 2) >>> tux.cmd.spinr_on(2,5) (count = 2 and speed = 5) """ - self.last_ack=self.structured(TUX_CMD_STRUCT_SPINR,\ - TUX_CMD_STRUCT_SUB_ON,count,speed,0) - self.parent.event.wait_status(DATAS_STATUS_SPIN_POSITION_COUNTER,0\ - ,(0.5*count)) + self.last_ack=self.structured(TUX_CMD_STRUCT_SPINR, \ + TUX_CMD_STRUCT_SUB_ON,count,speed,0) + self.parent.event.wait_status(DATAS_STATUS_SPIN_POSITION_COUNTER,0, \ + (0.5*count)) #-------------------------------------------------------------------------- # Send a command to tux to spin to the right in free mode @@ -1870,8 +1882,8 @@ Example: >>> tux.cmd.spinr_off() """ - self.last_ack=self.structured(TUX_CMD_STRUCT_SPINR,TUX_CMD_STRUCT_SUB_OFF\ - ,0,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_SPINR, \ + TUX_CMD_STRUCT_SUB_OFF,0,0,0) #-------------------------------------------------------------------------- # Send a command to tux for turning the IR on @@ -1895,8 +1907,8 @@ Example: >>> tux.cmd.ir_off() """ - self.last_ack=self.structured(TUX_CMD_STRUCT_IR,TUX_CMD_STRUCT_SUB_OFF\ - ,0,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_IR, \ + TUX_CMD_STRUCT_SUB_OFF,0,0,0) #-------------------------------------------------------------------------- # Send a command to tux for sending an IR code @@ -1912,8 +1924,8 @@ Example: >>> tux.cmd.ir_send(1,1) """ - self.last_ack=self.structured(TUX_CMD_STRUCT_IR,\ - TUX_CMD_STRUCT_SUB_SEND,address,command,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_IR, \ + TUX_CMD_STRUCT_SUB_SEND,address,command,0) #-------------------------------------------------------------------------- # Send a command to tux for turning the leds on @@ -1925,7 +1937,8 @@ Example: >>> tux.cmd.leds_on() """ - self.last_ack=self.structured(TUX_CMD_STRUCT_LEDS,TUX_CMD_STRUCT_SUB_ON,0,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_LEDS, \ + TUX_CMD_STRUCT_SUB_ON,0,0,0) #-------------------------------------------------------------------------- # Send a command to tux for blinking the leds @@ -1941,8 +1954,8 @@ Example: >>> tux.cmd.leds_blink(10,25) """ - self.last_ack=self.structured(TUX_CMD_STRUCT_LEDS,\ - TUX_CMD_STRUCT_SUB_BLINK,count,delay,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_LEDS, \ + TUX_CMD_STRUCT_SUB_BLINK,count,delay,0) #-------------------------------------------------------------------------- # Send a command to tux for turning the leds off @@ -1954,8 +1967,8 @@ Example: >>> tux.cmd.leds_off() """ - self.last_ack=self.structured(TUX_CMD_STRUCT_LEDS,\ - TUX_CMD_STRUCT_SUB_OFF,0,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_LEDS, \ + TUX_CMD_STRUCT_SUB_OFF,0,0,0) #-------------------------------------------------------------------------- # Send a command to tux for turning the leds on during a specified time @@ -2004,7 +2017,8 @@ Example: >>> tux.cmd.ledl_on() """ - self.last_ack=self.structured(TUX_CMD_STRUCT_LEDL,TUX_CMD_STRUCT_SUB_ON,0,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_LEDL, \ + TUX_CMD_STRUCT_SUB_ON,0,0,0) #-------------------------------------------------------------------------- # Send a command to tux for turning the left led off @@ -2016,7 +2030,8 @@ Example: >>> tux.cmd.ledl_off() """ - self.last_ack=self.structured(TUX_CMD_STRUCT_LEDL,TUX_CMD_STRUCT_SUB_OFF,0,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_LEDL, \ + TUX_CMD_STRUCT_SUB_OFF,0,0,0) #-------------------------------------------------------------------------- # Send a command to tux for turning the left led on during a specified time @@ -2066,7 +2081,8 @@ Example: >>> tux.cmd.ledr_on() """ - self.last_ack=self.structured(TUX_CMD_STRUCT_LEDR,TUX_CMD_STRUCT_SUB_ON,0,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_LEDR, \ + TUX_CMD_STRUCT_SUB_ON,0,0,0) #-------------------------------------------------------------------------- # Send a command to tux for turning the right led off @@ -2078,7 +2094,8 @@ Example: >>> tux.cmd.ledr_off() """ - self.last_ack=self.structured(TUX_CMD_STRUCT_LEDR,TUX_CMD_STRUCT_SUB_OFF,0,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_LEDR, \ + TUX_CMD_STRUCT_SUB_OFF,0,0,0) #-------------------------------------------------------------------------- # Send a command to tux for turning the right led on during a specified @@ -2136,8 +2153,8 @@ >>> tux.cmd.sound_play(1) >>> tux.cmd.sound_play(1,0) """ - self.last_ack=self.structured(TUX_CMD_STRUCT_SOUND,\ - TUX_CMD_STRUCT_SUB_PLAY,index,volume,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_SOUND, \ + TUX_CMD_STRUCT_SUB_PLAY,index,volume,0) #-------------------------------------------------------------------------- # Send a command to tux for storing a sound collection in the memory flash @@ -2153,8 +2170,8 @@ Example: >>> tux.cmd.sound_storing(10) """ - self.last_ack=self.structured(TUX_CMD_STRUCT_SOUND,\ - TUX_CMD_STRUCT_SUB_STORING,number,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_SOUND, \ + TUX_CMD_STRUCT_SUB_STORING,number,0,0) #-------------------------------------------------------------------------- # Send a command to tux for indexing the sound @@ -2171,8 +2188,8 @@ Example: >>> tux.cmd.sound_store_index(0x00,0x04,0x00) """ - self.last_ack=self.structured(TUX_CMD_STRUCT_SOUND,TUX_CMD_STRUCT_SUB_STORE_INDEX,\ - highAdd,middleAdd,lowAdd) + self.last_ack=self.structured(TUX_CMD_STRUCT_SOUND, \ + TUX_CMD_STRUCT_SUB_STORE_INDEX,highAdd,middleAdd,lowAdd) #-------------------------------------------------------------------------- # Send a command to tux for testing the sound in tux @@ -2184,7 +2201,8 @@ Example: >>> tux.cmd.sound_test() """ - self.last_ack=self.structured(TUX_CMD_STRUCT_SOUND,TUX_CMD_STRUCT_SUB_TEST,0,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_SOUND, \ + TUX_CMD_STRUCT_SUB_TEST,0,0,0) #-------------------------------------------------------------------------- # Send a command to tux for the "ping-pong" test @@ -2213,7 +2231,8 @@ Example: >>> tux.cmd.sleep_on() """ - self.last_ack=self.structured(TUX_CMD_STRUCT_SLEEP,TUX_CMD_STRUCT_SUB_ON,0,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_SLEEP, \ + TUX_CMD_STRUCT_SUB_ON,0,0,0) #-------------------------------------------------------------------------- # Send a command to tux for turning the sleep mode off @@ -2225,7 +2244,8 @@ Example: >>> tux.cmd.sleep_off() """ - self.last_ack=self.structured(TUX_CMD_STRUCT_SLEEP,TUX_CMD_STRUCT_SUB_OFF,0,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_SLEEP, \ + TUX_CMD_STRUCT_SUB_OFF,0,0,0) #-------------------------------------------------------------------------- # Send a command to tux for selecting the "general" audio channel in @@ -2240,8 +2260,8 @@ >>> tux.cmd.audio_channel_general() """ self.no_ack=True - self.last_ack=self.structured(TUX_CMD_STRUCT_AUDIO_CHANNEL,\ - TUX_CMD_STRUCT_SUB_CH_GENERAL,0,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_AUDIO_CHANNEL, \ + TUX_CMD_STRUCT_SUB_CH_GENERAL,0,0,0) self.no_ack=False #-------------------------------------------------------------------------- @@ -2256,8 +2276,8 @@ >>> tux.cmd.audio_channel_tts() """ self.no_ack=True - self.last_ack=self.structured(TUX_CMD_STRUCT_AUDIO_CHANNEL,\ - TUX_CMD_STRUCT_SUB_CH_TTS,0,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_AUDIO_CHANNEL, \ + TUX_CMD_STRUCT_SUB_CH_TTS,0,0,0) self.no_ack=False #============================================================================== @@ -2430,8 +2450,8 @@ if status[4]==DATAS_STATUS_SOUND_COUNT: line=line+"Flash sounds count->" if status[4]==DATAS_STATUS_PONG: - line=line+"Pong-> Received : %d Remaining : %d Average : %.0f %s"\ - %(status[6],status[5],((status[6]*100)/(200-status[5])),'%') + line=line+"Pong-> Received : %d Remaining : %d Average : %.0f %s" \ + %(status[6],status[5],((status[6]*100)/(200-status[5])),'%') value_type=value_np #-- Write value if value_type==value_onoff: @@ -2458,14 +2478,14 @@ # create a list of frames to match data_to_match_list = [] # create and insert a frame to match - data_to_match = (SOURCE_TUX,SS_DEFAULT,DATA_TP_RSP,\ - 999,DATA_STATUS,999,999,999,999,999,999,\ - 999,999,999,999,999) + data_to_match = (SOURCE_TUX,SS_DEFAULT,DATA_TP_RSP,999,DATA_STATUS, \ + 999,999,999,999,999,999,999,999,999,999,999) data_to_match_list.append(data_to_match) # create empty frame returned returned_data = [] # insert theses settings in the lock list - self.parent._insert_lock_in_list(data_to_match_list,cond_lock_mutex,returned_data) + self.parent._insert_lock_in_list(data_to_match_list,cond_lock_mutex, + returned_data) # wait the lock has unblocked. With a time-out cond_lock_mutex.acquire() cond_lock_mutex.wait(timeout) @@ -2495,8 +2515,8 @@ """ if not self.parent.daemon.connected: return 0 - data=(DEST_TUX,SD_DEFAULT,DATA_TP_REQ,SUBDATA_TP_STATUS,DATA_STATUS,\ - 0,0,0,0,0,0,0,0,0,0,0) + data=(DEST_TUX,SD_DEFAULT,DATA_TP_REQ,SUBDATA_TP_STATUS,DATA_STATUS, \ + 0,0,0,0,0,0,0,0,0,0,0) self.parent.sock.send("".join( [chr(x) for x in data] )) return self.rsp_status(DATA_STATUS) @@ -3313,14 +3333,14 @@ # create a list of frames to match data_to_match_list = [] # create and insert a frame to match - data_to_match = (SOURCE_SUB_DAEMON,SS_DEFAULT,DATA_TP_ACK_CMD,\ - 999,999,999,999,999,999,999,999,\ - 999,999,999,999,999) + data_to_match = (SOURCE_SUB_DAEMON,SS_DEFAULT,DATA_TP_ACK_CMD, \ + 999,999,999,999,999,999,999,999,999,999,999,999,999) data_to_match_list.append(data_to_match) # create empty frame returned returned_data = [] # insert theses settings in the lock list - self.parent._insert_lock_in_list(data_to_match_list,cond_lock_mutex,returned_data) + self.parent._insert_lock_in_list(data_to_match_list, \ + cond_lock_mutex,returned_data) # wait the lock has unblocked. With a time-out cond_lock_mutex.acquire() cond_lock_mutex.wait(2) @@ -3343,14 +3363,15 @@ # create a list of frames to match data_to_match_list = [] # create and insert a frame to match - data_to_match = (SOURCE_SUB_DAEMON,SS_DEFAULT,DATA_TP_RSP,\ - SUBDATA_TP_INFO,DATA_INFO,999,999,999,999,999,999,\ - 999,999,999,999,999) + data_to_match = (SOURCE_SUB_DAEMON,SS_DEFAULT,DATA_TP_RSP, \ + SUBDATA_TP_INFO,DATA_INFO,999,999,999,999,999,999, \ + 999,999,999,999,999) data_to_match_list.append(data_to_match) # create empty frame returned returned_data = [] # insert theses settings in the lock list - self.parent._insert_lock_in_list(data_to_match_list,cond_lock_mutex,returned_data) + self.parent._insert_lock_in_list(data_to_match_list,cond_lock_mutex, + returned_data) # wait the lock has unblocked. With a time-out cond_lock_mutex.acquire() cond_lock_mutex.wait(2) @@ -3380,8 +3401,8 @@ """ if not self.connected: return 2 - data=(DEST_SUB_DAEMON,SD_DEFAULT,DATA_TP_CMD,SUBDATA_TP_STRUCT,cmd,param1,\ - param2,param3,0,0,0,0,0,0,0,0) + data=(DEST_SUB_DAEMON,SD_DEFAULT,DATA_TP_CMD,SUBDATA_TP_STRUCT,cmd, + param1,param2,param3,0,0,0,0,0,0,0,0) self.parent.sock.send("".join( [chr(x) for x in data] )) return 0 @@ -3394,8 +3415,8 @@ """ if not self.connected: return 2 - data=(DEST_SUB_DAEMON,SD_DEFAULT,DATA_TP_REQ,\ - SUBDATA_TP_INFO,req,param1,param2,param3,0,0,0,0,0,0,0,0) + data=(DEST_SUB_DAEMON,SD_DEFAULT,DATA_TP_REQ, \ + SUBDATA_TP_INFO,req,param1,param2,param3,0,0,0,0,0,0,0,0) self.parent.sock.send("".join( [chr(x) for x in data] )) return self.rsp_info(req) @@ -3423,7 +3444,8 @@ Not a user function """ if not self.connected : return - self.last_ack=self.cmd_no_ack(SUB_D_CMD_STRUC_DISCONNECT_CLIENT_ME,0,0,0) + self.last_ack=self.cmd_no_ack(SUB_D_CMD_STRUC_DISCONNECT_CLIENT_ME, \ + 0,0,0) #-------------------------------------------------------------------------- # Kill tuxdaemon @@ -3460,10 +3482,11 @@ if name_length<11: add_name="".join( [' ' for i in range(11-name_length)] ) name=name+add_name - data=(DEST_SUB_DAEMON,SD_DEFAULT,DATA_TP_CMD,SUBDATA_TP_STRUCT,\ - SUB_D_CMD_STRUC_DEFINE_CLIENT_NAME,ord(name[0]),ord(name[1]),\ - ord(name[2]),ord(name[3]),ord(name[4]),ord(name[5]),ord(name[6]),\ - ord(name[7]),ord(name[8]),ord(name[9]),ord(name[10])) + data=(DEST_SUB_DAEMON,SD_DEFAULT,DATA_TP_CMD,SUBDATA_TP_STRUCT, \ + SUB_D_CMD_STRUC_DEFINE_CLIENT_NAME,ord(name[0]),ord(name[1]), \ + ord(name[2]),ord(name[3]),ord(name[4]),ord(name[5]), + ord(name[6]),ord(name[7]),ord(name[8]),ord(name[9]), + ord(name[10])) self.parent.sock.send("".join( [chr(x) for x in data] )) self.parent.my_name=name self.last_ack=self.cmd_ack() @@ -3615,8 +3638,8 @@ """ if not self.parent.daemon.connected: return (0,0,0,0,0) - data=(DEST_TUX,SD_DEFAULT,DATA_TP_REQ,SUBDATA_TP_INFO,\ - TUX_REQ_INFO_VERSION,cpu_index,0,0,0,0,0,0,0,0,0,0) + data=(DEST_TUX,SD_DEFAULT,DATA_TP_REQ,SUBDATA_TP_INFO, \ + TUX_REQ_INFO_VERSION,cpu_index,0,0,0,0,0,0,0,0,0,0) self.parent.sock.send("".join( [chr(x) for x in data] )) frame = self.parent.status.rsp_status(TUX_REQ_INFO_VERSION) if len(frame) > 0: @@ -3730,9 +3753,10 @@ tmp_tab=fp.read(9).split(':') current_tux_device[5]=int(tmp_tab[0],16) current_tux_device[6]=int(tmp_tab[1],16) - current_tux_device[0]="hw:%d,%d"%(current_tux_device[1],\ - current_tux_device[2]) - if ((current_tux_device[5]==0x03eb)and(current_tux_device[6]==0xff07)): + current_tux_device[0]="hw:%d,%d"%(current_tux_device[1], \ + current_tux_device[2]) + if ((current_tux_device[5]==0x03eb) and + (current_tux_device[6]==0xff07)): self.TUX_devices.append(current_tux_device) self.TUX_devices_count=self.TUX_devices_count+1 @@ -4109,8 +4133,8 @@ """ Not a user function """ - self.send_command_to_tts(CMD_TYPE_SOUND_CONF,CMD_SOUNDCONF_REINIT,\ - usb_bus,usb_device,0,0) + self.send_command_to_tts(CMD_TYPE_SOUND_CONF,CMD_SOUNDCONF_REINIT, \ + usb_bus,usb_device,0,0) #-------------------------------------------------------------------------- # Stop alsa driver @@ -4119,7 +4143,8 @@ """ Not a user function """ - self.send_command_to_tts(CMD_TYPE_SOUND_CONF,CMD_SOUNDCONF_STOP,0,0,0,0) + self.send_command_to_tts(CMD_TYPE_SOUND_CONF,CMD_SOUNDCONF_STOP, \ + 0,0,0,0) #-------------------------------------------------------------------------- # Select a speaker voice @@ -4265,9 +4290,9 @@ u = unicode(text,"utf-8") text_to_send = u.encode('latin-1','replace') text_length = len(text_to_send) - self.send_command_to_tts(CMD_TYPE_TTS, CMD_TTS_INSERT_PLAY_SPEECH,\ - (text_length & 0x0000FF00) >> 8, (text_length & 0x000000FF),\ - self.my_voice, self.my_pitch) + self.send_command_to_tts(CMD_TYPE_TTS, CMD_TTS_INSERT_PLAY_SPEECH, \ + (text_length & 0x0000FF00) >> 8, (text_length & 0x000000FF), \ + self.my_voice, self.my_pitch) self.parent.cmd.audio_channel_tts() self.sock.send(text_to_send) counter = 0 @@ -4363,7 +4388,8 @@ """ Not a user function """ - self.send_command_to_tts(CMD_TYPE_DAEMON,CMD_DAEMON_DISCONNECT_CLIENT,0,0,0,0) + self.send_command_to_tts(CMD_TYPE_DAEMON,CMD_DAEMON_DISCONNECT_CLIENT, \ + 0,0,0,0) #-------------------------------------------------------------------------- # Print the audio fifo state on tuxttsdaemon @@ -4372,7 +4398,8 @@ """ Not a user function """ - self.send_command_to_tts(CMD_TYPE_DAEMON,CMD_DAEMON_PRINT_FIFO_STATE,0,0,0,0) + self.send_command_to_tts(CMD_TYPE_DAEMON,CMD_DAEMON_PRINT_FIFO_STATE, \ + 0,0,0,0) #-------------------------------------------------------------------------- # Print informations of tux sound cards plugged @@ -4381,7 +4408,8 @@ """ Not a user function """ - self.send_command_to_tts(CMD_TYPE_DAEMON,CMD_DAEMON_PRINT_TUX_SOUND_CARDS,0,0,0,0) + self.send_command_to_tts(CMD_TYPE_DAEMON, \ + CMD_DAEMON_PRINT_TUX_SOUND_CARDS,0,0,0,0) #-------------------------------------------------------------------------- # Kill tuxttsdaemon @@ -4455,12 +4483,12 @@ c_header='' my_doc='' for i in range(80-len(indent)): c_header=c_header+'-' - my_doc='%s%s) Class : %s (%s)<br>'%(my_doc,class_num,\ - class_name,str(type(class_obj))[8:-2]) - self.header_doc=self.header_doc+indent+'<a href="#%s">'%(class_num)\ - +my_doc+'</a>' - my_doc=indent+'<a name=%s></a>'%(class_num)+self.h_class_b+\ - my_doc+self.h_class_e + my_doc='%s%s) Class : %s (%s)<br>'%(my_doc,class_num, \ + class_name,str(type(class_obj))[8:-2]) + self.header_doc=self.header_doc+indent+'<a href="#%s">'%(class_num) \ + +my_doc+'</a>' + my_doc=indent+'<a name=%s></a>'%(class_num)+self.h_class_b+ \ + my_doc+self.h_class_e for line in test: if line.find('Functions list')!=-1: break @@ -4477,8 +4505,9 @@ if funct_ok: line=line[line.rfind('.')+1:] i=i+1 - my_doc=my_doc+self.parse_function("%s.%d"%(class_num,i),class_name+'.'+line,\ - getattr(class_obj,line).__doc__,indent+' ') + my_doc=my_doc+self.parse_function("%s.%d"%(class_num,i), \ + class_name+'.'+line, getattr(class_obj,line).__doc__, \ + indent+' ') if line.find('Functionslist')!=-1: funct_ok=True # sub class @@ -4486,8 +4515,9 @@ if line.find('asclass')!=-1: line=line[1:line[1:].find('"')+1] i=i+1 - my_doc=my_doc+self.parse_class("%s.%d"%(class_num,i),getattr(class_obj,line),\ - class_name+'.'+line,getattr(class_obj,line).__doc__,indent+' ') + my_doc=my_doc+self.parse_class("%s.%d"%(class_num,i), \ + getattr(class_obj,line),class_name+'.'+line, \ + getattr(class_obj,line).__doc__,indent+' ') return my_doc #-------------------------------------------------------------------------- @@ -4502,10 +4532,10 @@ my_doc='' for i in range(80-len(indent)): c_header=c_header+'-' my_doc='%s%s)\tFunction : %s<br>'%(my_doc,funct_num,funct_name) - self.header_doc=self.header_doc+indent+'<a href="#%s">'%(funct_num)\ - +my_doc+'</a>' - my_doc=indent+'<a name=%s></a>'%(funct_num)+self.h_funct_b+\ - my_doc+self.h_funct_e + self.header_doc=self.header_doc+indent+'<a href="#%s">'%(funct_num) \ + +my_doc+'</a>' + my_doc=indent+'<a name=%s></a>'%(funct_num)+self.h_funct_b+ \ + my_doc+self.h_funct_e for line in test: my_doc=my_doc+indent+line[4:]+'<br>' return my_doc @@ -4535,12 +4565,15 @@ </HEAD>' documentation=documentation+'<body><pre>' documentation=documentation+self.h_titre_b+\ - 'DOCUMENTATION OF TUXDROID PYTHON API %s'%(api_version)+self.h_titre_e+'<br>' + 'DOCUMENTATION OF TUXDROID PYTHON API %s'%(api_version)+ \ + self.h_titre_e+'<br>' documentation=documentation+'\n' - self.header_doc='<br>'+self.h_class_b+'Table of content :'+self.h_class_e+'<br><br>' + self.header_doc='<br>'+self.h_class_b+'Table of content :'+ \ + self.h_class_e+'<br><br>' body_doc=self.parse_class('1',self.parent,'tux',main_class,'') self.header_doc=self.header_doc+'<br><br>' - documentation=documentation+self.header_doc+body_doc+'</pre></body></html>' + documentation=documentation+self.header_doc+body_doc+ \ + '</pre></body></html>' f=open(doc_path,'w') f.write(documentation) f.close() @@ -4572,9 +4605,10 @@ Example: >>> tux.misc.simulate_remote_key(K_OK) """ - tmp_tcp_data = (chr(SOURCE_TUX),chr(0),chr(DATA_TP_RSP),\ - chr(SUBDATA_TP_STATUS),chr(DATAS_STATUS_IR_CODE),chr(key),chr(0),\ - chr(0),chr(0),chr(0),chr(0),chr(0),chr(0),chr(0),chr(0),chr(0)) + tmp_tcp_data = (chr(SOURCE_TUX),chr(0),chr(DATA_TP_RSP), \ + chr(SUBDATA_TP_STATUS),chr(DATAS_STATUS_IR_CODE), \ + chr(key),chr(0),chr(0),chr(0),chr(0),chr(0),chr(0), \ + chr(0),chr(0),chr(0),chr(0)) self.parent.tcp_data_fifo_lock_mutex.acquire() self.parent.tcp_data_fifo_lock.append(tmp_tcp_data) |