From 09cd0c015ae276aa849297a6a976065b2b3f247b Mon Sep 17 00:00:00 2001 From: Devendra Date: Wed, 23 Apr 2014 14:03:13 +0530 Subject: modifying code for pep 8 compliance --- python-tornado/unassembled/Platform.py | 47 ++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 19 deletions(-) (limited to 'python-tornado/unassembled/Platform.py') diff --git a/python-tornado/unassembled/Platform.py b/python-tornado/unassembled/Platform.py index 02c374d..871a400 100644 --- a/python-tornado/unassembled/Platform.py +++ b/python-tornado/unassembled/Platform.py @@ -13,23 +13,28 @@ from tornado.stack_context import ExceptionStackContext ioloop = tornado.ioloop.IOLoop.instance() + class Pubnub(PubnubCoreAsync): - def stop(self): ioloop.stop() - def start(self): ioloop.start() - def timeout( self, delay, callback): - ioloop.add_timeout( time.time()+float(delay), callback ) - + def stop(self): + ioloop.stop() + + def start(self): + ioloop.start() + + def timeout(self, delay, callback): + ioloop.add_timeout(time.time() + float(delay), callback) + def __init__( self, publish_key, subscribe_key, - secret_key = False, - cipher_key = False, - auth_key = False, - ssl_on = False, - origin = 'pubsub.pubnub.com' - ) : + secret_key=False, + cipher_key=False, + auth_key=False, + ssl_on=False, + origin='pubsub.pubnub.com' + ): super(Pubnub, self).__init__( publish_key=publish_key, subscribe_key=subscribe_key, @@ -38,22 +43,26 @@ class Pubnub(PubnubCoreAsync): auth_key=auth_key, ssl_on=ssl_on, origin=origin, - ) + ) self.headers = {} self.headers['User-Agent'] = 'Python-Tornado' self.headers['Accept-Encoding'] = self.accept_encoding self.headers['V'] = self.version self.http = tornado.httpclient.AsyncHTTPClient(max_clients=1000) self.id = None - - def _request( self, request, callback=None, error=None, single=False ) : + + def _request(self, request, callback=None, error=None, single=False): def _invoke(func, data): if func is not None: func(data) url = self.getUrl(request) - request = tornado.httpclient.HTTPRequest( url, 'GET', self.headers, connect_timeout=10, request_timeout=310 ) + request = tornado.httpclient.HTTPRequest( + url, 'GET', + self.headers, + connect_timeout=10, + request_timeout=310) if single is True: id = time.time() self.id = id @@ -61,13 +70,14 @@ class Pubnub(PubnubCoreAsync): def responseCallback(response): if single is True: if not id == self.id: - return None - + return None + body = response._get_body() if body is None: return #print(body) + def handle_exc(*args): return True if response.error is not None: @@ -80,7 +90,7 @@ class Pubnub(PubnubCoreAsync): try: data = json.loads(body.decode("utf-8")) except: - _invoke(error, {'error' : 'json decode error'}) + _invoke(error, {'error': 'json decode error'}) if 'error' in data and 'status' in data and 'status' != 200: _invoke(error, data) @@ -96,4 +106,3 @@ class Pubnub(PubnubCoreAsync): pass return abort - -- cgit v1.2.3