From 3cf86161d04bc2d63e5c5dd97a6e3e2ec728ef7b Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Mon, 15 Jun 2015 05:15:28 +0000 Subject: [PATCH] Use py3 print. Signed-off-by: Robin H. Johnson --- s3tests/functional/__init__.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/s3tests/functional/__init__.py b/s3tests/functional/__init__.py index a5917e1..fe5fa45 100644 --- a/s3tests/functional/__init__.py +++ b/s3tests/functional/__init__.py @@ -1,3 +1,5 @@ +from __future__ import print_function +import sys import ConfigParser import boto.exception import boto.s3.connection @@ -55,15 +57,15 @@ def choose_bucket_prefix(template, max_len=30): def nuke_prefixed_buckets_on_conn(prefix, name, conn): - print 'Cleaning buckets from connection {name} prefix {prefix!r}.'.format( + print('Cleaning buckets from connection {name} prefix {prefix!r}.'.format( name=name, prefix=prefix, - ) + )) for bucket in conn.get_all_buckets(): - print 'prefix=',prefix + print('prefix=',prefix) if bucket.name.startswith(prefix): - print 'Cleaning bucket {bucket}'.format(bucket=bucket) + print('Cleaning bucket {bucket}'.format(bucket=bucket)) success = False for i in xrange(2): try: @@ -81,17 +83,17 @@ def nuke_prefixed_buckets_on_conn(prefix, name, conn): raise e keys = bucket.list(); for key in keys: - print 'Cleaning bucket {bucket} key {key}'.format( + print('Cleaning bucket {bucket} key {key}'.format( bucket=bucket, key=key, - ) + )) # key.set_canned_acl('private') bucket.delete_key(key.name, version_id = key.version_id) bucket.delete() success = True except boto.exception.S3ResponseError as e: if e.error_code != 'AccessDenied': - print 'GOT UNWANTED ERROR', e.error_code + print('GOT UNWANTED ERROR', e.error_code) raise # seems like we don't have permissions set appropriately, we'll # modify permissions and retry @@ -107,26 +109,26 @@ def nuke_prefixed_buckets(prefix): # If no regions are specified, use the simple method if targets.main.master == None: for name, conn in s3.items(): - print 'Deleting buckets on {name}'.format(name=name) + print('Deleting buckets on {name}'.format(name=name)) nuke_prefixed_buckets_on_conn(prefix, name, conn) else: # First, delete all buckets on the master connection for name, conn in s3.items(): if conn == targets.main.master.connection: - print 'Deleting buckets on {name} (master)'.format(name=name) + print('Deleting buckets on {name} (master)'.format(name=name)) nuke_prefixed_buckets_on_conn(prefix, name, conn) # Then sync to propagate deletes to secondaries region_sync_meta(targets.main, targets.main.master.connection) - print 'region-sync in nuke_prefixed_buckets' + print('region-sync in nuke_prefixed_buckets') # Now delete remaining buckets on any other connection for name, conn in s3.items(): if conn != targets.main.master.connection: - print 'Deleting buckets on {name} (non-master)'.format(name=name) + print('Deleting buckets on {name} (non-master)'.format(name=name)) nuke_prefixed_buckets_on_conn(prefix, name, conn) - print 'Done with cleanup of test buckets.' + print('Done with cleanup of test buckets.') class TargetConfig: def __init__(self, cfg, section):