-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupload.py
32 lines (23 loc) · 849 Bytes
/
upload.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/dev python
import os
import sys
import argparse
import requests
def upload(path, url):
headers = {
"X-Flash-Mode": "firmware",
"Content-Type": "application/octet-stream",
}
with open(path, "rb") as f:
print("Uploading %s to %s..." % (path, url))
r = requests.post(url, headers=headers, data=f)
print("Upload complete! %s" % r.text)
parser = argparse.ArgumentParser(description='Upload firmware to to OTA target')
parser.add_argument('-u', '--url', required=True, help="URL on where to upload the firmware.bin")
parser.add_argument('firmware', help="Path to the firmware.bin that should be uploaded")
args = parser.parse_args()
url = args.url
firmware = args.firmware
if not os.path.isfile(firmware):
sys.exit("Firmare file %s does not exists." % firmware)
upload(firmware, url)