Use Python 3 print function
This is updated in all files for consistency, even the modules that will never be ported to Py 3 completely due to dependency on Yum. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
c14c28a157
commit
ec39514fba
30
bin/pungi
30
bin/pungi
@ -11,6 +11,8 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, see <https://gnu.org/licenses/>.
|
# along with this program; if not, see <https://gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import selinux
|
import selinux
|
||||||
import sys
|
import sys
|
||||||
@ -38,18 +40,18 @@ def main():
|
|||||||
|
|
||||||
# You must be this high to ride if you're going to do root tasks
|
# 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):
|
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
|
return 1
|
||||||
|
|
||||||
if opts.do_all or opts.do_buildinstall:
|
if opts.do_all or opts.do_buildinstall:
|
||||||
try:
|
try:
|
||||||
enforcing = selinux.security_getenforce()
|
enforcing = selinux.security_getenforce()
|
||||||
except:
|
except:
|
||||||
print >> sys.stdout, "INFO: selinux disabled"
|
print("INFO: selinux disabled")
|
||||||
enforcing = False
|
enforcing = False
|
||||||
if enforcing:
|
if enforcing:
|
||||||
print >> sys.stdout, "WARNING: SELinux is enforcing. This may lead to a compose with selinux disabled."
|
print("WARNING: SELinux is enforcing. This may lead to a compose with selinux disabled.")
|
||||||
print >> sys.stdout, "Consider running with setenforce 0."
|
print("Consider running with setenforce 0.")
|
||||||
|
|
||||||
# Set up the kickstart parser and pass in the kickstart file we were handed
|
# Set up the kickstart parser and pass in the kickstart file we were handed
|
||||||
ksparser = pungi.ks.get_ksparser(ks_path=opts.config)
|
ksparser = pungi.ks.get_ksparser(ks_path=opts.config)
|
||||||
@ -70,19 +72,21 @@ def main():
|
|||||||
try:
|
try:
|
||||||
os.makedirs(config.get('pungi', 'destdir'))
|
os.makedirs(config.get('pungi', 'destdir'))
|
||||||
except OSError:
|
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)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
print >> sys.stdout, "Warning: Reusing existing destination directory."
|
print("Warning: Reusing existing destination directory.")
|
||||||
|
|
||||||
if not os.path.exists(config.get('pungi', 'workdirbase')):
|
if not os.path.exists(config.get('pungi', 'workdirbase')):
|
||||||
try:
|
try:
|
||||||
os.makedirs(config.get('pungi', 'workdirbase'))
|
os.makedirs(config.get('pungi', 'workdirbase'))
|
||||||
except OSError:
|
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)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
print >> sys.stdout, "Warning: Reusing existing working base directory."
|
print("Warning: Reusing existing working base directory.")
|
||||||
|
|
||||||
cachedir = config.get('pungi', 'cachedir')
|
cachedir = config.get('pungi', 'cachedir')
|
||||||
|
|
||||||
@ -90,7 +94,7 @@ def main():
|
|||||||
try:
|
try:
|
||||||
os.makedirs(cachedir)
|
os.makedirs(cachedir)
|
||||||
except OSError:
|
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)
|
sys.exit(1)
|
||||||
|
|
||||||
# Set debuginfo flag
|
# Set debuginfo flag
|
||||||
@ -172,11 +176,11 @@ def main():
|
|||||||
else:
|
else:
|
||||||
mypungi.downloadSRPMs()
|
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:
|
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:
|
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...)
|
# Furthermore (but without the yumlock...)
|
||||||
if not opts.sourceisos:
|
if not opts.sourceisos:
|
||||||
@ -202,7 +206,7 @@ def main():
|
|||||||
if opts.do_all or opts.do_createiso:
|
if opts.do_all or opts.do_createiso:
|
||||||
mypungi.doCreateIsos()
|
mypungi.doCreateIsos()
|
||||||
|
|
||||||
print "All done!"
|
print("All done!")
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from argparse import ArgumentParser, Action
|
from argparse import ArgumentParser, Action
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import argparse
|
import argparse
|
||||||
@ -159,13 +160,13 @@ def _get_url(pkg):
|
|||||||
|
|
||||||
def print_rpms(gather_obj):
|
def print_rpms(gather_obj):
|
||||||
for pkg in sorted(gather_obj.result_binary_packages):
|
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):
|
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):
|
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__":
|
if __name__ == "__main__":
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@ -213,10 +214,10 @@ def main():
|
|||||||
pungi.checks.check_umask(logger)
|
pungi.checks.check_umask(logger)
|
||||||
errors, warnings = pungi.checks.validate(conf)
|
errors, warnings = pungi.checks.validate(conf)
|
||||||
for warning in warnings:
|
for warning in warnings:
|
||||||
print >>sys.stderr, warning
|
print(warning, file=sys.stderr)
|
||||||
if errors:
|
if errors:
|
||||||
for error in errors:
|
for error in errors:
|
||||||
print >>sys.stderr, error
|
print(error, file=sys.stderr)
|
||||||
fail_to_start('Config validation failed', errors=errors)
|
fail_to_start('Config validation failed', errors=errors)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
# Author: David Cantrell <dcantrell@redhat.com>
|
# Author: David Cantrell <dcantrell@redhat.com>
|
||||||
# Author: Brian C. Lane <bcl@redhat.com>
|
# Author: Brian C. Lane <bcl@redhat.com>
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import textwrap
|
import textwrap
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
@ -93,7 +95,7 @@ def main():
|
|||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
cl = ChangeLog(args.name, args.version)
|
cl = ChangeLog(args.name, args.version)
|
||||||
print cl.formatLog()
|
print(cl.formatLog())
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
@ -35,6 +35,8 @@ When a new config option is added, the schema must be updated (see the
|
|||||||
``CONFIG_DEPS`` mapping.
|
``CONFIG_DEPS`` mapping.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import contextlib
|
import contextlib
|
||||||
import os.path
|
import os.path
|
||||||
import platform
|
import platform
|
||||||
@ -63,9 +65,8 @@ def is_isohybrid_needed(conf):
|
|||||||
if runroot and not _will_productimg_run(conf):
|
if runroot and not _will_productimg_run(conf):
|
||||||
return False
|
return False
|
||||||
if platform.machine() not in ('x86_64', 'i686', 'i386'):
|
if platform.machine() not in ('x86_64', 'i686', 'i386'):
|
||||||
msg = ('Not checking for /usr/bin/isohybrid due to current architecture. '
|
print('Not checking for /usr/bin/isohybrid due to current architecture. '
|
||||||
'Expect failures in productimg phase.')
|
'Expect failures in productimg phase.')
|
||||||
print msg
|
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -36,6 +36,8 @@ To print profiling data, run:
|
|||||||
Profiler.print_results()
|
Profiler.print_results()
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
|
|
||||||
import functools
|
import functools
|
||||||
import time
|
import time
|
||||||
@ -65,8 +67,8 @@ class Profiler(object):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def print_results(cls):
|
def print_results(cls):
|
||||||
print "Profiling results:"
|
print("Profiling results:")
|
||||||
results = cls._data.items()
|
results = cls._data.items()
|
||||||
results.sort(lambda x, y: cmp(x[1]["time"], y[1]["time"]), reverse=True)
|
results.sort(lambda x, y: cmp(x[1]["time"], y[1]["time"]), reverse=True)
|
||||||
for name, data in results:
|
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))
|
||||||
|
Loading…
Reference in New Issue
Block a user