Example #1
0
async def _uaclient():
    parser = argparse.ArgumentParser(
        description=
        "Connect to server and start python shell. root and objects nodes are available. Node specificed in command line is available as mynode variable"
    )
    add_common_args(parser)
    parser.add_argument("-c", "--certificate", help="set client certificate")
    parser.add_argument("-k", "--private_key", help="set client private key")
    args = parse_args(parser)

    client = Client(args.url, timeout=args.timeout)
    await _configure_client_with_args(client, args)
    if args.certificate:
        client.load_client_certificate(args.certificate)
    if args.private_key:
        client.load_private_key(args.private_key)

    try:
        async with client:
            mynode = await get_node(client, args)
            # embed()
    except (OSError, concurrent.futures._base.TimeoutError) as e:
        print(e)
        sys.exit(1)

    sys.exit(0)
Example #2
0
import sys
sys.path.insert(0, "..")
import logging

from IPython import embed

from asyncua import Client

if __name__ == "__main__":
    logging.basicConfig(level=logging.WARN)
    client = Client("opc.tcp://localhost:53530/OPCUA/SimulationServer/")
    client.load_client_certificate("server_cert.pem")
    client.load_private_key("mykey.pem")
    try:
        client.connect()
        root = client.get_root_node()
        objects = client.get_objects_node()
        print("childs og objects are: ", objects.get_children())

        embed()
    finally:
        client.disconnect()