示例#1
0
class HTTPServer(object):

    def __init__(self, host, port, template, log_queue, docpath, snmp_port=161):
        self.host = host
        self.port = port
        self.docpath = docpath
        self.snmp_host = '127.0.0.1'
        self.snmp_port = snmp_port

        self.cmd_responder = CommandResponder(host, port, template, log_queue, docpath, self.snmp_host, self.snmp_port)
        self.cmd_responder.httpd.allow_reuse_address = True
        self.server_port = self.cmd_responder.server_port

    def start(self):
        if self.cmd_responder:
            logger.info('HTTP server started on: {0}'.format((self.host, self.port)))

            self.cmd_responder.serve_forever()

    def stop(self):
        if self.cmd_responder:
            self.cmd_responder.stop()

    def shutdown(self):
        if self.cmd_responder:
            self.cmd_responder.httpd.shutdown()
示例#2
0
    def __init__(self, host, port, template, log_queue, docpath, snmp_port=161):
        self.host = host
        self.port = port
        self.docpath = docpath
        self.snmp_host = '127.0.0.1'
        self.snmp_port = snmp_port

        self.cmd_responder = CommandResponder(host, port, template, log_queue, docpath, self.snmp_host, self.snmp_port)
        self.cmd_responder.httpd.allow_reuse_address = True