Convert to python3 style print() syntax
Use __future__ imports to keep this working for python2
This commit is contained in:
parent
34c193108c
commit
55288c4551
30
setup.py
30
setup.py
|
@ -78,11 +78,11 @@ class my_build_i18n(distutils.command.build.build):
|
||||||
potpath = "po/POTFILES.in"
|
potpath = "po/POTFILES.in"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
print "Writing %s" % potpath
|
print("Writing %s" % potpath)
|
||||||
file(potpath, "w").write(potfiles)
|
file(potpath, "w").write(potfiles)
|
||||||
self._run()
|
self._run()
|
||||||
finally:
|
finally:
|
||||||
print "Removing %s" % potpath
|
print("Removing %s" % potpath)
|
||||||
os.unlink(potpath)
|
os.unlink(potpath)
|
||||||
|
|
||||||
def _run(self):
|
def _run(self):
|
||||||
|
@ -168,7 +168,7 @@ class my_build(distutils.command.build.build):
|
||||||
wrapper += "exec \"%s\" \"$@\"" % (sharepath)
|
wrapper += "exec \"%s\" \"$@\"" % (sharepath)
|
||||||
|
|
||||||
newpath = os.path.abspath(os.path.join("build", app))
|
newpath = os.path.abspath(os.path.join("build", app))
|
||||||
print "Generating %s" % newpath
|
print("Generating %s" % newpath)
|
||||||
file(newpath, "w").write(wrapper)
|
file(newpath, "w").write(wrapper)
|
||||||
|
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ class my_build(distutils.command.build.build):
|
||||||
newpath = os.path.join(os.path.dirname(path),
|
newpath = os.path.join(os.path.dirname(path),
|
||||||
appname + ".1")
|
appname + ".1")
|
||||||
|
|
||||||
print "Generating %s" % newpath
|
print("Generating %s" % newpath)
|
||||||
ret = os.system('pod2man '
|
ret = os.system('pod2man '
|
||||||
'--center "Virtual Machine Manager" '
|
'--center "Virtual Machine Manager" '
|
||||||
'--release %s --name %s '
|
'--release %s --name %s '
|
||||||
|
@ -235,11 +235,11 @@ class my_install(distutils.command.install.install):
|
||||||
def finalize_options(self):
|
def finalize_options(self):
|
||||||
if self.prefix is None:
|
if self.prefix is None:
|
||||||
if CLIConfig.prefix != sysprefix:
|
if CLIConfig.prefix != sysprefix:
|
||||||
print "Using configured prefix=%s instead of sysprefix=%s" % (
|
print("Using configured prefix=%s instead of sysprefix=%s" % (
|
||||||
CLIConfig.prefix, sysprefix)
|
CLIConfig.prefix, sysprefix))
|
||||||
self.prefix = CLIConfig.prefix
|
self.prefix = CLIConfig.prefix
|
||||||
else:
|
else:
|
||||||
print "Using sysprefix=%s" % sysprefix
|
print("Using sysprefix=%s" % sysprefix)
|
||||||
self.prefix = sysprefix
|
self.prefix = sysprefix
|
||||||
|
|
||||||
elif self.prefix != CLIConfig.prefix:
|
elif self.prefix != CLIConfig.prefix:
|
||||||
|
@ -367,7 +367,7 @@ class configure(distutils.core.Command):
|
||||||
template += "default_hvs = %s\n" % self.default_hvs
|
template += "default_hvs = %s\n" % self.default_hvs
|
||||||
|
|
||||||
file(CLIConfig.cfgpath, "w").write(template)
|
file(CLIConfig.cfgpath, "w").write(template)
|
||||||
print "Generated %s" % CLIConfig.cfgpath
|
print("Generated %s" % CLIConfig.cfgpath)
|
||||||
|
|
||||||
|
|
||||||
class TestBaseCommand(distutils.core.Command):
|
class TestBaseCommand(distutils.core.Command):
|
||||||
|
@ -442,7 +442,7 @@ class TestBaseCommand(distutils.core.Command):
|
||||||
try:
|
try:
|
||||||
unittest.installHandler()
|
unittest.installHandler()
|
||||||
except:
|
except:
|
||||||
print "installHandler hack failed"
|
print("installHandler hack failed")
|
||||||
|
|
||||||
tests = unittest.TestLoader().loadTestsFromNames(self._testfiles)
|
tests = unittest.TestLoader().loadTestsFromNames(self._testfiles)
|
||||||
if self.only:
|
if self.only:
|
||||||
|
@ -454,13 +454,13 @@ class TestBaseCommand(distutils.core.Command):
|
||||||
newtests.append(testcase)
|
newtests.append(testcase)
|
||||||
|
|
||||||
if not newtests:
|
if not newtests:
|
||||||
print "--only didn't find any tests"
|
print("--only didn't find any tests")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
tests = unittest.TestSuite(newtests)
|
tests = unittest.TestSuite(newtests)
|
||||||
print "Running only:"
|
print("Running only:")
|
||||||
for test in newtests:
|
for test in newtests:
|
||||||
print "%s" % test
|
print("%s" % test)
|
||||||
print
|
print()
|
||||||
|
|
||||||
t = unittest.TextTestRunner(verbosity=self.debug and 2 or 1)
|
t = unittest.TextTestRunner(verbosity=self.debug and 2 or 1)
|
||||||
|
|
||||||
|
@ -582,14 +582,14 @@ class CheckPylint(distutils.core.Command):
|
||||||
output_format = sys.stdout.isatty() and "colorized" or "text"
|
output_format = sys.stdout.isatty() and "colorized" or "text"
|
||||||
exclude = ["virtinst/progress.py"]
|
exclude = ["virtinst/progress.py"]
|
||||||
|
|
||||||
print "running pep8"
|
print("running pep8")
|
||||||
cmd = "pep8 "
|
cmd = "pep8 "
|
||||||
cmd += "--config tests/pep8.cfg "
|
cmd += "--config tests/pep8.cfg "
|
||||||
cmd += "--exclude %s " % ",".join(exclude)
|
cmd += "--exclude %s " % ",".join(exclude)
|
||||||
cmd += " ".join(files)
|
cmd += " ".join(files)
|
||||||
os.system(cmd)
|
os.system(cmd)
|
||||||
|
|
||||||
print "running pylint"
|
print("running pylint")
|
||||||
cmd = "pylint "
|
cmd = "pylint "
|
||||||
cmd += "--rcfile tests/pylint.cfg "
|
cmd += "--rcfile tests/pylint.cfg "
|
||||||
cmd += "--output-format=%s " % output_format
|
cmd += "--output-format=%s " % output_format
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# Copyright (C) 2013, 2014 Red Hat, Inc.
|
# Copyright (C) 2013, 2014 Red Hat, Inc.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import atexit
|
import atexit
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
@ -78,7 +80,7 @@ atexit.register(exit_cleanup)
|
||||||
|
|
||||||
|
|
||||||
def _fetch_distro(distro):
|
def _fetch_distro(distro):
|
||||||
print "Fetching distro=%s" % distro.name
|
print("Fetching distro=%s" % distro.name)
|
||||||
|
|
||||||
fetcher = urlfetcher.fetcherForURI(distro.url, "/tmp", meter)
|
fetcher = urlfetcher.fetcherForURI(distro.url, "/tmp", meter)
|
||||||
origenv = os.environ.pop("VIRTINST_TEST_SUITE")
|
origenv = os.environ.pop("VIRTINST_TEST_SUITE")
|
||||||
|
@ -91,7 +93,7 @@ def _fetch_distro(distro):
|
||||||
distro.kernel = kernel
|
distro.kernel = kernel
|
||||||
distro.initrd = initrd
|
distro.initrd = initrd
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print "fetching distro=%s failed: %s" % (distro.name, e)
|
print("fetching distro=%s failed: %s" % (distro.name, e))
|
||||||
finally:
|
finally:
|
||||||
fetcher.cleanupLocation()
|
fetcher.cleanupLocation()
|
||||||
if origenv:
|
if origenv:
|
||||||
|
@ -100,17 +102,17 @@ def _fetch_distro(distro):
|
||||||
|
|
||||||
def _test_distro(distro):
|
def _test_distro(distro):
|
||||||
os.system("clear")
|
os.system("clear")
|
||||||
print "\n"
|
print("\n")
|
||||||
if distro.warntype == WARN_RHEL4:
|
if distro.warntype == WARN_RHEL4:
|
||||||
print "RHEL4: Makes its way to the text installer, then chokes "
|
print("RHEL4: Makes its way to the text installer, then chokes ")
|
||||||
print "on our bogus URI http://HEY-THIS-IS-OUR-BAD-KICKSTART-URL.com/"
|
print("on our bogus URI http://HEY-THIS-IS-OUR-BAD-KICKSTART-URL.com/")
|
||||||
elif distro.warntype == WARN_RHEL5:
|
elif distro.warntype == WARN_RHEL5:
|
||||||
print "RHEL5, RHEL6, Fedora < 17: You'll get an error about a "
|
print("RHEL5, RHEL6, Fedora < 17: You'll get an error about a ")
|
||||||
print "bogus bootproto ITREADTHEKICKSTART. This means anaconda "
|
print("bogus bootproto ITREADTHEKICKSTART. This means anaconda ")
|
||||||
print "read our busted kickstart."
|
print("read our busted kickstart.")
|
||||||
else:
|
else:
|
||||||
print "RHEL7, Fedora >= 17: Chokes on the bogus URI in the early "
|
print("RHEL7, Fedora >= 17: Chokes on the bogus URI in the early ")
|
||||||
print "console screen when fetching the installer squashfs image."
|
print("console screen when fetching the installer squashfs image.")
|
||||||
|
|
||||||
originitrd = distro.initrd
|
originitrd = distro.initrd
|
||||||
kernel = distro.kernel
|
kernel = distro.kernel
|
||||||
|
@ -128,7 +130,7 @@ def _test_distro(distro):
|
||||||
"-net bridge,br=virbr0 -net nic,model=%s "
|
"-net bridge,br=virbr0 -net nic,model=%s "
|
||||||
"-kernel %s -initrd %s %s" %
|
"-kernel %s -initrd %s %s" %
|
||||||
(distro.name, nic, kernel, newinitrd, append))
|
(distro.name, nic, kernel, newinitrd, append))
|
||||||
print "\n\n" + cmd
|
print("\n\n" + cmd)
|
||||||
os.system(cmd)
|
os.system(cmd)
|
||||||
|
|
||||||
|
|
||||||
|
@ -142,7 +144,7 @@ class FetchTests(unittest.TestCase):
|
||||||
global _printfetch
|
global _printfetch
|
||||||
if _printfetch:
|
if _printfetch:
|
||||||
return
|
return
|
||||||
print """
|
print ("""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -152,7 +154,7 @@ First step is we need to go and fetch a bunch of distro kernel/initrd
|
||||||
from public trees. This is going to take a while. Let it run then come
|
from public trees. This is going to take a while. Let it run then come
|
||||||
back later and we will be waiting to continue.
|
back later and we will be waiting to continue.
|
||||||
|
|
||||||
"""
|
""")
|
||||||
prompt()
|
prompt()
|
||||||
_printfetch = True
|
_printfetch = True
|
||||||
|
|
||||||
|
@ -163,7 +165,7 @@ class InjectTests(unittest.TestCase):
|
||||||
if _printinitrd:
|
if _printinitrd:
|
||||||
return
|
return
|
||||||
|
|
||||||
print """
|
print("""
|
||||||
|
|
||||||
|
|
||||||
Okay, we have all the media. We are going to perform the initrd injection
|
Okay, we have all the media. We are going to perform the initrd injection
|
||||||
|
@ -171,7 +173,7 @@ of some broken kickstarts, then manually launch a qemu instance to verify
|
||||||
the kickstart is detected. How you know it's working depends on the distro.
|
the kickstart is detected. How you know it's working depends on the distro.
|
||||||
When each test launches, we will print the manual verification instructions.
|
When each test launches, we will print the manual verification instructions.
|
||||||
|
|
||||||
"""
|
""")
|
||||||
prompt()
|
prompt()
|
||||||
_printinitrd = True
|
_printinitrd = True
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
|
@ -42,7 +44,7 @@ class _FuzzyPredicate(dogtail.predicate.Predicate):
|
||||||
return
|
return
|
||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print "got predicate exception: %s" % e
|
print("got predicate exception: %s" % e)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -158,9 +160,9 @@ def print_nodes(root):
|
||||||
"""
|
"""
|
||||||
def _walk(node):
|
def _walk(node):
|
||||||
try:
|
try:
|
||||||
print node_string(node)
|
print(node_string(node))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print "got exception: %s" % e
|
print("got exception: %s" % e)
|
||||||
|
|
||||||
root.findChildren(_walk, isLambda=True)
|
root.findChildren(_walk, isLambda=True)
|
||||||
|
|
||||||
|
@ -174,6 +176,6 @@ def focused_nodes(root):
|
||||||
if node.focused:
|
if node.focused:
|
||||||
return node
|
return node
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print "got exception: %s" % e
|
print("got exception: %s" % e)
|
||||||
|
|
||||||
return root.findChildren(_walk, isLambda=True)
|
return root.findChildren(_walk, isLambda=True)
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
# MA 02110-1301 USA.
|
# MA 02110-1301 USA.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
import StringIO
|
import StringIO
|
||||||
|
@ -33,7 +35,7 @@ class TestVirtConv(unittest.TestCase):
|
||||||
def _convert_helper(self, infile, outfile, in_type, disk_format):
|
def _convert_helper(self, infile, outfile, in_type, disk_format):
|
||||||
outbuf = StringIO.StringIO()
|
outbuf = StringIO.StringIO()
|
||||||
def print_cb(msg):
|
def print_cb(msg):
|
||||||
print >> outbuf, msg
|
print(msg, file=outbuf)
|
||||||
|
|
||||||
converter = VirtConverter(conn, infile, print_cb=print_cb)
|
converter = VirtConverter(conn, infile, print_cb=print_cb)
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
# MA 02110-1301 USA.
|
# MA 02110-1301 USA.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
@ -44,7 +46,7 @@ warnings.simplefilter("ignore")
|
||||||
try:
|
try:
|
||||||
gi.check_version("3.14.0")
|
gi.check_version("3.14.0")
|
||||||
except (ValueError, AttributeError):
|
except (ValueError, AttributeError):
|
||||||
print "pygobject3 3.14.0 or later is required."
|
print("pygobject3 3.14.0 or later is required.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
@ -76,7 +78,7 @@ def _import_gtk(leftovers):
|
||||||
leftovers = sys.argv[1:]
|
leftovers = sys.argv[1:]
|
||||||
|
|
||||||
if Gtk.check_version(3, 14, 0):
|
if Gtk.check_version(3, 14, 0):
|
||||||
print "gtk3 3.14.0 or later is required."
|
print("gtk3 3.14.0 or later is required.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# This will error if Gtk wasn't correctly initialized
|
# This will error if Gtk wasn't correctly initialized
|
||||||
|
@ -94,7 +96,7 @@ def _import_gtk(leftovers):
|
||||||
if display:
|
if display:
|
||||||
msg += ": Could not open display: %s" % display
|
msg += ": Could not open display: %s" % display
|
||||||
logging.debug("".join(traceback.format_exc()))
|
logging.debug("".join(traceback.format_exc()))
|
||||||
print msg
|
print(msg)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
finally:
|
finally:
|
||||||
sys.argv = origargv
|
sys.argv = origargv
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
# MA 02110-1301 USA.
|
# MA 02110-1301 USA.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
from distutils.spawn import find_executable
|
from distutils.spawn import find_executable
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
@ -202,7 +204,7 @@ class VirtConverter(object):
|
||||||
if print_cb == -1 or print_cb is None:
|
if print_cb == -1 or print_cb is None:
|
||||||
def cb(msg):
|
def cb(msg):
|
||||||
if print_cb == -1:
|
if print_cb == -1:
|
||||||
print msg
|
print(msg)
|
||||||
self.print_cb = cb
|
self.print_cb = cb
|
||||||
else:
|
else:
|
||||||
self.print_cb = print_cb
|
self.print_cb = print_cb
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
# MA 02110-1301 USA.
|
# MA 02110-1301 USA.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import collections
|
import collections
|
||||||
import logging
|
import logging
|
||||||
|
@ -321,12 +323,12 @@ def fail(msg, do_exit=True):
|
||||||
|
|
||||||
def print_stdout(msg, do_force=False):
|
def print_stdout(msg, do_force=False):
|
||||||
if do_force or not get_global_state().quiet:
|
if do_force or not get_global_state().quiet:
|
||||||
print msg
|
print(msg)
|
||||||
|
|
||||||
|
|
||||||
def print_stderr(msg):
|
def print_stderr(msg):
|
||||||
logging.debug(msg)
|
logging.debug(msg)
|
||||||
print >> sys.stderr, msg
|
print(msg, file=sys.stderr)
|
||||||
|
|
||||||
|
|
||||||
def _fail_exit():
|
def _fail_exit():
|
||||||
|
@ -1101,10 +1103,10 @@ class VirtCLIParser(object):
|
||||||
"""
|
"""
|
||||||
Print out all _param names, triggered via ex. --disk help
|
Print out all _param names, triggered via ex. --disk help
|
||||||
"""
|
"""
|
||||||
print "--%s options:" % cls.cli_arg_name
|
print("--%s options:" % cls.cli_arg_name)
|
||||||
for arg in sorted(cls._virtargs, key=lambda p: p.cliname):
|
for arg in sorted(cls._virtargs, key=lambda p: p.cliname):
|
||||||
print " %s" % arg.cliname
|
print(" %s" % arg.cliname)
|
||||||
print
|
print()
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, guest, optstr):
|
def __init__(self, guest, optstr):
|
||||||
|
|
Loading…
Reference in New Issue