@@ -168,8 +168,8 @@ def post_request(url, timeout, data, headers=[], proxy=None):
168
168
else :
169
169
raise MyError ("server returned non-JSON output" )
170
170
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
173
173
174
174
def upload_file (filepath , upload_url , headers , timeout , proxy = None ):
175
175
'''Upload file to given Github upload URL
@@ -248,15 +248,21 @@ def main():
248
248
headers ['Authorization' ] = _get_auth (user , password )
249
249
250
250
# Check if the tag is not already present in the repo.
251
+ print "Checking if tag " + tag + " is already present in releases"
251
252
_url = "https://api.github.com"
252
253
_path = '%s%s%s' % ("/repos/" , repo , "/releases/tags/" + tag )
253
254
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
+
260
266
prerelease = False
261
267
if arguments .prerelease :
262
268
prerelease = True
@@ -295,8 +301,8 @@ def main():
295
301
release_json = post_request (url ,
296
302
arguments .timeout , payload , headers , proxy )
297
303
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
300
306
sys .exit (1 )
301
307
302
308
if upload_url :
0 commit comments