From 6d3d4e5c2a200b196757cd74527bb591e6806c2a Mon Sep 17 00:00:00 2001 From: pedro Date: Thu, 19 Sep 2024 14:01:54 -0300 Subject: [PATCH] make upload snapshot work --- settings.ini.example | 6 ++++++ workbench-script.py | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 settings.ini.example diff --git a/settings.ini.example b/settings.ini.example new file mode 100644 index 0000000..35fb89b --- /dev/null +++ b/settings.ini.example @@ -0,0 +1,6 @@ +[settings] +url = http://127.0.0.1:8000/api/snapshot/ +token = '1234' +# path = /path/to/save +# device = your_device_name +# # erase = basic diff --git a/workbench-script.py b/workbench-script.py index be7de13..9edb2e1 100644 --- a/workbench-script.py +++ b/workbench-script.py @@ -259,12 +259,15 @@ def save_snapshot_in_disk(snapshot, path): f.write(json.dumps(snapshot)) +# TODO sanitize url, if url is like this, it fails +# url = 'http://127.0.0.1:8000/api/snapshot/' def send_snapshot_to_devicehub(snapshot, token, url): headers = { f"Authorization": "Basic {token}", "Content-Type": "application/json" } - return requests.post(url, data=snapshot, header=headers) + + return requests.post(url, data=json.dumps(snapshot), headers=headers) @logs