def _upload_file_to_rackspace(self, file, container, attempt=0):
"""Upload file to rackspace."""
try:
chksum = pyrax.utils.get_checksum(file)
self.cf.upload_file(container,
file,
obj_name=secure_filename(file.filename),
etag=chksum)
return True
except Exception as e:
print "Uploader exception" # TODO: Log this!
traceback.print_exc()
attempt += 1
if (attempt < 3):
time.sleep(1) # Wait one second and try again
return self._upload_file_to_rackspace(file, container, attempt)
else:
print "Tried to upload two times. Failed!" # TODO: Log this!
raise
评论列表
文章目录