Changeset 62 for remote_control/puzzlebox_brainstorms_client_thinkgear.py
- Timestamp:
- 06/22/10 14:42:27 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
remote_control/puzzlebox_brainstorms_client_thinkgear.py
r61 r62 20 20 21 21 import puzzlebox_brainstorms_configuration as configuration 22 import puzzlebox_brainstorms_client as client23 22 24 23 ##################################################################### … … 36 35 THINKGEAR_DELIMITER = '\r' 37 36 37 ENABLE_THINKGEAR_AUTHORIZATION = configuration.ENABLE_THINKGEAR_AUTHORIZATION 38 38 AUTHORIZATION_REQUEST = configuration.THINKGEAR_AUTHORIZATION_REQUEST 39 39 … … 46 46 ##################################################################### 47 47 48 class puzzlebox_brainstorms_client_thinkgear (client.puzzlebox_brainstorms_client):48 class puzzlebox_brainstorms_client_thinkgear: 49 49 50 50 def __init__(self, log, \ … … 200 200 data = json.loads(line) 201 201 except Exception, e: 202 if SELF.DEBUG:202 if self.DEBUG: 203 203 print "Partial data received (or error:", 204 204 print e … … 207 207 print "line:", 208 208 print line 209 210 # We've received back an unrecognized response 211 # so we'll attempt to reset the server's 212 # parameters for JSON communication 213 self.send_data(self.factory.parameters) 209 214 210 215 else: … … 243 248 ##################################################################### 244 249 245 class puzzlebox_brainstorms_client_thinkgear_factory( \ 246 client.puzzlebox_brainstorms_client_send_command_factory): 250 class puzzlebox_brainstorms_client_thinkgear_factory(protocol.ClientFactory): 247 251 248 252 def __init__(self, log, \ … … 289 293 290 294 295 ################################################################## 296 297 def clientConnectionFailed(self, connector, reason): 298 299 if self.DEBUG: 300 print "Client failed to connect to remote component at %s:%i" % \ 301 (self.server_host, self.server_port) 302 303 reply = 'FAILED_TO_CONNECT' 304 305 self.connection_attempt = self.connection_attempt + 1 306 307 if ((self.max_connection_attempts == None) or \ 308 (self.connection_attempt <= self.max_connection_attempts)): 309 310 # If connection failed retry after one second 311 reactor.callLater(1, connector.connect) 312 313 else: 314 if self.DEBUG: 315 print "Maximum connection retries reached, aborting" 316 317 318 self.replyDefer.callback(reply) 319 320 321 ################################################################## 322 323 def clientConnectionLost(self, connector, reason): 324 325 # Losing Connection is expected after data exchange is complete 326 try: 327 self.replyDefer.callback(reason) 328 except: 329 pass 330 331 291 332 ##################################################################### 292 333 # Main … … 307 348 DEBUG=DEBUG) 308 349 309 # Use ThinkGear authentication 310 ## reactor.callWhenRunning( \ 311 ## thinkgear_client.authorize_and_send_parameters, \ 312 ## thinkgear_parameters, \ 313 ## authorization_request) 314 315 # Do not use ThinkGear authentication 316 authorization_request = None 317 reactor.callWhenRunning( \ 318 thinkgear_client.send_parameters, \ 319 thinkgear_parameters, \ 320 authorization_request) 350 351 if ENABLE_THINKGEAR_AUTHORIZATION: 352 # Use ThinkGear authentication 353 reactor.callWhenRunning( \ 354 thinkgear_client.authorize_and_send_parameters, \ 355 thinkgear_parameters, \ 356 authorization_request) 357 358 else: 359 # Do not use ThinkGear authentication 360 authorization_request = None 361 reactor.callWhenRunning( \ 362 thinkgear_client.send_parameters, \ 363 thinkgear_parameters, \ 364 authorization_request) 321 365 322 366
Note: See TracChangeset
for help on using the changeset viewer.