Merge "Use print function rather than print statement"

This commit is contained in:
Jenkins 2013-10-15 01:49:50 +00:00 committed by Gerrit Code Review
commit 767bf3b536
9 changed files with 54 additions and 40 deletions

View File

@ -102,6 +102,7 @@ class CoverageController(object):
def _start_coverage_telnet(self, tn, service):
data_file = os.path.join(self.data_path,
'.nova-coverage.%s' % str(service))
tn.write('from __future__ import print_function\n')
tn.write('import sys\n')
tn.write('from coverage import coverage\n')
tn.write("coverInst = coverage(data_file='%s') "
@ -109,7 +110,7 @@ class CoverageController(object):
"else coverInst\n" % data_file)
tn.write('coverInst.skipModules = sys.modules.keys()\n')
tn.write("coverInst.start()\n")
tn.write("print 'finished'\n")
tn.write("print('finished')\n")
tn.expect([re.compile('finished')])
def _start_coverage(self, req, body):
@ -147,7 +148,7 @@ class CoverageController(object):
def _stop_coverage_telnet(self, tn):
tn.write("coverInst.stop()\n")
tn.write("coverInst.save()\n")
tn.write("print 'finished'\n")
tn.write("print('finished')\n")
tn.expect([re.compile('finished')])
def _check_coverage(self):
@ -170,14 +171,14 @@ class CoverageController(object):
if xml:
execute = str("coverInst.xml_report(outfile='%s')\n" % path)
tn.write(execute)
tn.write("print 'finished'\n")
tn.write("print('finished')\n")
tn.expect([re.compile('finished')])
else:
execute = str("output = open('%s', 'w')\n" % path)
tn.write(execute)
tn.write("coverInst.report(file=output)\n")
tn.write("output.close()\n")
tn.write("print 'finished'\n")
tn.write("print('finished')\n")
tn.expect([re.compile('finished')])
tn.close()
@ -244,7 +245,7 @@ class CoverageController(object):
def _reset_coverage_telnet(self, tn):
tn.write("coverInst.erase()\n")
tn.write("print 'finished'\n")
tn.write("print('finished')\n")
tn.expect([re.compile('finished')])
def _reset_coverage(self, req):

View File

@ -117,6 +117,7 @@ class CoverageController(wsgi.Controller):
def _start_coverage_telnet(self, tn, service):
data_file = os.path.join(self.data_path,
'.nova-coverage.%s' % str(service))
tn.write('from __future__ import print_function\n')
tn.write('import sys\n')
tn.write('from coverage import coverage\n')
tn.write("coverInst = coverage(data_file='%s') "
@ -124,7 +125,7 @@ class CoverageController(wsgi.Controller):
"else coverInst\n" % data_file)
tn.write('coverInst.skipModules = sys.modules.keys()\n')
tn.write("coverInst.start()\n")
tn.write("print 'finished'\n")
tn.write("print('finished')\n")
tn.expect([re.compile('finished')])
def _check_coverage_module_loaded(self):
@ -172,7 +173,7 @@ class CoverageController(wsgi.Controller):
def _stop_coverage_telnet(self, tn):
tn.write("coverInst.stop()\n")
tn.write("coverInst.save()\n")
tn.write("print 'finished'\n")
tn.write("print('finished')\n")
tn.expect([re.compile('finished')])
def _check_coverage(self):
@ -199,14 +200,14 @@ class CoverageController(wsgi.Controller):
if xml:
execute = str("coverInst.xml_report(outfile='%s')\n" % path)
tn.write(execute)
tn.write("print 'finished'\n")
tn.write("print('finished')\n")
tn.expect([re.compile('finished')])
else:
execute = str("output = open('%s', 'w')\n" % path)
tn.write(execute)
tn.write("coverInst.report(file=output)\n")
tn.write("output.close()\n")
tn.write("print 'finished'\n")
tn.write("print('finished')\n")
tn.expect([re.compile('finished')])
tn.close()
@ -277,7 +278,7 @@ class CoverageController(wsgi.Controller):
def _reset_coverage_telnet(self, tn):
tn.write("coverInst.erase()\n")
tn.write("print 'finished'\n")
tn.write("print('finished')\n")
tn.expect([re.compile('finished')])
@extensions.expected_errors(503)

View File

