diff options
-rwxr-xr-x | linaro-cp.py | 21 |
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 |