From 7c366f5cbd3d99757ac0744c2deba7c48023bb63 Mon Sep 17 00:00:00 2001 From: bonuscheese Date: Tue, 22 Aug 2017 03:57:26 +1000 Subject: [PATCH] Fix 'format' method syntax to support Python 2.6 (Fixes #28198) (#28304) Fixes #28198 Changed how string format method is used to support Python 2.6 syntax. By adding in positional arguments to braces in format method (e.g. {0}, {1}), Python 2.6 can support this module, without causing issues in newer versions of Python. See ref for info on format differences w/ 2.6: https://docs.python.org/2/library/string.html#format-string-syntax --- lib/ansible/modules/cloud/amazon/s3_sync.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ansible/modules/cloud/amazon/s3_sync.py b/lib/ansible/modules/cloud/amazon/s3_sync.py index 11c0da833b..407ef53c1d 100644 --- a/lib/ansible/modules/cloud/amazon/s3_sync.py +++ b/lib/ansible/modules/cloud/amazon/s3_sync.py @@ -277,12 +277,12 @@ def calculate_multipart_etag(source_path, chunk_size=DEFAULT_CHUNK_SIZE): md5s.append(hashlib.md5(data)) if len(md5s) == 1: - new_etag = '"{}"'.format(md5s[0].hexdigest()) + new_etag = '"{0}"'.format(md5s[0].hexdigest()) else: # > 1 digests = b"".join(m.digest() for m in md5s) new_md5 = hashlib.md5(digests) - new_etag = '"{}-{}"'.format(new_md5.hexdigest(), len(md5s)) + new_etag = '"{0}-{1}"'.format(new_md5.hexdigest(), len(md5s)) return new_etag @@ -432,8 +432,8 @@ def filter_list(s3, bucket, s3filelist, strategy): remote_size = entry['s3_head']['ContentLength'] - entry['whytime'] = '{} / {}'.format(local_modified_epoch, remote_modified_epoch) - entry['whysize'] = '{} / {}'.format(local_size, remote_size) + entry['whytime'] = '{0} / {1}'.format(local_modified_epoch, remote_modified_epoch) + entry['whysize'] = '{0} / {1}'.format(local_size, remote_size) if local_modified_epoch <= remote_modified_epoch or local_size == remote_size: entry['skip_flag'] = True