def get_service(self, service): '''Returns the dict associated with the user for a given service''' rservice = self._service.format(id=self.id, service=service) json = r.get(rservice) # convenient but not atomic if json: return decode(json) else: return None
from sys import argv from tornado.httpclient import HTTPError, HTTPClient as Client from tornado.escape import json_decode as decode client = Client() try: url = argv[1] except IndexError: print('Connecting to localhost') url = 'http://localhost:8888/' pos = 0 timeout = 20 while True: try: resp = client.fetch(url + str(pos), request_timeout=timeout) d = decode(resp.body) pos = d['pointer'] line = d['text'] print(line.rstrip('\n')) except HTTPError as e: #print(e) if not 'imeout' in str(e): print(e) break except KeyboardInterrupt: print('Closed by user') break
def get_name(self): '''Returns the dictionary of keys/values for this Group''' return decode(r.get(self.rinfo))
def _facebook(self): return decode(self.facebook_json()) if self.facebook_json() else None
def _twitter(self): return decode(self.twitter_json()) if self.twitter_json() else None
def _google(self): return decode(self.google_json()) if self.google_json() else None