From ef32b3de26ceb8a9572ed616bc77e0d68071fb31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Thu, 4 Oct 2018 13:23:17 -0400 Subject: [PATCH] drop the renaming, add removal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- s3utils/move_builds.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/s3utils/move_builds.py b/s3utils/move_builds.py index 1bdf0ed..743b03a 100644 --- a/s3utils/move_builds.py +++ b/s3utils/move_builds.py @@ -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