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
9 changed files with 54 additions and 40 deletions
+5 -2
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)
+6 -3
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)
+3 -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):
+17 -15
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():
+9 -7
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)