From 822ab3f8ac0910d9514d56e870e039f36e5234b6 Mon Sep 17 00:00:00 2001 From: Teemu R Date: Mon, 13 Jan 2020 08:52:52 +0100 Subject: [PATCH] Fix dump-discover to use asyncio.run (#16) --- kasa/cli.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kasa/cli.py b/kasa/cli.py index 6ce81e14..210e2fff 100755 --- a/kasa/cli.py +++ b/kasa/cli.py @@ -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)