|
7 | 7 | from wsdiscovery.publishing import ThreadedWSPublishing as WSPublishing |
8 | 8 | from wsdiscovery.scope import Scope |
9 | 9 | from wsdiscovery.qname import QName |
| 10 | +from wsdiscovery.discovery import DEFAULT_DISCOVERY_TIMEOUT |
10 | 11 |
|
11 | 12 | DEFAULT_LOGLEVEL = "INFO" |
12 | 13 |
|
@@ -43,14 +44,17 @@ def setup_logger(name, loglevel): |
43 | 44 | type=click.Choice(["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]), |
44 | 45 | help='Log level') |
45 | 46 | @click.option('--capture', '-c', nargs=1, type=click.File('w'), help='Capture messages to a file') |
46 | | -def discover(scope, address, port, loglevel, capture): |
| 47 | +@click.option('--timeout', '-t', default=DEFAULT_DISCOVERY_TIMEOUT, show_default=True, |
| 48 | + type=int, help='Discovery timeout in seconds') |
| 49 | +def discover(scope, address, port, loglevel, capture, timeout): |
47 | 50 | "Discover services using WS-Discovery" |
48 | 51 |
|
49 | 52 | logger = setup_logger("ws-discovery", loglevel) |
50 | 53 |
|
51 | 54 | with discovery(capture) as wsd: |
52 | 55 | scopes = [Scope(scope)] if scope else [] |
53 | | - svcs = wsd.searchServices(scopes=scopes, address=address, port=port) |
| 56 | + svcs = wsd.searchServices(scopes=scopes, address=address, port=port, |
| 57 | + timeout=timeout) |
54 | 58 | print("\nDiscovered:\n") |
55 | 59 | for service in svcs: |
56 | 60 | url = urlparse(service.getXAddrs()[0]) |
|
0 commit comments