1234567891011121314151617181920 |
- def main(uri, cancel):
- # Check that dest is a valid S3 url
- split_rs = urlparse.urlsplit(uri)
- if split_rs.scheme != "s3":
- raise ValueError("'%s' is not an S3 url" % uri)
- s3 = boto.connect_s3()
- bucket = s3.lookup(split_rs.netloc)
-
- mpul = bucket.list_multipart_uploads()
- for mpu in mpul:
- if not cancel:
- print('s3-mp-cleanup.py s3://{}/{} -c {} # {} {}'.format(mpu.bucket.name, mpu.key_name, mpu.id, mpu.initiator.display_name, mpu.initiated))
- elif cancel == mpu.id:
- bucket.cancel_multipart_upload(mpu.key_name, mpu.id)
- break
- else:
- if cancel:
- print("No multipart upload {} found for {}".format(cancel, uri))
- sys.exit(1)
|