chore: switch to py3 print function

Also fix other problems due to flake8 upgrades.

Change-Id: I5cb6194e48c66e40ec7aa9739eb37550d6bf3e2a
This commit is contained in:
Zhihao Yuan 2013-07-19 10:30:43 -04:00
parent 0b94bdcff2
commit dddea2747d
9 changed files with 65 additions and 58 deletions

View File

@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function
import atexit
import functools
import sys
@ -33,7 +34,7 @@ def _fail(returncode, ex):
:param ex: the error that occurred
"""
print >> sys.stderr, ex
print(ex, file=sys.stderr)
LOG.exception(ex)
sys.exit(returncode)

View File

@ -29,7 +29,7 @@ def lazy_property(write=False, delete=True):
setattr(self, attr_name, fn(self))
return getattr(self, attr_name)
def setter(self, value):
def setter(self, value):
setattr(self, attr_name, value)
def deleter(self):

View File

@ -185,7 +185,7 @@ class MongodbMessageTests(base.MessageControllerTest):
self.assertEqual(marker1, marker2)
self.assertEqual(marker2, marker3)
self.assertEqual(marker1, i+2)
self.assertEqual(marker1, i + 2)
def test_remove_expired(self):
num_projects = 10

View File

@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function
import json
from marconi.tests.system.common import functionlib
@ -37,7 +38,7 @@ def verify_claim_msg(count, *claim_response):
if test_result_flag:
test_result_flag = query_claim(headers, body)
else:
print 'More msgs returned than specified in limit'
print('More msgs returned than specified in limit')
return test_result_flag
@ -77,17 +78,17 @@ def query_claim(headers, *body):
test_result_flag = verify_query_msgs(query_msgs, msg_list)
if not test_result_flag:
print 'URL'
print url
print 'HEADER'
print header
print 'Messages returned by Query Claim'
print query_msgs
print '# of Messages returned by Query Claim', len(query_msgs)
print 'Messages returned by Claim Messages'
print msg_list
print '# of Messages returned by Claim messages', len(msg_list)
print 'Query Claim Failed'
print('URL')
print(url)
print('HEADER')
print(header)
print('Messages returned by Query Claim')
print(query_msgs)
print('# of Messages returned by Query Claim', len(query_msgs))
print('Messages returned by Claim Messages')
print(msg_list)
print('# of Messages returned by Claim messages', len(msg_list))
print('Query Claim Failed')
return test_result_flag
@ -128,9 +129,9 @@ def verify_patch_claim(url, header, ttl_extended):
ttl = response_body['ttl']
if ttl < ttl_extended:
print get_claim.status_code
print get_claim.headers
print get_claim.text
print(get_claim.status_code)
print(get_claim.headers)
print(get_claim.text)
test_result_flag = False
return test_result_flag
@ -163,11 +164,11 @@ def delete_claimed_msgs(*claim_response):
if delete_response.status_code == 204:
test_result_flag = functionlib.verify_delete(url, header)
else:
print 'DELETE message with claim ID: {}'.format(url)
print delete_response.status_code
print delete_response.headers
print delete_response.text
print 'Delete Claimed Message Failed'
print('DELETE message with claim ID: {}'.format(url))
print(delete_response.status_code)
print(delete_response.headers)
print(delete_response.text)
print('Delete Claimed Message Failed')
return test_result_flag
@ -185,9 +186,9 @@ def get_claimed_msgs(*claim_response):
for url in urllist:
get_response = http.get(url, header)
if get_response.status_code != 200:
print url
print header
print 'Get Response Code: {}'.format(get_response.status_code)
print(url)
print(header)
print('Get Response Code: {}'.format(get_response.status_code))
test_result_flag = False
if not test_result_flag:
@ -212,9 +213,10 @@ def release_claim(*claim_response):
if release_response.status_code == 204:
test_result_flag = functionlib.verify_delete(url, header)
else:
print 'Release Claim HTTP code:{}'.format(release_response.status_code)
print release_response.headers
print release_response.text
print('Release Claim HTTP code:{}'.format(
release_response.status_code))
print(release_response.headers)
print(release_response.text)
assert test_result_flag, 'Release Claim Failed'
if not test_result_flag:

View File

@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function
import binascii
import json
import os
@ -177,11 +178,11 @@ def verify_delete(url, header):
else:
print('GET after DELETE failed')
print('URL')
print url
print(url)
print('headers')
print header
print(header)
print('Response Body')
print getmsg.text
print 'GET Code {}'.format(getmsg.status_code)
print(getmsg.text)
print('GET Code {}'.format(getmsg.status_code))
return test_result_flag

View File

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import with_statement
from __future__ import print_function
import json
import random
@ -129,11 +129,11 @@ def verify_post_msg(msg_headers, posted_body):
else:
print('Failed to GET {}'.format(url))
print('Request Header')
print header
print(header)
print('Response Headers')
print getmsg.headers
print(getmsg.headers)
print('Response Body')
print getmsg.text
print(getmsg.text)
return test_result_flag
@ -196,11 +196,11 @@ def delete_msg(*postresponse):
else:
print('DELETE message failed')
print('URL')
print url
print(url)
print('headers')
print header
print(header)
print('Response Body')
print deletemsg.text
print 'DELETE Code {}'.format(deletemsg.status_code)
print(deletemsg.text)
print('DELETE Code {}'.format(deletemsg.status_code))
return test_result_flag

View File

@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function
import binascii
import json
import os
@ -56,8 +57,8 @@ def verify_queue_stats(*get_response):
if test_result_flag:
return test_result_flag
else:
print headers
print body
print(headers)
print(body)
assert test_result_flag, 'Get Request stats failed'
@ -89,7 +90,7 @@ def verify_list_queues(*list_queue_response):
if False in test_result_flags:
test_result_flag = False
print 'List Queue API response: {}'.format(response_body)
print('List Queue API response: {}'.format(response_body))
return test_result_flag
if links[0]['rel'] == 'next':
@ -117,8 +118,8 @@ def verify_listed(queue, detail_enabled):
if keys == expected_keys:
return test_result_flag
else:
print 'list_queue response does not match expected response'
print queue
print('list_queue response does not match expected response')
print(queue)
test_result_flag = False
return test_result_flag

View File

@ -19,6 +19,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from __future__ import print_function
import os
import sys
@ -44,7 +45,7 @@ def print_help(venv, root):
Also, make test will automatically use the virtualenv.
"""
print help % (venv, root)
print(help % (venv, root))
def main(argv):

