From 46447cebaafeefcb29fd0aedb47270887771da45 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 1 Oct 2024 14:11:03 +0200 Subject: [PATCH] qr for workbench --- workbench-script.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/workbench-script.py b/workbench-script.py index 398c414..901781f 100644 --- a/workbench-script.py +++ b/workbench-script.py @@ -306,7 +306,21 @@ def send_snapshot_to_devicehub(snapshot, token, url): if response.status_code == 200: print(f"workbench: INFO: Snapshot successfully sent to '{url}'") else: - raise Exception(f"workbench: ERROR: Failed to send snapshot. HTTP {response.status_code}: {response.text}") + txt = "workbench: ERROR: Failed to send snapshot. HTTP {}: {}".format( + response.status_code, + response.text + ) + raise Exception(txt) + + try: + res = json.loads(response.text) + if res.get('public_url'): + qr = "echo {} | qrencode -t ANSI".format(res['public_url']) + print(exec_cmd(qr)) + if res.get("dhid"): + print(res['dhid']) + except Exception: + print(response.text) except Exception as e: print(f"workbench: ERROR: Snapshot not remotely sent. URL '{url}' is unreachable. Do you have internet? Is your server up & running?\n {e}")