make upload snapshot work
This commit is contained in:
parent
45464c49f0
commit
6d3d4e5c2a
6
settings.ini.example
Normal file
6
settings.ini.example
Normal file
|
@ -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
|
|
@ -259,12 +259,15 @@ def save_snapshot_in_disk(snapshot, path):
|
||||||
f.write(json.dumps(snapshot))
|
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):
|
def send_snapshot_to_devicehub(snapshot, token, url):
|
||||||
headers = {
|
headers = {
|
||||||
f"Authorization": "Basic {token}",
|
f"Authorization": "Basic {token}",
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
}
|
}
|
||||||
return requests.post(url, data=snapshot, header=headers)
|
|
||||||
|
return requests.post(url, data=json.dumps(snapshot), headers=headers)
|
||||||
|
|
||||||
|
|
||||||
@logs
|
@logs
|
||||||
|
|
Loading…
Reference in a new issue