Shorten the skipped-device message, full text behind a flag
This commit is contained in:
1 parent
04bdb0f150
commit
eb0a499aad
3 files changed
+25
-5
No files matched your search
+18
-4
@@ -108,6 +108,12 @@ def online_hint(info):
|
||||
return None
|
||||
|
||||
|
||||
BLUETOOTH_ONLY_SHORT = (
|
||||
"Bluetooth-only models cannot be used as a source. "
|
||||
"Details: --explain-skipped"
|
||||
)
|
||||
|
||||
|
||||
def clean_status(raw):
|
||||
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(
|
||||
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()
|
||||
|
||||
@@ -419,10 +431,12 @@ async def discover(
|
||||
continue
|
||||
|
||||
if not include_offline and online_hint(info) is False:
|
||||
print()
|
||||
print(f" {serial} - {model_label(part_number_of(info))}")
|
||||
print(" not cloud connected, skipping without subscribing.")
|
||||
label = model_label(part_number_of(info))
|
||||
print(f" {serial} - {label}: not cloud connected, skipped.")
|
||||
if explain_skipped:
|
||||
print(BLUETOOTH_ONLY_HINT)
|
||||
else:
|
||||
print(f" {BLUETOOTH_ONLY_SHORT}")
|
||||
continue
|
||||
|
||||
targets[serial] = info
|
||||
|
||||
@@ -172,6 +172,7 @@ def cmd_discover_anker(args):
|
||||
only_sn=args.sn,
|
||||
skip=args.skip,
|
||||
include_offline=args.include_offline,
|
||||
explain_skipped=args.explain_skipped,
|
||||
)
|
||||
)
|
||||
print()
|
||||
@@ -1319,6 +1320,11 @@ def build_parser():
|
||||
action="store_true",
|
||||
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)
|
||||
|
||||
shelly_parser = subparsers.add_parser(
|
||||
|
||||
+1
-1
@@ -418,7 +418,7 @@ def run_setup(prompt, choose, confirm):
|
||||
)
|
||||
print()
|
||||
try:
|
||||
asyncio.run(anker.discover())
|
||||
asyncio.run(anker.discover(explain_skipped=True))
|
||||
except Exception as err:
|
||||
print(f" Discovery failed: {type(err).__name__}: {err}")
|
||||
return False
|
||||
|
||||
Reference in new issue
Block a user