Patchwork [05/15] classes/lib: Update to use print as a function call

login
register
mail settings
Submitter Richard Purdie
Date May 7, 2013, 12:55 p.m.
Message ID <1367931368-21504-5-git-send-email-richard.purdie@linuxfoundation.org>
Download mbox | patch
Permalink /patch/49461/
State New
Headers show

Comments

Richard Purdie - May 7, 2013, 12:55 p.m.
In python 3 print is a function call. In some cases bb.note is a more
appropriate call to make.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/sanity.bbclass |    7 ++++---
 meta/classes/sstate.bbclass |    6 +++---
 meta/lib/oe/path.py         |    2 +-
 3 files changed, 8 insertions(+), 7 deletions(-)
Martin Jansa - May 7, 2013, 3:40 p.m.
On Tue, May 07, 2013 at 01:55:57PM +0100, Richard Purdie wrote:
> In python 3 print is a function call. In some cases bb.note is a more
> appropriate call to make.
> 
> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> ---
>  meta/classes/sanity.bbclass |    7 ++++---
>  meta/classes/sstate.bbclass |    6 +++---
>  meta/lib/oe/path.py         |    2 +-
>  3 files changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass
> index 766e97e..d4a8f5e 100644
> --- a/meta/classes/sanity.bbclass
> +++ b/meta/classes/sanity.bbclass
> @@ -367,15 +367,16 @@ def check_sanity(sanity_data):
>      try:
>          from distutils.version import LooseVersion
>      except ImportError:
> -        def LooseVersion(v): print "WARNING: sanity.bbclass can't compare versions without python-distutils"; return 1
> -    import commands

^ was removing "import commands" intentional? maybe it just belongs to
different patch in this series

> +        def LooseVersion(v):
> +            print("WARNING: sanity.bbclass can't compare versions without python-distutils")
> +            return 1
>

Patch

diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass
index 766e97e..d4a8f5e 100644
--- a/meta/classes/sanity.bbclass
+++ b/meta/classes/sanity.bbclass
@@ -367,15 +367,16 @@  def check_sanity(sanity_data):
     try:
         from distutils.version import LooseVersion
     except ImportError:
-        def LooseVersion(v): print "WARNING: sanity.bbclass can't compare versions without python-distutils"; return 1
-    import commands
+        def LooseVersion(v):
+            print("WARNING: sanity.bbclass can't compare versions without python-distutils")
+            return 1
 
     # Check the bitbake version meets minimum requirements
     minversion = sanity_data.getVar('BB_MIN_VERSION', True)
     if not minversion:
         # Hack: BB_MIN_VERSION hasn't been parsed yet so return 
         # and wait for the next call
-        print "Foo %s" % minversion
+        print("Foo %s" % minversion)
         return
 
     if 0 == os.getuid():
diff --git a/meta/classes/sstate.bbclass b/meta/classes/sstate.bbclass
index 77ec402..9a76a6b 100644
--- a/meta/classes/sstate.bbclass
+++ b/meta/classes/sstate.bbclass
@@ -261,7 +261,7 @@  def sstate_installpkg(ss, d):
         # Add sstateinst to each filename in fixmepath, use xargs to efficiently call sed
         sstate_hardcode_cmd = "sed -e 's:^:%s:g' %s | xargs %s" % (sstateinst, fixmefn, sstate_sed_cmd)
 
-        print "Replacing fixme paths in sstate package: %s" % (sstate_hardcode_cmd)
+        bb.note("Replacing fixme paths in sstate package: %s" % (sstate_hardcode_cmd))
         subprocess.call(sstate_hardcode_cmd, shell=True)
 
         # Need to remove this or we'd copy it into the target directory and may 
@@ -408,14 +408,14 @@  def sstate_hardcode_path(d):
     # This has the side effect of making sure the vfs cache is hot
     sstate_hardcode_cmd = "%s | xargs %s | %s | xargs %s %s" % (sstate_scan_cmd, sstate_grep_cmd, sstate_filelist_cmd, xargs_no_empty_run_cmd, sstate_sed_cmd)
 
-    print "Removing hardcoded paths from sstate package: '%s'" % (sstate_hardcode_cmd)
+    bb.note("Removing hardcoded paths from sstate package: '%s'" % (sstate_hardcode_cmd))
     subprocess.call(sstate_hardcode_cmd, shell=True)
 
         # If the fixmefn is empty, remove it..
     if os.stat(fixmefn).st_size == 0:
         os.remove(fixmefn)
     else:
-        print "Replacing absolute paths in fixmepath file: '%s'" % (sstate_filelist_relative_cmd)
+        bb.note("Replacing absolute paths in fixmepath file: '%s'" % (sstate_filelist_relative_cmd))
         subprocess.call(sstate_filelist_relative_cmd, shell=True)
 
 def sstate_package(ss, d):
diff --git a/meta/lib/oe/path.py b/meta/lib/oe/path.py
index d8eb802..da044ba 100644
--- a/meta/lib/oe/path.py
+++ b/meta/lib/oe/path.py
@@ -55,7 +55,7 @@  def make_relative_symlink(path):
         depth += 1
 
     if not ancestor:
-        print "make_relative_symlink() Error: unable to find the common ancestor of %s and its target" % path
+        print("make_relative_symlink() Error: unable to find the common ancestor of %s and its target" % path)
         return
 
     base = link.partition(ancestor)[2].strip('/')