Exemplo n.º 1
0
 def action(self, action, args, kwargs):
     # It's really pathetic, but it's still debugging output.
     self.log.debug('Action %r called with %d args', action,
         len(args) + len(kwargs))
     
     # This method is responsible for the JSON encoding/decoding, not send().
     # This was deliberate because it keeps most of the protocol details
     # separate from the lower-level socket code.
     received_data = self.send(json.dumps([action, args, kwargs]) + '\r\n')
     return self.handle_response(received_data)
Exemplo n.º 2
0
 def close(self):
     # The following closes the connection by first sending the 'quit'
     # message and then closing the socket via the forced _close() method.
     self.lock.acquire()
     try:
         self.writer.write(json.dumps(['quit']) + '\r\n')
         self._close()
     except Exception, exc:
         self.log.error('Error %r occurred while closing connection', exc)
         raise
Exemplo n.º 3
0
 def action(self, action, args, kwargs):
     # It's really pathetic, but it's still debugging output.
     self.log.debug('Action %r called with %d args', action,
         len(args) + len(kwargs))
     
     path = '/' + urllib.quote(action) + '/'        
     url = URLObject(host=self.host).with_port(self.port).with_path(path)
     received_data = self.send(url, data=json.dumps([args, kwargs]))
     
     return self.handle_response(received_data)
Exemplo n.º 4
0
 def close(self):
     # The following closes the connection by first sending the 'quit'
     # message and then closing the socket via the forced _close() method.
     self.lock.acquire()
     try:
         self.writer.write(json.dumps(['quit']) + '\r\n')
         self._close()
     except Exception, exc:
         self.log.error('Error %r occurred while closing connection', exc)
         raise
Exemplo n.º 5
0
    def action(self, action, args, kwargs):
        # It's really pathetic, but it's still debugging output.
        self.log.debug('Action %r called with %d args', action,
                       len(args) + len(kwargs))

        # This method is responsible for the JSON encoding/decoding, not send().
        # This was deliberate because it keeps most of the protocol details
        # separate from the lower-level socket code.
        received_data = self.send(json.dumps([action, args, kwargs]) + '\r\n')
        return self.handle_response(received_data)
Exemplo n.º 6
0
    def action(self, action, args, kwargs):
        # It's really pathetic, but it's still debugging output.
        self.log.debug('Action %r called with %d args', action,
                       len(args) + len(kwargs))

        path = '/' + urllib.quote(action) + '/'
        url = URLObject(host=self.host).with_port(self.port).with_path(path)
        received_data = self.send(url, data=json.dumps([args, kwargs]))

        return self.handle_response(received_data)
def write_json(writer, object):
    # A simple utility method.
    writer.write(json.dumps(object) + '\r\n')
Exemplo n.º 8
0
 def __new__(cls, obj, status=200):
     return Response(response=json.dumps(obj), mimetype='application/json',
         status=status)
Exemplo n.º 9
0
 def __new__(cls, obj, status=200):
     return Response(response=json.dumps(obj),
                     mimetype='application/json',
                     status=status)