From c5b631df1352bbdead0767b13559d1c7cd0393b2 Mon Sep 17 00:00:00 2001 From: Verkehrsrot Date: Thu, 30 May 2019 11:14:23 +0200 Subject: [PATCH] build.py improved error handling --- build.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/build.py b/build.py index 11371c37..fd3b0f53 100644 --- a/build.py +++ b/build.py @@ -89,17 +89,20 @@ def publish_bintray(source, target, env): "X-Bintray-Override": "1" } - r = requests.put( - url, - data=open(firmware_path, "rb"), - headers=headers, - auth=(user, apitoken)) + r = None + + try: + r = requests.put(url, + 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("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 env.Replace(