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,17 +89,20 @@ def publish_bintray(source, target, env):
"X-Bintray-Override": "1" "X-Bintray-Override": "1"
} }
r = requests.put( r = None
url,
data=open(firmware_path, "rb"), try:
headers=headers, r = requests.put(url,
auth=(user, apitoken)) data=open(firmware_path, "rb"),
headers=headers,
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("The firmware has been successfuly published at Bintray.com!")
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!")
# put build file name and upload command to platformio environment # put build file name and upload command to platformio environment
env.Replace( env.Replace(