Shorten the skipped-device message, full text behind a flag
This commit is contained in:
+18
-4
@@ -108,6 +108,12 @@ def online_hint(info):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
BLUETOOTH_ONLY_SHORT = (
|
||||||
|
"Bluetooth-only models cannot be used as a source. "
|
||||||
|
"Details: --explain-skipped"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def clean_status(raw):
|
def clean_status(raw):
|
||||||
return {key: value for key, value in (raw or {}).items() if key not in IGNORED_KEYS}
|
return {key: value for key, value in (raw or {}).items() if key not in IGNORED_KEYS}
|
||||||
|
|
||||||
@@ -390,7 +396,13 @@ async def close_session(api, websession):
|
|||||||
|
|
||||||
|
|
||||||
async def discover(
|
async def discover(
|
||||||
settle=45, only_pn=None, only_sn=None, skip=None, include_offline=False, verbose=True
|
settle=45,
|
||||||
|
only_pn=None,
|
||||||
|
only_sn=None,
|
||||||
|
skip=None,
|
||||||
|
include_offline=False,
|
||||||
|
explain_skipped=False,
|
||||||
|
verbose=True,
|
||||||
):
|
):
|
||||||
paths.ensure_dirs()
|
paths.ensure_dirs()
|
||||||
|
|
||||||
@@ -419,10 +431,12 @@ async def discover(
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
if not include_offline and online_hint(info) is False:
|
if not include_offline and online_hint(info) is False:
|
||||||
print()
|
label = model_label(part_number_of(info))
|
||||||
print(f" {serial} - {model_label(part_number_of(info))}")
|
print(f" {serial} - {label}: not cloud connected, skipped.")
|
||||||
print(" not cloud connected, skipping without subscribing.")
|
if explain_skipped:
|
||||||
print(BLUETOOTH_ONLY_HINT)
|
print(BLUETOOTH_ONLY_HINT)
|
||||||
|
else:
|
||||||
|
print(f" {BLUETOOTH_ONLY_SHORT}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
targets[serial] = info
|
targets[serial] = info
|
||||||
|
|||||||
@@ -172,6 +172,7 @@ def cmd_discover_anker(args):
|
|||||||
only_sn=args.sn,
|
only_sn=args.sn,
|
||||||
skip=args.skip,
|
skip=args.skip,
|
||||||
include_offline=args.include_offline,
|
include_offline=args.include_offline,
|
||||||
|
explain_skipped=args.explain_skipped,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
print()
|
print()
|
||||||
@@ -1319,6 +1320,11 @@ def build_parser():
|
|||||||
action="store_true",
|
action="store_true",
|
||||||
help="try devices the cloud reports as not connected",
|
help="try devices the cloud reports as not connected",
|
||||||
)
|
)
|
||||||
|
anker_parser.add_argument(
|
||||||
|
"--explain-skipped",
|
||||||
|
action="store_true",
|
||||||
|
help="print the full reason when a device is skipped",
|
||||||
|
)
|
||||||
anker_parser.set_defaults(func=cmd_discover_anker)
|
anker_parser.set_defaults(func=cmd_discover_anker)
|
||||||
|
|
||||||
shelly_parser = subparsers.add_parser(
|
shelly_parser = subparsers.add_parser(
|
||||||
|
|||||||
+1
-1
@@ -418,7 +418,7 @@ def run_setup(prompt, choose, confirm):
|
|||||||
)
|
)
|
||||||
print()
|
print()
|
||||||
try:
|
try:
|
||||||
asyncio.run(anker.discover())
|
asyncio.run(anker.discover(explain_skipped=True))
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
print(f" Discovery failed: {type(err).__name__}: {err}")
|
print(f" Discovery failed: {type(err).__name__}: {err}")
|
||||||
return False
|
return False
|
||||||
|
|||||||
Reference in New Issue
Block a user