summaryrefslogtreecommitdiff
path: root/linaro-cp.py
diff options
context:
space:
mode:
authorBen Copeland <ben.copeland@linaro.org>2017-03-23 11:39:44 +0000
committerBen Copeland <ben.copeland@linaro.org>2017-03-23 11:41:53 +0000
commit50aa24023d92a8c848df192ae2b201c958c5c673 (patch)
tree5756e250dd0a4c944675cbc347266a6dd2d8f9dc /linaro-cp.py
parentd67eea34a5b82dc0fb26f39575c97c2a3c081fff (diff)
S3: retry logic
Based on Andy Doan's patch, this allows a retry to happen on the temp url. Because we used signed urls with S3, this patch will request a new signed url and try again. Change-Id: I32595f73ce0d85b8dcc69e71f030deaa223d61d0
Diffstat (limited to 'linaro-cp.py')
-rwxr-xr-xlinaro-cp.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/linaro-cp.py b/linaro-cp.py
index e4dbf2c..2fcb297 100755
--- a/linaro-cp.py
+++ b/linaro-cp.py
@@ -107,7 +107,7 @@ class API_v1(object):
def upload(self, src, dst, options):
transfer_queue = self.get_transfer_queue(src, dst, options)
if not transfer_queue:
- print "Warning: no files to publish"
+ print("Warning: no files to publish")
if options.verbose:
pprint.pprint(transfer_queue)
if not options.dry_run:
@@ -160,11 +160,22 @@ class API_v3(API_v1):
if not mtype:
mtype = 'other'
- resp = self._upload_data(url, data={'Content-Type': mtype}, headers={'AuthToken': self.api_key})
+ data = {'Content-Type': mtype}
+ headers = {'AuthToken': self.api_key}
- # now find the tempurl and really publish
- location = resp.headers['location']
- self._put_s3(location, filename, mtype)
+ error = None
+ for x in range(3):
+ try:
+ # get the tempurl
+ resp = self._upload_data(url, data=data, headers=headers)
+ location = resp.headers['location']
+ # publish file
+ self._put_s3(location, filename, mtype)
+ return
+ except Exception as e:
+ time.sleep(3)
+ error = e
+ raise error
def link_latest(self, dst):
url = self.server + '/api/v3/link_latest/' + dst