Ejemplo n.º 1
0
def make_client():
    parser = argparse.ArgumentParser(
        description="Interactive client shell for malcolm")
    parser.add_argument('server',
                        help="Server string for connection to malcolm "
                        "directory server like 172.23.243.13:5600")
    parser.add_argument('--log', default="INFO",
                        help="Lowest level of logs to see. One of: "
                        "ERROR, WARNING, INFO, DEBUG. "
                        "Default is INFO")
    args = parser.parse_args()
    # assuming loglevel is bound to the string value obtained from the
    # command line argument. Convert to upper case to allow the user to
    # specify --log=DEBUG or --log=debug
    numeric_level = getattr(logging, args.log.upper(), None)
    if not isinstance(numeric_level, int):
        raise ValueError('Invalid log level: %s' % args.log)
    logging.basicConfig(level=numeric_level)
    ds_string = "zmq://tcp://{}".format(args.server)
    client = Process([], "iMalcolmClient", ds_string=ds_string)
    client.DeviceClient = IDeviceClient
    return client