s3bundler_15.py 806 B

12345678910111213141516171819
  1. def commit(self):
  2. "Close archive and write index, dlq and tarball to S3"
  3. self.target.close()
  4. self.tarobj.seek(0)
  5. if self.dlq.tell() > 0:
  6. self.dlq.push()
  7. if self.index.tell() > 0:
  8. self.index.push()
  9. logger.info("uploading archive to s3://{bucket}/{key}".format(
  10. bucket=self.bucket,key=self.archivekey))
  11. try:
  12. self.s3.upload_fileobj(self.tarobj, self.bucket, self.archivekey)
  13. except botocore.exceptions.ClientError as e:
  14. logger.error("ERROR: Failed to upload archive: s3://{}/{}".format(self.bucket,
  15. self.archivekey))
  16. logger.error("Exception: %s", e, exc_info=True)
  17. sys.exit(4)
  18. self.manifest.success()