mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-22 19:23:34 +00:00
Fix dump-discover to use asyncio.run (#16)
This commit is contained in:
parent
0f0df481a0
commit
822ab3f8ac
@ -1,5 +1,6 @@
|
||||
"""python-kasa cli tool."""
|
||||
import asyncio
|
||||
import json
|
||||
import logging
|
||||
from pprint import pformat as pf
|
||||
|
||||
@ -88,14 +89,13 @@ def dump_discover(ctx, save):
|
||||
Useful for dumping into a file with `--save` to be added to the test suite.
|
||||
"""
|
||||
target = ctx.parent.params["target"]
|
||||
for dev in Discover.discover(target=target, return_raw=True).values():
|
||||
devs = asyncio.run(Discover.discover(target=target, return_raw=True))
|
||||
for dev in devs.values():
|
||||
model = dev["system"]["get_sysinfo"]["model"]
|
||||
hw_version = dev["system"]["get_sysinfo"]["hw_ver"]
|
||||
save_to = f"{model}_{hw_version}.json"
|
||||
click.echo("Saving info to %s" % save_to)
|
||||
with open(save_to, "w") as f:
|
||||
import json
|
||||
|
||||
json.dump(dev, f, sort_keys=True, indent=4)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user