Skip to content

Commit bf0af47

Browse files
committed
fix release checking
1 parent 26475a4 commit bf0af47

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

tools/dorelease.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ def post_request(url, timeout, data, headers=[], proxy=None):
168168
else:
169169
raise MyError("server returned non-JSON output")
170170
except HTTPError as e:
171-
print e.code
172-
raise MyError("got HTTP error: {} ({})".format(e.code, e.reason))
171+
# print "got HTTP error: {} ({})".format(e.code, e.reason)
172+
raise e
173173

174174
def upload_file(filepath, upload_url, headers, timeout, proxy=None):
175175
'''Upload file to given Github upload URL
@@ -248,15 +248,21 @@ def main():
248248
headers['Authorization'] = _get_auth(user, password)
249249

250250
# Check if the tag is not already present in the repo.
251+
print "Checking if tag " + tag + " is already present in releases"
251252
_url = "https://api.github.com"
252253
_path = '%s%s%s' % ("/repos/", repo, "/releases/tags/" + tag)
253254
url = '%s%s' % (_url, _path)
254-
output_json = post_request(url,
255-
arguments.timeout, None, headers, proxy)
256-
if output_json["tag_name"] == tag:
257-
print "tag '" + tag + "' already present in the releases"
258-
sys.exit(1)
259-
255+
try:
256+
output_json = post_request(url,
257+
arguments.timeout, None, headers, proxy)
258+
if output_json["tag_name"] == tag:
259+
print "tag '" + tag + "' already present in the releases"
260+
sys.exit(1)
261+
except HTTPError as e:
262+
if e.code != 404:
263+
print "Got HTTP error: " + str(e.value)
264+
sys.exit(1)
265+
260266
prerelease = False
261267
if arguments.prerelease:
262268
prerelease = True
@@ -295,8 +301,8 @@ def main():
295301
release_json = post_request(url,
296302
arguments.timeout, payload, headers, proxy)
297303
upload_url = release_json["upload_url"]
298-
except MyError as e:
299-
print 'My exception occurred, value:', e.value
304+
except HTTPError as e:
305+
print 'HTTP exception occurred, value:', e.value
300306
sys.exit(1)
301307

302308
if upload_url:

0 commit comments

Comments
 (0)