Пример #1
0
def main():
    """Main."""
    winutils.exit_if_admin()

    script_name = os.path.basename(sys.argv[0])  # in case it is full path
    script_name_no_ext = os.path.splitext(script_name)[0]

    log_filename = "%s.log" % (script_name_no_ext, )
    format = ("%(asctime)s %(name)s %(levelname)s : %(message)s")

    logging.basicConfig(format=format,
                        filename=log_filename,
                        filemode='w',
                        level=logging.DEBUG)

    c = wmi.WMI()
    for iface in c.Win32_NetworkAdapterConfiguration(IPEnabled=True):
        print("Local IP address: %s DNS %r" %
              (iface.IPAddress, iface.DNSDomain))

    print("Starting PTS ...")
    pts = PyPTSWithXmlRpcCallback()
    print("OK")

    print("Serving on port {} ...".format(SERVER_PORT))

    server = xmlrpc.server.SimpleXMLRPCServer(("", SERVER_PORT),
                                              allow_none=True)
    server.register_instance(pts)
    server.register_introspection_functions()
    server.serve_forever()
Пример #2
0
def main():
    """Main."""
    winutils.exit_if_admin()

    script_name = os.path.basename(sys.argv[0])  # in case it is full path
    script_name_no_ext = os.path.splitext(script_name)[0]

    log_filename = "%s.log" % (script_name_no_ext,)
    format = ("%(asctime)s %(name)s %(levelname)s : %(message)s")

    logging.basicConfig(format=format,
                        filename=log_filename,
                        filemode='w',
                        level=logging.DEBUG)

    print("Starting PTS ...")
    pts = PyPTSWithXmlRpcCallback()
    print("OK")

    print("Serving on port {} ...".format(SERVER_PORT))

    server = xmlrpc.server.SimpleXMLRPCServer(("", SERVER_PORT), allow_none=True)
    server.register_instance(pts)
    server.register_introspection_functions()
    server.serve_forever()
Пример #3
0
        superguard.add_server(srv)
        sleep(5)

    while queue.empty():
        for srv in servers:
            if not srv.is_alive():
                queue.put(Exception('Server is down'))
        sleep(
            2
        )  # This loop has a huge impact on the performance of server threads

    [s.terminate('') for s in servers]


if __name__ == "__main__":
    winutils.exit_if_admin()
    args = SvrArgumentParser("PTS automation server").parse_args()
    queue = Queue()

    superguard = SuperGuard(float(args.superguard), queue)
    if args.superguard:
        superguard.start()

    while True:
        try:
            if type(args.srv_port) is int:
                server = Server(queue=queue)
                superguard.add_server(server)

                server.main(args)  # Run server in main process
            else: