def commit(self): "Close archive and write index, dlq and tarball to S3" self.target.close() self.tarobj.seek(0) if self.dlq.tell() > 0: self.dlq.push() if self.index.tell() > 0: self.index.push() logger.info("uploading archive to s3://{bucket}/{key}".format( bucket=self.bucket,key=self.archivekey)) try: self.s3.upload_fileobj(self.tarobj, self.bucket, self.archivekey) except botocore.exceptions.ClientError as e: logger.error("ERROR: Failed to upload archive: s3://{}/{}".format(self.bucket, self.archivekey)) logger.error("Exception: %s", e, exc_info=True) sys.exit(4) self.manifest.success()