예제 #1
0
    def handleResponse(self, response):

        data = response.read()
        self.bytes_read = len(str(response.headers)) + len(data)
        obj = to_object(data)

        if obj['status'] != 200:
            sys.stderr.write('JSON gateway returned status %d:\n' % (obj['status']))
            return None

        # the gateway wraps responses in an array to handle streaming data
        # if there is only one item in the array, it (probably) wasn't a streaming request
        p = obj['payload']
        if len(p) > 1: return p
        if len(p): return p[0]
        return None
예제 #2
0
    def handleResponse(self, response):

        data = response.read()
        self.bytes_read = len(str(response.headers)) + len(data)
        obj = to_object(data)

        if obj['status'] != 200:
            sys.stderr.write('JSON gateway returned status %d:\n' %
                             (obj['status']))
            return None

        # the gateway wraps responses in an array to handle streaming data
        # if there is only one item in the array, it (probably) wasn't a streaming request
        p = obj['payload']
        if len(p) > 1: return p
        if len(p): return p[0]
        return None
예제 #3
0
 def get(self, key):
     obj = self.client.get(str(key))
     osrf.log.log_internal("cache: fetching %s => %s" % (str(key), obj))
     return to_object(obj or "null")
예제 #4
0
 def get(self, key):
     obj = self.client.get(str(key))
     osrf.log.log_internal("cache: fetching %s => %s" % (str(key), obj))
     return to_object(obj or "null")