From fc603b22403e06286dfb68ae813428eab300b992 Mon Sep 17 00:00:00 2001 From: pedro Date: Mon, 30 Sep 2024 08:09:23 -0300 Subject: [PATCH] workbench-script: verify if snapshot was received --- workbench-script.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/workbench-script.py b/workbench-script.py index 3cf9e12..411d6e7 100644 --- a/workbench-script.py +++ b/workbench-script.py @@ -311,8 +311,12 @@ def send_snapshot_to_devicehub(snapshot, token, url): "Content-Type": "application/json" } try: - requests.post(url, data=json.dumps(snapshot), headers=headers) - print(f"workbench: INFO: Snapshot sent to '{url}'") + response = requests.post(url, data=json.dumps(snapshot), headers=headers) + 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}") + 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}")