Skip to content

Commit 957f43b

Browse files
committed
Add option to specify probe types
1 parent 91b1514 commit 957f43b

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

wsdiscovery/cmdline.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ def setup_logger(name, loglevel):
4141

4242

4343
@click.command()
44-
@click.option('--scope', '-s', help='Full scope URI, eg. onvif://www.onvif.org/Model/')
44+
@click.option('--scope', '-s', help='Probe scope URI, e.g. onvif://www.onvif.org/Model/')
45+
@click.option('--type', '-y', 'ptype', nargs=3, type=(str, str, str), multiple=True,
46+
help='Probe type in this order: NS_URI NS_PREFIX LOCAL_NAME,'
47+
' e.g. http://www.onvif.org/ver10/network/wsdl dp0 NetworkVideoTransmitter'
48+
' -- this option can be specified multiple times')
4549
@click.option('--address', '-a', help='Service address')
4650
@click.option('--port', '-p', type=int, help='Service port')
4751
@click.option('--loglevel', '-l', default=DEFAULT_LOGLEVEL, show_default=True,
@@ -54,16 +58,22 @@ def setup_logger(name, loglevel):
5458
show_default=True, help='Number of Unicast messages to send')
5559
@click.option('--multicast-num', '-mn', type=int, default=MULTICAST_UDP_REPEAT,
5660
show_default=True, help='Number of Multicast messages to send')
57-
def discover(scope, address, port, loglevel, capture, timeout, unicast_num,
58-
multicast_num):
61+
def discover(scope, ptype, address, port, loglevel, capture, timeout,
62+
unicast_num, multicast_num):
5963
"Discover services using WS-Discovery"
6064

6165
logger = setup_logger("ws-discovery", loglevel)
6266

67+
probe_types = []
68+
for type_tuple in ptype:
69+
probe_types.append(QName(type_tuple[0], type_tuple[2], type_tuple[1]))
70+
if len(probe_types) == 0:
71+
probe_types = None
72+
6373
with discovery(capture, unicast_num, multicast_num) as wsd:
6474
scopes = [Scope(scope)] if scope else []
65-
svcs = wsd.searchServices(scopes=scopes, address=address, port=port,
66-
timeout=timeout)
75+
svcs = wsd.searchServices(types=probe_types, scopes=scopes,
76+
address=address, port=port, timeout=timeout)
6777
print("\nDiscovered:\n")
6878
for service in svcs:
6979
url = urlparse(service.getXAddrs()[0])

0 commit comments

Comments
 (0)