Beispiel #1
0
    def on_data(self, data):
        """Called when raw data is received from connection.

        Override this method if you wish to manually handle
        the stream data. Return False to stop stream and close connection.
        """

        if 'in_reply_to_status_id' in data:
            status = Status.parse(self.api, json.loads(u(data)))
            if self.on_status(status) is False:
                return False
        elif 'delete' in data:
            delete = json.loads(data)['delete']['status']
            if self.on_delete(delete['id'], delete['user_id']) is False:
                return False
        elif 'limit' in data:
            if self.on_limit(json.loads(data)['limit']['track']) is False:
                return False
Beispiel #2
0
 def parse_error(self, payload):
     error = self.json_lib.loads(u(payload))
     if error.has_key('error'):
         return error['error']
     else:
         return error['errors']
Beispiel #3
0
 def parse(self, method, payload):
     try:
         json = self.json_lib.loads(u(payload))
     except Exception, e:
         raise TweepError('Failed to parse JSON payload: %s' % e)