build.py improved error handling

This commit is contained in:
Verkehrsrot 2019-05-30 11:14:23 +02:00
parent b17ddd2ab0
commit c5b631df13

View File

@ -89,16 +89,19 @@ def publish_bintray(source, target, env):
"X-Bintray-Override": "1" "X-Bintray-Override": "1"
} }
r = requests.put( r = None
url,
try:
r = requests.put(url,
data=open(firmware_path, "rb"), data=open(firmware_path, "rb"),
headers=headers, headers=headers,
auth=(user,apitoken)) auth=(user,apitoken))
r.raise_for_status()
except requests.exceptions.RequestException as e:
sys.stderr.write("Failed to submit package: %s\n" %
("%s\n%s" % (r.status_code, r.text) if r else str(e)))
env.Exit(1)
if r.status_code != 201:
print("Failed to submit package: {0}\n{1}".format(
r.status_code, r.text))
else:
print("The firmware has been successfuly published at Bintray.com!") print("The firmware has been successfuly published at Bintray.com!")
# put build file name and upload command to platformio environment # put build file name and upload command to platformio environment