The patch b00bdc728e7a0ae697b4fc59a4f9958b688c6789 enabled flake8-checking to be run on ovs-bugtool.in which failed due to python3 issues. This patch fixes those issues.
Signed-off-by: Aaron Rosen <aaronoro...@gmail.com> --- utilities/bugtool/ovs-bugtool.in | 45 +++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/utilities/bugtool/ovs-bugtool.in b/utilities/bugtool/ovs-bugtool.in index ecf01f6..a666877 100755 --- a/utilities/bugtool/ovs-bugtool.in +++ b/utilities/bugtool/ovs-bugtool.in @@ -33,6 +33,7 @@ # or func_output(). # +from __future__ import print_function import getopt import re import os @@ -252,7 +253,7 @@ dev_null = open('/dev/null', 'r+') def output(x): global SILENT_MODE if not SILENT_MODE: - print x + print (x) def output_ts(x): @@ -355,7 +356,7 @@ def collect_data(): elif 'func' in v: try: s = v['func'](cap) - except Exception, e: + except Exception as e: s = str(e) if check_space(cap, k, len(s)): v['output'] = StringIOmtime(s) @@ -373,7 +374,7 @@ def main(argv=None): collect_all_info = True if '--help' in sys.argv: - print """\ + print ("""\ %(argv0)s: create status report bundles to assist in problem diagnosis usage: %(argv0)s OPTIONS @@ -398,12 +399,12 @@ Output options: --outfd=FD write output to FD (requires --output=tar) --unlimited ignore default limits on sizes of data collected --debug print ovs-bugtool debug info on stdout\ -""" % {'argv0': sys.argv[0]} +""" % {'argv0': sys.argv[0]}) sys.exit(0) # we need access to privileged files, exit if we are not running as root if os.getuid() != 0: - print >>sys.stderr, "Error: ovs-bugtool must be run as root" + print ("Error: ovs-bugtool must be run as root", file=sys.stderr) return 1 output_file = None @@ -418,8 +419,8 @@ Output options: argv, 'sy', ['capabilities', 'silent', 'yestoall', 'entries=', 'output=', 'outfd=', 'outfile=', 'all', 'unlimited', 'debug', 'ovs', 'log-days=']) - except getopt.GetoptError, opterr: - print >>sys.stderr, opterr + except getopt.GetoptError as opterr: + print (opterr, file=sys.stderr) return 2 try: @@ -439,7 +440,7 @@ Output options: if v in ['tar', 'tar.bz2', 'tar.gz', 'zip']: output_type = v else: - print >>sys.stderr, "Invalid output format '%s'" % v + print ("Invalid output format '%s'" % v, file=sys.stderr) return 2 # "-s" or "--silent" means suppress output (except for the final @@ -461,7 +462,8 @@ Output options: old = fcntl.fcntl(output_fd, fcntl.F_GETFD) fcntl.fcntl(output_fd, fcntl.F_SETFD, old | fcntl.FD_CLOEXEC) except: - print >>sys.stderr, "Invalid output file descriptor", output_fd + print ("Invalid output file descriptor", output_fd, + file=sys.stderr) return 2 if k == '--outfile': @@ -483,15 +485,16 @@ Output options: log_days = int(v) if len(params) != 1: - print >>sys.stderr, "Invalid additional arguments", str(params) + print ("Invalid additional arguments", str(params), file=sys.stderr) return 2 if output_fd != -1 and output_type != 'tar': - print >>sys.stderr, "Option '--outfd' only valid with '--output=tar'" + print ("Option '--outfd' only valid with '--output=tar'", + file=sys.stderr) return 2 if output_fd != -1 and output_file is not None: - print >>sys.stderr, "Cannot set both '--outfd' and '--outfile'" + print ("Cannot set both '--outfd' and '--outfile'", file=sys.stderr) return 2 if output_file is not None and not unlimited_data: @@ -713,10 +716,10 @@ exclude those logs from the archive. make_zip(subdir, output_file) if dbg: - print >>sys.stderr, "Category sizes (max, actual):\n" + print ("Category sizes (max, actual):\n", file=sys.stderr) for c in caps.keys(): - print >>sys.stderr, " %s (%d, %d)" % (c, caps[c][MAX_SIZE], - cap_sizes[c]) + print (" %s (%d, %d)" % (c, caps[c][MAX_SIZE], + cap_sizes[c]), file=sys.stderr) cleanup_ovsdb() return 0 @@ -970,7 +973,7 @@ def make_tar(subdir, suffix, output_fd, output_file): filename = "%s/%s.%s" % (BUG_DIR, subdir, suffix) else: filename = output_file - old_umask = os.umask(0077) + old_umask = os.umask(0o77) tf = tarfile.open(filename, mode) os.umask(old_umask) else: @@ -1003,7 +1006,7 @@ def make_tar(subdir, suffix, output_fd, output_file): if output_fd == -1: output('Writing tarball %s successful.' % filename) if SILENT_MODE: - print filename + print (filename) def make_zip(subdir, output_file): @@ -1013,7 +1016,7 @@ def make_zip(subdir, output_file): filename = "%s/%s.zip" % (BUG_DIR, subdir) else: filename = output_file - old_umask = os.umask(0077) + old_umask = os.umask(0o77) zf = zipfile.ZipFile(filename, 'w', zipfile.ZIP_DEFLATED) os.umask(old_umask) @@ -1037,7 +1040,7 @@ def make_zip(subdir, output_file): output('Writing archive %s successful.' % filename) if SILENT_MODE: - print filename + print (filename) def make_inventory(inventory, subdir): @@ -1149,7 +1152,7 @@ def print_capabilities(): "ns", CAP_XML_ROOT, None) map(lambda key: capability(document, key), [k for k in caps.keys() if not caps[k][HIDDEN]]) - print document.toprettyxml() + print (document.toprettyxml()) def capability(document, key): @@ -1362,5 +1365,5 @@ if __name__ == "__main__": try: sys.exit(main()) except KeyboardInterrupt: - print "\nInterrupted." + print ("\nInterrupted.") sys.exit(3) -- 1.9.1 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev