()
| 671 | |
| 672 | |
| 673 | def uacall(): |
| 674 | parser = argparse.ArgumentParser(description="Call method of a node") |
| 675 | add_common_args(parser) |
| 676 | parser.add_argument("-m", |
| 677 | "--method", |
| 678 | dest="method", |
| 679 | type=int, |
| 680 | default=None, |
| 681 | help="Set method to call. If not given then (single) method of the selected node is used.") |
| 682 | parser.add_argument("-M", |
| 683 | "--method-name", |
| 684 | dest="method_name", |
| 685 | type=str, |
| 686 | default=None, |
| 687 | help="Set name of method to call. Overrides --method") |
| 688 | parser.add_argument("-l", |
| 689 | "--list", |
| 690 | "--array", |
| 691 | dest="array", |
| 692 | default="guess", |
| 693 | choices=["guess", "true", "false"], |
| 694 | help="Value is an array") |
| 695 | parser.add_argument("-t", |
| 696 | "--datatype", |
| 697 | dest="datatype", |
| 698 | default="guess", |
| 699 | choices=["guess", 'byte', 'sbyte', 'nodeid', 'expandednodeid', 'qualifiedname', 'browsename', 'string', 'float', 'double', 'int16', 'int32', "int64", 'uint16', 'uint32', 'uint64', "bool", "string", 'datetime', 'bytestring', 'xmlelement', 'statuscode', 'localizedtext'], |
| 700 | help="Data type to return") |
| 701 | parser.add_argument("value", |
| 702 | help="Value to use for call to method, if any", |
| 703 | nargs="?", |
| 704 | metavar="VALUE") |
| 705 | |
| 706 | args = parse_args(parser, requirenodeid=True) |
| 707 | |
| 708 | client = Client(args.url, timeout=args.timeout) |
| 709 | _configure_client_with_args(client, args) |
| 710 | client.connect() |
| 711 | try: |
| 712 | node = get_node(client, args) |
| 713 | # val must be a tuple in order to enable method calls without arguments |
| 714 | if ( args.value is None ): |
| 715 | val = () #empty tuple |
| 716 | else: |
| 717 | val = (_val_to_variant(args.value, args),) # tuple with one element |
| 718 | |
| 719 | # determine method to call: Either explicitly given or automatically select the method of the selected node. |
| 720 | methods = node.get_methods() |
| 721 | method_id = None |
| 722 | #print( "methods=%s" % (methods) ) |
| 723 | |
| 724 | if ( args.method_name is not None ): |
| 725 | method_id = args.method_name |
| 726 | elif ( args.method is None ): |
| 727 | if ( len( methods ) == 0 ): |
| 728 | raise ValueError( "No methods in selected node and no method given" ) |
| 729 | elif ( len( methods ) == 1 ): |
| 730 | method_id = methods[0] |
nothing calls this directly
no test coverage detected