drop the renaming, add removal

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2018-10-04 13:23:17 -04:00
parent bd57b00e00
commit ef32b3de26
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
1 changed files with 9 additions and 9 deletions

View File

@ -15,13 +15,13 @@ s3 = session.client('s3',
for f in s3.list_objects_v2(Bucket=SRC_BUCKET)['Contents']:
name = f['Key']
when = f['LastModified']
new_name = 'StatusIm.{}.{}.nightly.{}'.format(
when.strftime('%y%m%d.%H%M%S'),
name[9:15],
name.split('.')[-1]
)
print('{:<25} -> {}'.format(name, new_name))
path = '/tmp/{}'.format(new_name)
# ignore is build is not a pr
if 'pr' != name.split('-')[-1].split('.')[0]:
continue
print('{:<25} {} -> {}'.format(name, SRC_BUCKET, DST_BUCKET))
path = '/tmp/{}'.format(name)
s3.download_file(SRC_BUCKET, name, path)
s3.upload_file(path, DST_BUCKET, new_name)
s3.upload_file(path, DST_BUCKET, name)
s3.delete_object(Bucket=SRC_BUCKET, Key=name)
os.remove(path)
break