@ -1097,7 +1097,7 @@ class AgentBuildCommands(object):
agent_build.version, agent_build.md5hash))
print(' %s' % agent_build.url)
print
print()
@args('--os', metavar='<os>', help='os')
@args('--architecture', dest='architecture',

View File

@ -379,7 +379,7 @@ class Debug(Middleware):
print(('*' * 40) + ' RESPONSE HEADERS')
for (key, value) in resp.headers.iteritems():
print(key, '=', value)
print
print()
resp.app_iter = self.print_generator(resp.app_iter)

View File

@ -21,6 +21,9 @@ find_unused_options.py
Compare the nova.conf file with the nova.conf.sample file to find any unused
options or default values in nova.conf
'''
from __future__ import print_function
import argparse
import os
import sys
@ -74,7 +77,7 @@ if __name__ == '__main__':
for k, v in sorted(conf_file_options.items()):
if k not in sample_conf_file_options:
print "Unused:", k
print("Unused:", k)
for k, v in sorted(conf_file_options.items()):
if k in sample_conf_file_options and v == sample_conf_file_options[k]:
print "Default valued:", k
print("Default valued:", k)

View File

@ -31,6 +31,9 @@ Run like:
./tools/db/schema_diff.py mysql master:latest my_branch:82
"""
from __future__ import print_function
import datetime
import glob
import os
@ -191,19 +194,19 @@ def git_has_uncommited_changes():
def die(msg):
print >> sys.stderr, "ERROR: %s" % msg
print("ERROR: %s" % msg, file=sys.stderr)
sys.exit(1)
def usage(msg=None):
if msg:
print >> sys.stderr, "ERROR: %s" % msg
print("ERROR: %s" % msg, file=sys.stderr)
prog = "schema_diff.py"
args = ["<mysql|postgres>", "<orig-branch:orig-version>",
"<new-branch:new-version>"]
print >> sys.stderr, "usage: %s %s" % (prog, ' '.join(args))
print("usage: %s %s" % (prog, ' '.join(args)), file=sys.stderr)
sys.exit(1)

View File

@ -19,6 +19,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from __future__ import print_function
import os
import sys
@ -44,7 +46,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

@ -18,6 +18,8 @@
"""pylint error checking."""
from __future__ import print_function
import cStringIO as StringIO
import json
import re
@ -114,9 +116,9 @@ class ErrorKeys(object):
@classmethod
def print_json(cls, errors, output=sys.stdout):
print >>output, "# automatically generated by tools/lintstack.py"
print("# automatically generated by tools/lintstack.py", file=output)
for i in sorted(errors.keys()):
print >>output, json.dumps(i)
print(json.dumps(i), file=output)
@classmethod
def from_file(cls, filename):
@ -139,7 +141,7 @@ def run_pylint():
def generate_error_keys(msg=None):
print "Generating", KNOWN_PYLINT_EXCEPTIONS_FILE
print("Generating", KNOWN_PYLINT_EXCEPTIONS_FILE)
if msg is None:
msg = run_pylint()
errors = LintOutput.from_msg_to_dict(msg)
@ -148,30 +150,30 @@ def generate_error_keys(msg=None):
def validate(newmsg=None):
print "Loading", KNOWN_PYLINT_EXCEPTIONS_FILE
print("Loading", KNOWN_PYLINT_EXCEPTIONS_FILE)
known = ErrorKeys.from_file(KNOWN_PYLINT_EXCEPTIONS_FILE)
if newmsg is None:
print "Running pylint. Be patient..."
print("Running pylint. Be patient...")
newmsg = run_pylint()
errors = LintOutput.from_msg_to_dict(newmsg)
print "Unique errors reported by pylint: was %d, now %d." \
% (len(known), len(errors))
print("Unique errors reported by pylint: was %d, now %d."
% (len(known), len(errors)))
passed = True
for err_key, err_list in errors.items():
for err in err_list:
if err_key not in known:
print err.lintoutput
print
print(err.lintoutput)
print()
passed = False
if passed:
print "Congrats! pylint check passed."
print("Congrats! pylint check passed.")
redundant = known - set(errors.keys())
if redundant:
print "Extra credit: some known pylint exceptions disappeared."
print("Extra credit: some known pylint exceptions disappeared.")
for i in sorted(redundant):
print json.dumps(i)
print "Consider regenerating the exception file if you will."
print(json.dumps(i))
print("Consider regenerating the exception file if you will.")
else:
print ("Please fix the errors above. If you believe they are false"
" positives, run 'tools/lintstack.py generate' to overwrite.")
@ -179,10 +181,10 @@ def validate(newmsg=None):
def usage():
print """Usage: tools/lintstack.py [generate|validate]
print("""Usage: tools/lintstack.py [generate|validate]
To generate pylint_exceptions file: tools/lintstack.py generate
To validate the current commit: tools/lintstack.py
"""
""")
def main():

View File

@ -32,6 +32,8 @@ Due to the risk of false positives, the results from this need some human
interpretation.
"""
from __future__ import print_function
import optparse
import string
import subprocess
@ -39,12 +41,12 @@ import sys
def run(cmd, fail_ok=False):
print "running: %s" % cmd
print("running: %s" % cmd)
obj = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
shell=True)
obj.wait()
if obj.returncode != 0 and not fail_ok:
print "The above command terminated with an error."
print("The above command terminated with an error.")
sys.exit(obj.returncode)
return obj.stdout.read()
@ -95,13 +97,13 @@ def main():
run("git checkout %s" % original_branch)
run("git branch -D %s" % new_branch)
print expect_failure
print ""
print "*******************************"
print(expect_failure)
print("")
print("*******************************")
if test_works:
print "FOUND a regression test"
print("FOUND a regression test")
else:
print "NO regression test"
print("NO regression test")
sys.exit(1)