示例#1
0
文件: common.py 项目: mkttdw/zenqueue
 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)
示例#2
0
文件: common.py 项目: mkttdw/zenqueue
 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
示例#3
0
文件: common.py 项目: mkttdw/zenqueue
 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)
示例#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
示例#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)
示例#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')
示例#8
0
文件: http.py 项目: mkttdw/zenqueue
 def __new__(cls, obj, status=200):
     return Response(response=json.dumps(obj), mimetype='application/json',
         status=status)
示例#9
0
 def __new__(cls, obj, status=200):
     return Response(response=json.dumps(obj),
                     mimetype='application/json',
                     status=status)