View File

@ -21,6 +21,7 @@ virtual environments.
Synced in from openstack-common
"""
from __future__ import print_function
import argparse
import os
import subprocess
@ -39,7 +40,7 @@ class InstallVenv(object):
self.project = project
def die(self, message, *args):
print >> sys.stderr, message % args
print(message % args, file=sys.stderr)
sys.exit(1)
def check_python_version(self):
@ -86,20 +87,20 @@ class InstallVenv(object):
virtual environment.
"""
if not os.path.isdir(self.venv):
print 'Creating venv...',
print('Creating venv...', end=' ')
if no_site_packages:
self.run_command(['virtualenv', '-q', '--no-site-packages',
self.venv])
else:
self.run_command(['virtualenv', '-q', self.venv])
print 'done.'
print 'Installing pip in venv...',
print('done.')
print('Installing pip in venv...', end=' ')
if not self.run_command(['tools/with_venv.sh', 'easy_install',
'pip>1.0']).strip():
self.die("Failed to install pip.")
print 'done.'
print('done.')
else:
print "venv already exists..."
print("venv already exists...")
pass
def pip_install(self, *args):
@ -108,7 +109,7 @@ class InstallVenv(object):
redirect_output=False)
def install_dependencies(self):
print 'Installing dependencies with pip (this can take a while)...'
print('Installing dependencies with pip (this can take a while)...')
# First things first, make sure our venv has the latest pip and
# distribute.
@ -150,12 +151,12 @@ class Distro(InstallVenv):
return
if self.check_cmd('easy_install'):
print 'Installing virtualenv via easy_install...',
print('Installing virtualenv via easy_install...', end=' ')
if self.run_command(['easy_install', 'virtualenv']):
print 'Succeeded'
print('Succeeded')
return
else:
print 'Failed'
print('Failed')
self.die('ERROR: virtualenv not found.\n\n%s development'
' requires virtualenv, please install it using your'
@ -181,7 +182,7 @@ class Fedora(Distro):
check_exit_code=False)[1] == 0
def yum_install(self, pkg, **kwargs):
print "Attempting to install '%s' via yum" % pkg
print("Attempting to install '%s' via yum" % pkg)
self.run_command(['sudo', 'yum', 'install', '-y', pkg], **kwargs)
def apply_patch(self, originalfile, patchfile):