mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-23 03:33:35 +00:00
Make timeout configurable for cli (#564)
This commit is contained in:
parent
bfd1d6ae0a
commit
347cbfe3bd
10
kasa/cli.py
10
kasa/cli.py
@ -131,6 +131,13 @@ def json_formatter_cb(result, **kwargs):
|
|||||||
@click.option(
|
@click.option(
|
||||||
"--json", default=False, is_flag=True, help="Output raw device response as JSON."
|
"--json", default=False, is_flag=True, help="Output raw device response as JSON."
|
||||||
)
|
)
|
||||||
|
@click.option(
|
||||||
|
"--timeout",
|
||||||
|
envvar="KASA_TIMEOUT",
|
||||||
|
default=5,
|
||||||
|
required=False,
|
||||||
|
help="Timeout for device communications.",
|
||||||
|
)
|
||||||
@click.option(
|
@click.option(
|
||||||
"--discovery-timeout",
|
"--discovery-timeout",
|
||||||
envvar="KASA_DISCOVERY_TIMEOUT",
|
envvar="KASA_DISCOVERY_TIMEOUT",
|
||||||
@ -163,6 +170,7 @@ async def cli(
|
|||||||
debug,
|
debug,
|
||||||
type,
|
type,
|
||||||
json,
|
json,
|
||||||
|
timeout,
|
||||||
discovery_timeout,
|
discovery_timeout,
|
||||||
username,
|
username,
|
||||||
password,
|
password,
|
||||||
@ -234,7 +242,7 @@ async def cli(
|
|||||||
if type is not None:
|
if type is not None:
|
||||||
device_type = DeviceType.from_value(type)
|
device_type = DeviceType.from_value(type)
|
||||||
dev = await SmartDevice.connect(
|
dev = await SmartDevice.connect(
|
||||||
host, credentials=credentials, device_type=device_type
|
host, credentials=credentials, device_type=device_type, timeout=timeout
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
echo("No --type defined, discovering..")
|
echo("No --type defined, discovering..")
|
||||||
|
Loading…
Reference in New Issue
Block a user