diff --git a/bin/pungi b/bin/pungi index d5cd6bf0..221a79c0 100755 --- a/bin/pungi +++ b/bin/pungi @@ -11,6 +11,8 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, see . +from __future__ import print_function + import os import selinux import sys @@ -38,18 +40,18 @@ def main(): # You must be this high to ride if you're going to do root tasks if os.geteuid() != 0 and (opts.do_all or opts.do_buildinstall): - print >> sys.stderr, "You must run pungi as root" + print("You must run pungi as root", file=sys.stderr) return 1 if opts.do_all or opts.do_buildinstall: try: enforcing = selinux.security_getenforce() except: - print >> sys.stdout, "INFO: selinux disabled" + print("INFO: selinux disabled") enforcing = False if enforcing: - print >> sys.stdout, "WARNING: SELinux is enforcing. This may lead to a compose with selinux disabled." - print >> sys.stdout, "Consider running with setenforce 0." + print("WARNING: SELinux is enforcing. This may lead to a compose with selinux disabled.") + print("Consider running with setenforce 0.") # Set up the kickstart parser and pass in the kickstart file we were handed ksparser = pungi.ks.get_ksparser(ks_path=opts.config) @@ -70,19 +72,21 @@ def main(): try: os.makedirs(config.get('pungi', 'destdir')) except OSError: - print >> sys.stderr, "Error: Cannot create destination dir %s" % config.get('pungi', 'destdir') + print("Error: Cannot create destination dir %s" % config.get('pungi', 'destdir'), + file=sys.stderr) sys.exit(1) else: - print >> sys.stdout, "Warning: Reusing existing destination directory." + print("Warning: Reusing existing destination directory.") if not os.path.exists(config.get('pungi', 'workdirbase')): try: os.makedirs(config.get('pungi', 'workdirbase')) except OSError: - print >> sys.stderr, "Error: Cannot create working base dir %s" % config.get('pungi', 'workdirbase') + print("Error: Cannot create working base dir %s" % config.get('pungi', 'workdirbase'), + file=sys.stderr) sys.exit(1) else: - print >> sys.stdout, "Warning: Reusing existing working base directory." + print("Warning: Reusing existing working base directory.") cachedir = config.get('pungi', 'cachedir') @@ -90,7 +94,7 @@ def main(): try: os.makedirs(cachedir) except OSError: - print >> sys.stderr, "Error: Cannot create cache dir %s" % cachedir + print("Error: Cannot create cache dir %s" % cachedir, file=sys.stderr) sys.exit(1) # Set debuginfo flag @@ -172,11 +176,11 @@ def main(): else: mypungi.downloadSRPMs() - print "RPM size: %s MiB" % (mypungi.size_packages() / 1024 ** 2) + print("RPM size: %s MiB" % (mypungi.size_packages() / 1024 ** 2)) if not opts.nodebuginfo: - print "DEBUGINFO size: %s MiB" % (mypungi.size_debuginfo() / 1024 ** 2) + print("DEBUGINFO size: %s MiB" % (mypungi.size_debuginfo() / 1024 ** 2)) if not opts.nosource: - print "SRPM size: %s MiB" % (mypungi.size_srpms() / 1024 ** 2) + print("SRPM size: %s MiB" % (mypungi.size_srpms() / 1024 ** 2)) # Furthermore (but without the yumlock...) if not opts.sourceisos: @@ -202,7 +206,7 @@ def main(): if opts.do_all or opts.do_createiso: mypungi.doCreateIsos() - print "All done!" + print("All done!") if __name__ == '__main__': from argparse import ArgumentParser, Action diff --git a/bin/pungi-gather b/bin/pungi-gather index 7e5611cf..daf80f2c 100755 --- a/bin/pungi-gather +++ b/bin/pungi-gather @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +from __future__ import print_function import os import argparse @@ -159,13 +160,13 @@ def _get_url(pkg): def print_rpms(gather_obj): for pkg in sorted(gather_obj.result_binary_packages): - print "RPM%s: %s" % (_get_flags(gather_obj, pkg), _get_url(pkg)) + print("RPM%s: %s" % (_get_flags(gather_obj, pkg), _get_url(pkg))) for pkg in sorted(gather_obj.result_debug_packages): - print "DEBUGINFO%s: %s" % (_get_flags(gather_obj, pkg), _get_url(pkg)) + print("DEBUGINFO%s: %s" % (_get_flags(gather_obj, pkg), _get_url(pkg))) for pkg in sorted(gather_obj.result_source_packages): - print "SRPM%s: %s" % (_get_flags(gather_obj, pkg), _get_url(pkg)) + print("SRPM%s: %s" % (_get_flags(gather_obj, pkg), _get_url(pkg))) if __name__ == "__main__": diff --git a/bin/pungi-koji b/bin/pungi-koji index 7b0bd842..be3d9aaf 100755 --- a/bin/pungi-koji +++ b/bin/pungi-koji @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +from __future__ import print_function import os import sys @@ -213,10 +214,10 @@ def main(): pungi.checks.check_umask(logger) errors, warnings = pungi.checks.validate(conf) for warning in warnings: - print >>sys.stderr, warning + print(warning, file=sys.stderr) if errors: for error in errors: - print >>sys.stderr, error + print(error, file=sys.stderr) fail_to_start('Config validation failed', errors=errors) sys.exit(1) diff --git a/git-changelog b/git-changelog index ff4ffea8..f6141e4c 100755 --- a/git-changelog +++ b/git-changelog @@ -20,6 +20,8 @@ # Author: David Cantrell # Author: Brian C. Lane +from __future__ import print_function + import subprocess import textwrap from argparse import ArgumentParser @@ -93,7 +95,7 @@ def main(): args = parser.parse_args() cl = ChangeLog(args.name, args.version) - print cl.formatLog() + print(cl.formatLog()) if __name__ == "__main__": main() diff --git a/pungi/checks.py b/pungi/checks.py index dedc1872..d75929f0 100644 --- a/pungi/checks.py +++ b/pungi/checks.py @@ -35,6 +35,8 @@ When a new config option is added, the schema must be updated (see the ``CONFIG_DEPS`` mapping. """ +from __future__ import print_function + import contextlib import os.path import platform @@ -63,9 +65,8 @@ def is_isohybrid_needed(conf): if runroot and not _will_productimg_run(conf): return False if platform.machine() not in ('x86_64', 'i686', 'i386'): - msg = ('Not checking for /usr/bin/isohybrid due to current architecture. ' - 'Expect failures in productimg phase.') - print msg + print('Not checking for /usr/bin/isohybrid due to current architecture. ' + 'Expect failures in productimg phase.') return False return True diff --git a/pungi/profiler.py b/pungi/profiler.py index ec60e735..b1eb7c54 100644 --- a/pungi/profiler.py +++ b/pungi/profiler.py @@ -36,6 +36,8 @@ To print profiling data, run: Profiler.print_results() """ +from __future__ import print_function + import functools import time @@ -65,8 +67,8 @@ class Profiler(object): @classmethod def print_results(cls): - print "Profiling results:" + print("Profiling results:") results = cls._data.items() results.sort(lambda x, y: cmp(x[1]["time"], y[1]["time"]), reverse=True) for name, data in results: - print " %6.2f %5d %s" % (data["time"], data["calls"], name) + print(" %6.2f %5d %s" % (data["time"], data["calls"], name))