workbench-script: verify if snapshot was received

This commit is contained in:
pedro 2024-09-30 08:09:23 -03:00
parent 8bf10139e5
commit d1c3fbc782
1 changed files with 5 additions and 1 deletions

View File

@ -312,7 +312,11 @@ def send_snapshot_to_devicehub(snapshot, token, url):
} }
try: try:
requests.post(url, data=json.dumps(snapshot), headers=headers) requests.post(url, data=json.dumps(snapshot), headers=headers)
print(f"workbench: INFO: Snapshot sent to '{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}")
except Exception as e: 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}") print(f"workbench: ERROR: Snapshot not remotely sent. URL '{url}' is unreachable. Do you have internet? Is your server up & running?\n {e}")