[projects/pld-builder.new] start migrating to python 3: use print function

baggins baggins at pld-linux.org
Sat Oct 17 23:37:38 CEST 2020


commit fe8cf8f9c00fb48f9c64df07445fe873be64cd46
Author: Jan Rękorajski <baggins at pld-linux.org>
Date:   Sat Oct 17 23:37:00 2020 +0200

    start migrating to python 3: use print function

 PLD_Builder/get_br.py             |  4 +++-
 PLD_Builder/rpm_builder.py        | 10 ++++++----
 client/rebuild-kernel-packages.py | 20 +++++++++++---------
 3 files changed, 20 insertions(+), 14 deletions(-)
---
diff --git a/PLD_Builder/get_br.py b/PLD_Builder/get_br.py
index 1f69394..2465866 100644
--- a/PLD_Builder/get_br.py
+++ b/PLD_Builder/get_br.py
@@ -1,5 +1,7 @@
 # vi: encoding=utf-8 ts=8 sts=4 sw=4 et
 
+from __future__ import print_function
+
 import re
 import string
 import xreadlines
@@ -100,4 +102,4 @@ def get_build_requires(spec, bconds_with, bconds_without):
                     msg("spec error (%s): %s\n" % (spec, l))
 
     for x in build_req:
-        print x
+        print(x)
diff --git a/PLD_Builder/rpm_builder.py b/PLD_Builder/rpm_builder.py
index 23f9492..7b5230b 100644
--- a/PLD_Builder/rpm_builder.py
+++ b/PLD_Builder/rpm_builder.py
@@ -1,5 +1,7 @@
 # vi: encoding=utf-8 ts=8 sts=4 sw=4 et
 
+from __future__ import print_function
+
 import sys
 import os
 import atexit
@@ -115,13 +117,13 @@ def fetch_src(r, b):
                 continue
             else:
                 try:
-                    print "error.errno: %s" % str(error.errno)
+                    print("error.errno: %s" % str(error.errno))
                 except Exception, e:
-                    print "error.errno: exception %s" % e
+                    print("error.errno: exception %s" % e)
                 try:
-                    print "error.reason %s" % str(error.reason)
+                    print("error.reason %s" % str(error.reason))
                 except Exception, e:
-                    print "error.reason exception %s" % e
+                    print("error.reason exception %s" % e)
                 raise
 
     o = chroot.popen("cat > %s" % b.src_rpm, mode = "w")
diff --git a/client/rebuild-kernel-packages.py b/client/rebuild-kernel-packages.py
index 652d4cd..2f5f247 100755
--- a/client/rebuild-kernel-packages.py
+++ b/client/rebuild-kernel-packages.py
@@ -1,5 +1,7 @@
 #!/usr/bin/python
 
+from __future__ import print_function
+
 import argparse
 import collections
 import os
@@ -55,14 +57,14 @@ def run_command(command, verbose=False, quiet=True):
     gitproc.wait()
     out = gitproc.stdout.read().strip("\n'")
     if verbose:
-        print ' '.join(command)
+        print(' '.join(command))
     if not quiet:
-        print out
+        print(out)
     if gitproc.returncode != 0:
         if quiet:
-            print out
-        print '\nError running command: \n'
-        print ' '.join(command)
+            print(out)
+        print('\nError running command: \n')
+        print(' '.join(command))
         return (False, None)
     return (True, out)
 
@@ -100,7 +102,7 @@ def fetch_package(name, spec, branch, verbose=False):
         rev_branch = run_command(["/usr/bin/git", "-C", gitdir, "rev-parse", branch], verbose=verbose)
         rev_head = run_command(["/usr/bin/git", "-C", gitdir, "rev-parse", "HEAD"], verbose=verbose)
         if rev_branch[1] != rev_head[1]:
-            print "Error: cannot checkout " + name
+            print("Error: cannot checkout " + name)
             return None
         run_command(["/usr/bin/git", "-C", gitdir, "merge", "--ff-only", "@{upstream}"], verbose=verbose)
 
@@ -186,7 +188,7 @@ def main():
         run_command(shlex.split(command), verbose=args.verbose, quiet=False)
         raw_input('\nPress Enter after src builder updates kernel packages...')
 
-    print '\nCurrent kernels versions:'
+    print('\nCurrent kernels versions:')
     all_kernels = set()
     for kernel_list in packages.values():
         all_kernels.update(kernel_list)
@@ -196,7 +198,7 @@ def main():
         branch = 'master'
         if kernel != 'head':
             branch = 'LINUX_%s' % kernel.replace('.','_')
-        print '%s: %s' % (kernel, get_last_tag('kernel', 'kernel.spec', branch, dist=args.dist, kernel=kernel, verbose=args.verbose))
+        print('%s: %s' % (kernel, get_last_tag('kernel', 'kernel.spec', branch, dist=args.dist, kernel=kernel, verbose=args.verbose)))
 
     for pkg, kernels in packages.iteritems():
         try:
@@ -216,7 +218,7 @@ def main():
             if not args.head:
               tag = get_last_tag(name, spec, branch, dist=args.dist, verbose=args.verbose)
               if not tag:
-                  print "Failed getching last autotag for %s!" % pkg
+                  print("Failed getching last autotag for %s!" % pkg)
                   continue
               spec = '%s:%s' % (spec, tag)
             command = ("%s -nd %s -d %s --define 'build_kernels %s' --without userspace %s" %
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/pld-builder.new.git/commitdiff/fe8cf8f9c00fb48f9c64df07445fe873be64cd46



More information about the pld-cvs-commit mailing list