Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH 01/15] classes/recipes/lib: Fix various python whitespace issues
@ 2013-05-07 12:55 Richard Purdie
  2013-05-07 12:55 ` [PATCH 02/15] core-image-minimal-initramfs: Remove odd quote characters Richard Purdie
                   ` (14 more replies)
  0 siblings, 15 replies; 20+ messages in thread
From: Richard Purdie @ 2013-05-07 12:55 UTC (permalink / raw)
  To: openembedded-core

There are some left over tab characters in the python functions. This
removes them and resolves python 3 errors.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/insane.bbclass                        |   26 ++++++++++----------
 meta/classes/multilib_global.bbclass               |    2 +-
 meta/lib/oe/sstatesig.py                           |   20 +++++++--------
 .../meta/external-sourcery-toolchain.bb            |    2 +-
 meta/recipes-devtools/cmake/cmake_2.8.10.2.bb      |    4 +--
 .../linux-libc-headers/linux-libc-headers.inc      |    4 +--
 meta/recipes-kernel/linux/linux-dtb.inc            |    8 +++---
 7 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass
index 336beaa..271e9ff 100644
--- a/meta/classes/insane.bbclass
+++ b/meta/classes/insane.bbclass
@@ -173,10 +173,10 @@ def package_qa_check_rpath(file,name, d, elf, messages):
     import re
     rpath_re = re.compile("\s+RPATH\s+(.*)")
     for line in phdrs.split("\n"):
-    	m = rpath_re.match(line)
-	if m:
-	    rpath = m.group(1)
-	    for dir in bad_dirs:
+        m = rpath_re.match(line)
+        if m:
+            rpath = m.group(1)
+            for dir in bad_dirs:
                 if dir in rpath:
                     messages.append("package %s contains bad RPATH %s in file %s" % (name, rpath, file))
 
@@ -202,13 +202,13 @@ def package_qa_check_useless_rpaths(file, name, d, elf, messages):
     import re
     rpath_re = re.compile("\s+RPATH\s+(.*)")
     for line in phdrs.split("\n"):
-    	m = rpath_re.match(line)
-	if m:
-	   rpath = m.group(1)
-	   if rpath_eq(rpath, libdir) or rpath_eq(rpath, base_libdir):
-	      # The dynamic linker searches both these places anyway.  There is no point in
-	      # looking there again.
-	      messages.append("%s: %s contains probably-redundant RPATH %s" % (name, package_qa_clean_path(file, d), rpath))
+        m = rpath_re.match(line)
+        if m:
+           rpath = m.group(1)
+           if rpath_eq(rpath, libdir) or rpath_eq(rpath, base_libdir):
+              # The dynamic linker searches both these places anyway.  There is no point in
+              # looking there again.
+              messages.append("%s: %s contains probably-redundant RPATH %s" % (name, package_qa_clean_path(file, d), rpath))
 
 QAPATHTEST[dev-so] = "package_qa_check_dev"
 def package_qa_check_dev(path, name, d, elf, messages):
@@ -463,7 +463,7 @@ def package_qa_textrel(path, name, d, elf, messages):
     textrel_re = re.compile("\s+TEXTREL\s+")
     for line in phdrs.split("\n"):
         if textrel_re.match(line):
-	   sane = False
+            sane = False
 
     if not sane:
         messages.append("ELF binary '%s' has relocations in .text" % path)
@@ -498,7 +498,7 @@ def package_qa_hash_style(path, name, d, elf, messages):
         if "GNU_HASH" in line:
             sane = True
         if "[mips32]" in line or "[mips64]" in line:
-	    sane = True
+             sane = True
 
     if has_syms and not sane:
         messages.append("No GNU_HASH in the elf binary: '%s'" % path)
diff --git a/meta/classes/multilib_global.bbclass b/meta/classes/multilib_global.bbclass
index 529e82a..40ae006 100644
--- a/meta/classes/multilib_global.bbclass
+++ b/meta/classes/multilib_global.bbclass
@@ -5,7 +5,7 @@ python multilib_virtclass_handler_global () {
     if isinstance(e, bb.event.RecipePreFinalise):
         for v in e.data.getVar("MULTILIB_VARIANTS", True).split():
             if e.data.getVar("TARGET_VENDOR_virtclass-multilib-" + v, False) is None:
-	       e.data.setVar("TARGET_VENDOR_virtclass-multilib-" + v, e.data.getVar("TARGET_VENDOR", False) + "ml" + v)
+               e.data.setVar("TARGET_VENDOR_virtclass-multilib-" + v, e.data.getVar("TARGET_VENDOR", False) + "ml" + v)
 
     variant = e.data.getVar("BBEXTENDVARIANT", True)
 
diff --git a/meta/lib/oe/sstatesig.py b/meta/lib/oe/sstatesig.py
index 79a410e..852fb7e 100644
--- a/meta/lib/oe/sstatesig.py
+++ b/meta/lib/oe/sstatesig.py
@@ -108,16 +108,16 @@ def find_siginfo(pn, taskname, taskhashlist, d):
     foundall = False
     import glob
     for fullpath in glob.glob(filespec):
-	match = False
-	if taskhashlist:
-	    for taskhash in taskhashlist:
-		if fullpath.endswith('.%s' % taskhash):
-		    hashfiles[taskhash] = fullpath
-		    if len(hashfiles) == len(taskhashlist):
-			foundall = True
-			break
-	else:
-	    filedates[fullpath] = os.stat(fullpath).st_mtime
+        match = False
+        if taskhashlist:
+            for taskhash in taskhashlist:
+                if fullpath.endswith('.%s' % taskhash):
+                    hashfiles[taskhash] = fullpath
+                    if len(hashfiles) == len(taskhashlist):
+                        foundall = True
+                        break
+        else:
+            filedates[fullpath] = os.stat(fullpath).st_mtime
 
     if len(filedates) < 2 and not foundall:
         # That didn't work, look in sstate-cache
diff --git a/meta/recipes-core/meta/external-sourcery-toolchain.bb b/meta/recipes-core/meta/external-sourcery-toolchain.bb
index 24c7ce8..3218754 100644
--- a/meta/recipes-core/meta/external-sourcery-toolchain.bb
+++ b/meta/recipes-core/meta/external-sourcery-toolchain.bb
@@ -142,6 +142,6 @@ CSL_VER_MAIN ??= ""
 
 python () {
     if not d.getVar("CSL_VER_MAIN"):
-	raise bb.parse.SkipPackage("External CSL toolchain not configured (CSL_VER_MAIN not set).")
+        	raise bb.parse.SkipPackage("External CSL toolchain not configured (CSL_VER_MAIN not set).")
 }
 
diff --git a/meta/recipes-devtools/cmake/cmake_2.8.10.2.bb b/meta/recipes-devtools/cmake/cmake_2.8.10.2.bb
index ce398dd..65f75b4 100644
--- a/meta/recipes-devtools/cmake/cmake_2.8.10.2.bb
+++ b/meta/recipes-devtools/cmake/cmake_2.8.10.2.bb
@@ -17,11 +17,11 @@ python () {
     docdir=d.getVar("docdir", True)
 
     if not docdir.startswith(prefix):
-	raise bb.build.FuncFailed('docdir must contain prefix as its prefix')
+        raise bb.build.FuncFailed('docdir must contain prefix as its prefix')
 
     docdir_stripped = docdir[len(prefix):]
     if len(docdir_stripped) > 0 and docdir_stripped[0] == '/':
-	docdir_stripped = docdir_stripped[1:]
+        docdir_stripped = docdir_stripped[1:]
 
     d.setVar("docdir_stripped", docdir_stripped)
 }
diff --git a/meta/recipes-kernel/linux-libc-headers/linux-libc-headers.inc b/meta/recipes-kernel/linux-libc-headers/linux-libc-headers.inc
index 962ca75..96fe2ff 100644
--- a/meta/recipes-kernel/linux-libc-headers/linux-libc-headers.inc
+++ b/meta/recipes-kernel/linux-libc-headers/linux-libc-headers.inc
@@ -7,9 +7,9 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=d7810fab7487fb0aad327b76f1be7cd7"
 python __anonymous () {
     major = d.getVar("PV",True).split('.')[0]
     if major == "3":
-	d.setVar("HEADER_FETCH_VER", "3.0")
+        d.setVar("HEADER_FETCH_VER", "3.0")
     else:
-	d.setVar("HEADER_FETCH_VER", "2.6")
+        d.setVar("HEADER_FETCH_VER", "2.6")
 }
 
 inherit kernel-arch
diff --git a/meta/recipes-kernel/linux/linux-dtb.inc b/meta/recipes-kernel/linux/linux-dtb.inc
index 58b93a1..7747718 100644
--- a/meta/recipes-kernel/linux/linux-dtb.inc
+++ b/meta/recipes-kernel/linux/linux-dtb.inc
@@ -5,10 +5,10 @@ KERNEL_DEVICETREE_FLAGS ?= "-R 8 -p 0x3000"
 python __anonymous () {
     devicetree = d.getVar("KERNEL_DEVICETREE", True) or ''
     if devicetree:
-	depends = d.getVar("DEPENDS", True)
-	d.setVar("DEPENDS", "%s dtc-native" % depends)
-	packages = d.getVar("PACKAGES", True)
-	d.setVar("PACKAGES", "%s kernel-devicetree" % packages)
+        depends = d.getVar("DEPENDS", True)
+        d.setVar("DEPENDS", "%s dtc-native" % depends)
+        packages = d.getVar("PACKAGES", True)
+        d.setVar("PACKAGES", "%s kernel-devicetree" % packages)
 }
 
 do_install_append() {
-- 
1.7.10.4




^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 02/15] core-image-minimal-initramfs: Remove odd quote characters
  2013-05-07 12:55 [PATCH 01/15] classes/recipes/lib: Fix various python whitespace issues Richard Purdie
@ 2013-05-07 12:55 ` Richard Purdie
  2013-05-07 15:38   ` Martin Jansa
  2013-05-07 12:55 ` [PATCH 03/15] clases/lib: Use modern exception syntax Richard Purdie
                   ` (13 subsequent siblings)
  14 siblings, 1 reply; 20+ messages in thread
From: Richard Purdie @ 2013-05-07 12:55 UTC (permalink / raw)
  To: openembedded-core

The quote characters present trigger pyhton 3 characters type warnings,
we don't need them so replace them with normal quote characters.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/recipes-core/images/core-image-minimal-initramfs.bb |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/recipes-core/images/core-image-minimal-initramfs.bb b/meta/recipes-core/images/core-image-minimal-initramfs.bb
index 6de24b3..46a9dc4 100644
--- a/meta/recipes-core/images/core-image-minimal-initramfs.bb
+++ b/meta/recipes-core/images/core-image-minimal-initramfs.bb
@@ -1,7 +1,7 @@
 # Simple initramfs image. Mostly used for live images.
 DESCRIPTION = "Small image capable of booting a device. The kernel includes \
 the Minimal RAM-based Initial Root Filesystem (initramfs), which finds the \
-first “init” program more efficiently."
+first 'init' program more efficiently."
 
 IMAGE_INSTALL = "initramfs-live-boot initramfs-live-install initramfs-live-install-efi busybox udev base-passwd"
 
-- 
1.7.10.4




^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 03/15] clases/lib: Use modern exception syntax
  2013-05-07 12:55 [PATCH 01/15] classes/recipes/lib: Fix various python whitespace issues Richard Purdie
  2013-05-07 12:55 ` [PATCH 02/15] core-image-minimal-initramfs: Remove odd quote characters Richard Purdie
@ 2013-05-07 12:55 ` Richard Purdie
  2013-05-07 12:55 ` [PATCH 04/15] classes: Use modern exception raising syntax Richard Purdie
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Richard Purdie @ 2013-05-07 12:55 UTC (permalink / raw)
  To: openembedded-core

Update older code to use modern exception handling syntax which
is the form accepted by python 3.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/base.bbclass   |    4 ++--
 meta/classes/sanity.bbclass |    6 ++++--
 meta/lib/oe/cachedpath.py   |    4 ++--
 meta/lib/oe/patch.py        |    2 +-
 meta/lib/oe/path.py         |    6 +++---
 meta/lib/oe/utils.py        |    2 +-
 6 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index 641316d..196acdb 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -108,7 +108,7 @@ python base_do_fetch() {
     try:
         fetcher = bb.fetch2.Fetch(src_uri, localdata)
         fetcher.download()
-    except bb.fetch2.BBFetchException, e:
+    except bb.fetch2.BBFetchException as e:
         raise bb.build.FuncFailed(e)
 }
 
@@ -128,7 +128,7 @@ python base_do_unpack() {
     try:
         fetcher = bb.fetch2.Fetch(src_uri, localdata)
         fetcher.unpack(rootdir)
-    except bb.fetch2.BBFetchException, e:
+    except bb.fetch2.BBFetchException as e:
         raise bb.build.FuncFailed(e)
 }
 
diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass
index ac2314f..766e97e 100644
--- a/meta/classes/sanity.bbclass
+++ b/meta/classes/sanity.bbclass
@@ -235,12 +235,14 @@ def check_create_long_filename(filepath, pathname):
         f = file(testfile, "w")
         f.close()
         os.remove(testfile)
-    except IOError as (errno, strerror):
+    except IOError as e:
+        errno, strerror = e.args
         if errno == 36: # ENAMETOOLONG
             return "Failed to create a file with a long name in %s. Please use a filesystem that does not unreasonably limit filename length.\n" % pathname
         else:
             return "Failed to create a file in %s: %s.\n" % (pathname, strerror)
-    except OSError as (errno, strerror):
+    except OSError as e:
+        errno, strerror = e.args
         return "Failed to create %s directory in which to run long name sanity check: %s.\n" % (pathname, strerror)
     return ""
 
diff --git a/meta/lib/oe/cachedpath.py b/meta/lib/oe/cachedpath.py
index e350c8a..c7860ef 100644
--- a/meta/lib/oe/cachedpath.py
+++ b/meta/lib/oe/cachedpath.py
@@ -125,7 +125,7 @@ class CachedPath(object):
             # Note that listdir and error are globals in this module due
             # to earlier import-*.
             names = os.listdir(top)
-        except error, err:
+        except error as err:
             if onerror is not None:
                 onerror(err)
             return
@@ -221,7 +221,7 @@ class CachedPath(object):
                 file = self.__realpath_rel(root, file[(len(root) - 1):], root, loop_cnt, assume_dir)
             else:
                 file = self.__realpath(file, root, loop_cnt, assume_dir)[0]
-        except OSError, e:
+        except OSError as e:
             if e.errno == errno.ELOOP:
                 # make ELOOP more readable; without catching it, there will
                 # be printed a backtrace with 100s of OSError exceptions
diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py
index 7ab74fa..cbc5cd9 100644
--- a/meta/lib/oe/patch.py
+++ b/meta/lib/oe/patch.py
@@ -392,7 +392,7 @@ class UserResolver(Resolver):
         os.chdir(self.patchset.dir)
         try:
             self.patchset.Push(False)
-        except CmdError, v:
+        except CmdError as v:
             # Patch application failed
             patchcmd = self.patchset.Push(True, False, False)
 
diff --git a/meta/lib/oe/path.py b/meta/lib/oe/path.py
index 76a6ed8..d8eb802 100644
--- a/meta/lib/oe/path.py
+++ b/meta/lib/oe/path.py
@@ -107,7 +107,7 @@ def remove(path, recurse=True):
     for name in glob.glob(path):
         try:
             os.unlink(name)
-        except OSError, exc:
+        except OSError as exc:
             if recurse and exc.errno == errno.EISDIR:
                 shutil.rmtree(name)
             elif exc.errno != errno.ENOENT:
@@ -119,7 +119,7 @@ def symlink(source, destination, force=False):
         if force:
             remove(destination)
         os.symlink(source, destination)
-    except OSError, e:
+    except OSError as e:
         if e.errno != errno.EEXIST or os.readlink(destination) != source:
             raise
 
@@ -247,7 +247,7 @@ def realpath(file, root, use_physdir = True, loop_cnt = 100, assume_dir = False)
             file = __realpath_rel(root, file[(len(root) - 1):], root, loop_cnt, assume_dir)
         else:
             file = __realpath(file, root, loop_cnt, assume_dir)[0]
-    except OSError, e:
+    except OSError as e:
         if e.errno == errno.ELOOP:
             # make ELOOP more readable; without catching it, there will
             # be printed a backtrace with 100s of OSError exceptions
diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
index acd3969..ed94096 100644
--- a/meta/lib/oe/utils.py
+++ b/meta/lib/oe/utils.py
@@ -1,7 +1,7 @@
 def read_file(filename):
     try:
         f = file( filename, "r" )
-    except IOError, reason:
+    except IOError as reason:
         return "" # WARNING: can't raise an error now because of the new RDEPENDS handling. This is a bit ugly. :M:
     else:
         return f.read().strip()
-- 
1.7.10.4




^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 04/15] classes: Use modern exception raising syntax
  2013-05-07 12:55 [PATCH 01/15] classes/recipes/lib: Fix various python whitespace issues Richard Purdie
  2013-05-07 12:55 ` [PATCH 02/15] core-image-minimal-initramfs: Remove odd quote characters Richard Purdie
  2013-05-07 12:55 ` [PATCH 03/15] clases/lib: Use modern exception syntax Richard Purdie
@ 2013-05-07 12:55 ` Richard Purdie
  2013-05-07 12:55 ` [PATCH 05/15] classes/lib: Update to use print as a function call Richard Purdie
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Richard Purdie @ 2013-05-07 12:55 UTC (permalink / raw)
  To: openembedded-core

Modern expection rasing syntax is function call format, convert to this
to keep python 3 happy and model correct coding style in the core.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/gtk-immodules-cache.bbclass |    2 +-
 meta/classes/update-alternatives.bbclass |    4 ++--
 meta/classes/update-rc.d.bbclass         |    4 ++--
 meta/classes/useradd.bbclass             |    4 ++--
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/meta/classes/gtk-immodules-cache.bbclass b/meta/classes/gtk-immodules-cache.bbclass
index ed3069d..e11ed22 100644
--- a/meta/classes/gtk-immodules-cache.bbclass
+++ b/meta/classes/gtk-immodules-cache.bbclass
@@ -78,6 +78,6 @@ python __anonymous() {
         gtkimmodules_check = d.getVar('GTKIMMODULES_PACKAGES')
         if not gtkimmodules_check:
             bb_filename = d.getVar('FILE')
-            raise bb.build.FuncFailed, "\n\n\nERROR: %s inherits gtk-immodule-cache but doesn't set GTKIMMODULES_PACKAGE" % bb_filename
+            raise bb.build.FuncFailed("ERROR: %s inherits gtk-immodule-cache but doesn't set GTKIMMODULES_PACKAGE" % bb_filename)
 }
 
diff --git a/meta/classes/update-alternatives.bbclass b/meta/classes/update-alternatives.bbclass
index 45f4291..2cadaf7 100644
--- a/meta/classes/update-alternatives.bbclass
+++ b/meta/classes/update-alternatives.bbclass
@@ -128,9 +128,9 @@ def update_alternatives_after_parse(d):
         alt_path = d.getVar('ALTERNATIVE_PATH', True)
         alt_link = d.getVar('ALTERNATIVE_LINK', True) or ("%s/%s" % (d.getVar('bindir', True), alt_name))
         if alt_name == None:
-            raise bb.build.build.FuncFailed, "%s inherits update-alternatives but doesn't set ALTERNATIVE_NAME" % d.getVar('FILE')
+            raise bb.build.build.FuncFailed("%s inherits update-alternatives but doesn't set ALTERNATIVE_NAME" % d.getVar('FILE'))
         if alt_path == None:
-            raise bb.build.build.FuncFailed, "%s inherits update-alternatives but doesn't set ALTERNATIVE_PATH" % d.getVar('FILE')
+            raise bb.build.build.FuncFailed("%s inherits update-alternatives but doesn't set ALTERNATIVE_PATH" % d.getVar('FILE'))
 
         alternative = d.getVar('ALTERNATIVE_%s' % pn, True) or ""
         alternative += " " + alt_name
diff --git a/meta/classes/update-rc.d.bbclass b/meta/classes/update-rc.d.bbclass
index d8cc342..5588569 100644
--- a/meta/classes/update-rc.d.bbclass
+++ b/meta/classes/update-rc.d.bbclass
@@ -44,9 +44,9 @@ fi
 def update_rc_after_parse(d):
     if d.getVar('INITSCRIPT_PACKAGES') == None:
         if d.getVar('INITSCRIPT_NAME') == None:
-            raise bb.build.FuncFailed, "%s inherits update-rc.d but doesn't set INITSCRIPT_NAME" % d.getVar('FILE')
+            raise bb.build.FuncFailed("%s inherits update-rc.d but doesn't set INITSCRIPT_NAME" % d.getVar('FILE'))
         if d.getVar('INITSCRIPT_PARAMS') == None:
-            raise bb.build.FuncFailed, "%s inherits update-rc.d but doesn't set INITSCRIPT_PARAMS" % d.getVar('FILE')
+            raise bb.build.FuncFailed("%s inherits update-rc.d but doesn't set INITSCRIPT_PARAMS" % d.getVar('FILE'))
 
 python __anonymous() {
     update_rc_after_parse(d)
diff --git a/meta/classes/useradd.bbclass b/meta/classes/useradd.bbclass
index 0a4feba..52c0ba4 100644
--- a/meta/classes/useradd.bbclass
+++ b/meta/classes/useradd.bbclass
@@ -157,11 +157,11 @@ def update_useradd_after_parse(d):
     useradd_packages = d.getVar('USERADD_PACKAGES', True)
 
     if not useradd_packages:
-        raise bb.build.FuncFailed, "%s inherits useradd but doesn't set USERADD_PACKAGES" % d.getVar('FILE')
+        raise bb.build.FuncFailed("%s inherits useradd but doesn't set USERADD_PACKAGES" % d.getVar('FILE'))
 
     for pkg in useradd_packages.split():
         if not d.getVar('USERADD_PARAM_%s' % pkg, True) and not d.getVar('GROUPADD_PARAM_%s' % pkg, True):
-            raise bb.build.FuncFailed, "%s inherits useradd but doesn't set USERADD_PARAM or GROUPADD_PARAM for package %s" % (d.getVar('FILE'), pkg)
+            raise bb.build.FuncFailed("%s inherits useradd but doesn't set USERADD_PARAM or GROUPADD_PARAM for package %s" % (d.getVar('FILE'), pkg))
 
 python __anonymous() {
     update_useradd_after_parse(d)
-- 
1.7.10.4




^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 05/15] classes/lib: Update to use print as a function call
  2013-05-07 12:55 [PATCH 01/15] classes/recipes/lib: Fix various python whitespace issues Richard Purdie
                   ` (2 preceding siblings ...)
  2013-05-07 12:55 ` [PATCH 04/15] classes: Use modern exception raising syntax Richard Purdie
@ 2013-05-07 12:55 ` Richard Purdie
  2013-05-07 15:40   ` Martin Jansa
  2013-05-07 12:55 ` [PATCH 06/15] buildstats: Update to ensure files are closed Richard Purdie
                   ` (10 subsequent siblings)
  14 siblings, 1 reply; 20+ messages in thread
From: Richard Purdie @ 2013-05-07 12:55 UTC (permalink / raw)
  To: openembedded-core

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
+        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('/')
-- 
1.7.10.4




^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 06/15] buildstats: Update to ensure files are closed
  2013-05-07 12:55 [PATCH 01/15] classes/recipes/lib: Fix various python whitespace issues Richard Purdie
                   ` (3 preceding siblings ...)
  2013-05-07 12:55 ` [PATCH 05/15] classes/lib: Update to use print as a function call Richard Purdie
@ 2013-05-07 12:55 ` Richard Purdie
  2013-05-07 12:55 ` [PATCH 07/15] bin/bitbake: Ensure early errors are shown to the user Richard Purdie
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Richard Purdie @ 2013-05-07 12:55 UTC (permalink / raw)
  To: openembedded-core

python3 doesn't like files being left open. This updates the code style
to ensure file are closed.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/buildstats.bbclass |   31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/meta/classes/buildstats.bbclass b/meta/classes/buildstats.bbclass
index 6fd13a8..453c50b 100644
--- a/meta/classes/buildstats.bbclass
+++ b/meta/classes/buildstats.bbclass
@@ -12,12 +12,14 @@ DEVFILE = "${BUILDSTATS_BASE}/.device"
 ################################################################################
 
 def get_process_cputime(pid):
-    fields = open("/proc/%d/stat" % pid, "r").readline().rstrip().split()
+    with open("/proc/%d/stat" % pid, "r") as f:
+        fields = f.readline().rstrip().split()
     # 13: utime, 14: stime, 15: cutime, 16: cstime
     return sum(int(field) for field in fields[13:16])
 
 def get_cputime():
-    fields = open("/proc/stat", "r").readline().rstrip().split()[1:]
+    with open("/proc/stat", "r") as f:
+        fields = f.readline().rstrip().split()[1:]
     return sum(int(field) for field in fields)
 
 def set_bn(e):
@@ -26,14 +28,12 @@ def set_bn(e):
         os.remove(e.data.getVar('BNFILE', True))
     except:
         pass
-    file = open(e.data.getVar('BNFILE', True), "w")
-    file.write(os.path.join(bn, e.data.getVar('BUILDNAME', True)))
-    file.close()
+    with open(e.data.getVar('BNFILE', True), "w") as f:
+        f.write(os.path.join(bn, e.data.getVar('BUILDNAME', True)))
 
 def get_bn(e):
-    file = open(e.data.getVar('BNFILE', True))
-    bn = file.readline()
-    file.close()
+    with open(e.data.getVar('BNFILE', True)) as f:
+        bn = f.readline()
     return bn
 
 def set_device(e):
@@ -63,9 +63,10 @@ def set_device(e):
     ############################################################################
     rdev="NoLogicalDevice"
     try:
-        for line in open("/proc/diskstats", "r"):
-            if majordev == int(line.split()[0]) and minordev == int(line.split()[1]):
-                rdev=line.split()[2]
+        with open("/proc/diskstats", "r") as f:
+            for line in f:
+                if majordev == int(line.split()[0]) and minordev == int(line.split()[1]):
+                    rdev=line.split()[2]
     except:
         pass
     file = open(e.data.getVar('DEVFILE', True), "w")
@@ -85,9 +86,10 @@ def get_diskstats(dev):
     ############################################################################
     DSTAT_KEYS = ['ReadsComp', 'ReadsMerged', 'SectRead', 'TimeReads', 'WritesComp', 'SectWrite', 'TimeWrite', 'IOinProgress', 'TimeIO', 'WTimeIO']  
     try:
-        for x in open("/proc/diskstats", "r"):
-            if dev in x:
-                diskstats_val = x.rstrip().split()[4:]
+        with open("/proc/diskstats", "r") as f:
+            for x in f:
+                if dev in x:
+                    diskstats_val = x.rstrip().split()[4:]
     except IOError as e:
         return
     diskstats = dict(itertools.izip(DSTAT_KEYS, diskstats_val))
@@ -274,7 +276,6 @@ python run_buildstats () {
         file = open(build_status,"a")
         file.write(e.data.expand("Failed at: ${PF} at task: %s \n" % e.task))
         file.close()
-        
 }
 
 addhandler run_buildstats
-- 
1.7.10.4




^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 07/15] bin/bitbake: Ensure early errors are shown to the user
  2013-05-07 12:55 [PATCH 01/15] classes/recipes/lib: Fix various python whitespace issues Richard Purdie
                   ` (4 preceding siblings ...)
  2013-05-07 12:55 ` [PATCH 06/15] buildstats: Update to ensure files are closed Richard Purdie
@ 2013-05-07 12:55 ` Richard Purdie
  2013-05-13  1:31   ` Jonathan Liu
  2013-05-07 12:56 ` [PATCH 08/15] meta/lib/oe: Replace StandardError with Exception Richard Purdie
                   ` (8 subsequent siblings)
  14 siblings, 1 reply; 20+ messages in thread
From: Richard Purdie @ 2013-05-07 12:55 UTC (permalink / raw)
  To: openembedded-core

Currently if errors occur early in the init process, the errors may
not be shown to the user. This change ensures that if a failure does
occur, the messages are flushed from the queue and shown to the user.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 bitbake/bin/bitbake |   21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/bitbake/bin/bitbake b/bitbake/bin/bitbake
index 0e69207..e05ff5b 100755
--- a/bitbake/bin/bitbake
+++ b/bitbake/bin/bitbake
@@ -240,11 +240,22 @@ Default BBFILES are the .bb files in the current directory.""")
 
     idle = server.getServerIdleCB()
 
-    cooker = bb.cooker.BBCooker(configuration, idle, initialenv)
-    cooker.parseCommandLine()
-
-    server.addcooker(cooker)
-    server.saveConnectionDetails()
+    try:
+        cooker = bb.cooker.BBCooker(configuration, idle, initialenv)
+        cooker.parseCommandLine()
+
+        server.addcooker(cooker)
+        server.saveConnectionDetails()
+    except:
+        while True:
+            import queue
+            try:
+                event = server.event_queue.get(block=False)
+            except (queue.Empty, IOError):
+                break
+            if isinstance(event, logging.LogRecord):
+                logger.handle(event)
+        raise
     server.detach()
 
     # Should no longer need to ever reference cooker
-- 
1.7.10.4




^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 08/15] meta/lib/oe: Replace StandardError with Exception
  2013-05-07 12:55 [PATCH 01/15] classes/recipes/lib: Fix various python whitespace issues Richard Purdie
                   ` (5 preceding siblings ...)
  2013-05-07 12:55 ` [PATCH 07/15] bin/bitbake: Ensure early errors are shown to the user Richard Purdie
@ 2013-05-07 12:56 ` Richard Purdie
  2013-05-07 12:56 ` [PATCH 09/15] sanity.bbclass: Use open(), not file() Richard Purdie
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Richard Purdie @ 2013-05-07 12:56 UTC (permalink / raw)
  To: openembedded-core

StandardError is removed in python3, replace with Exception class instead.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/lib/oe/license.py  |    2 +-
 meta/lib/oe/terminal.py |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/meta/lib/oe/license.py b/meta/lib/oe/license.py
index 173e319..340da61 100644
--- a/meta/lib/oe/license.py
+++ b/meta/lib/oe/license.py
@@ -5,7 +5,7 @@ import ast
 import re
 from fnmatch import fnmatchcase as fnmatch
 
-class LicenseError(StandardError):
+class LicenseError(Exception):
     pass
 
 class LicenseSyntaxError(LicenseError):
diff --git a/meta/lib/oe/terminal.py b/meta/lib/oe/terminal.py
index aecf4e8..28470e3 100644
--- a/meta/lib/oe/terminal.py
+++ b/meta/lib/oe/terminal.py
@@ -6,10 +6,10 @@ from bb.process import Popen, ExecutionError
 logger = logging.getLogger('BitBake.OE.Terminal')
 
 
-class UnsupportedTerminal(StandardError):
+class UnsupportedTerminal(Exception):
     pass
 
-class NoSupportedTerminals(StandardError):
+class NoSupportedTerminals(Exception):
     pass
 
 
-- 
1.7.10.4




^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 09/15] sanity.bbclass: Use open(), not file()
  2013-05-07 12:55 [PATCH 01/15] classes/recipes/lib: Fix various python whitespace issues Richard Purdie
                   ` (6 preceding siblings ...)
  2013-05-07 12:56 ` [PATCH 08/15] meta/lib/oe: Replace StandardError with Exception Richard Purdie
@ 2013-05-07 12:56 ` Richard Purdie
  2013-05-07 12:56 ` [PATCH 10/15] metadata_scm: Replace depracated operator Richard Purdie
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Richard Purdie @ 2013-05-07 12:56 UTC (permalink / raw)
  To: openembedded-core

file() syntax is removed in python 3, use open() instead.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/sanity.bbclass |   24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass
index d4a8f5e..63ea079 100644
--- a/meta/classes/sanity.bbclass
+++ b/meta/classes/sanity.bbclass
@@ -232,7 +232,7 @@ def check_create_long_filename(filepath, pathname):
     try:
         if not os.path.exists(filepath):
             bb.utils.mkdirhier(filepath)
-        f = file(testfile, "w")
+        f = open(testfile, "w")
         f.close()
         os.remove(testfile)
     except IOError as e:
@@ -339,7 +339,7 @@ def check_gcc_march(sanity_data):
     if sanity_data.getVar("BUILD_CFLAGS",True).find("-march") < 0:
 
         # Construct a test file
-        f = file("gcc_test.c", "w")
+        f = open("gcc_test.c", "w")
         f.write("int main (){ __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4; return 0;}\n")
         f.close()
         import commands
@@ -562,7 +562,7 @@ def check_sanity(sanity_data):
     last_sstate_dir = ""
     sanityverfile = 'conf/sanity_info'
     if os.path.exists(sanityverfile):
-        f = file(sanityverfile, 'r')
+        f = open(sanityverfile, 'r')
         for line in f:
             if line.startswith('SANITY_VERSION'):
                 last_sanity_version = int(line.split()[1])
@@ -585,7 +585,7 @@ def check_sanity(sanity_data):
         if last_sstate_dir != sstate_dir:
             messages = messages + check_sanity_sstate_dir_change(sstate_dir, sanity_data)
     if os.path.exists("conf") and not messages:
-        f = file(sanityverfile, 'w')
+        f = open(sanityverfile, 'w')
         f.write("SANITY_VERSION %s\n" % sanity_version) 
         f.write("TMPDIR %s\n" % tmpdir) 
         f.write("SSTATE_DIR %s\n" % sstate_dir) 
@@ -595,13 +595,13 @@ def check_sanity(sanity_data):
     #
     checkfile = os.path.join(tmpdir, "saved_tmpdir")
     if os.path.exists(checkfile):
-        f = file(checkfile, "r")
+        f = open(checkfile, "r")
         saved_tmpdir = f.read().strip()
         if (saved_tmpdir != tmpdir):
             messages = messages + "Error, TMPDIR has changed location. You need to either move it back to %s or rebuild\n" % saved_tmpdir
     else:
         bb.utils.mkdirhier(tmpdir)
-        f = file(checkfile, "w")
+        f = open(checkfile, "w")
         f.write(tmpdir)
     f.close()
 
@@ -611,17 +611,17 @@ def check_sanity(sanity_data):
     current_abi = sanity_data.getVar('OELAYOUT_ABI', True)
     abifile = sanity_data.getVar('SANITY_ABIFILE', True)
     if os.path.exists(abifile):
-        f = file(abifile, "r")
+        f = open(abifile, "r")
         abi = f.read().strip()
         if not abi.isdigit():
-            f = file(abifile, "w")
+            f = open(abifile, "w")
             f.write(current_abi)
         elif abi == "2" and current_abi == "3":
             bb.note("Converting staging from layout version 2 to layout version 3")
             subprocess.call(sanity_data.expand("mv ${TMPDIR}/staging ${TMPDIR}/sysroots"), shell=True)
             subprocess.call(sanity_data.expand("ln -s sysroots ${TMPDIR}/staging"), shell=True)
             subprocess.call(sanity_data.expand("cd ${TMPDIR}/stamps; for i in */*do_populate_staging; do new=`echo $i | sed -e 's/do_populate_staging/do_populate_sysroot/'`; mv $i $new; done"), shell=True)
-            f = file(abifile, "w")
+            f = open(abifile, "w")
             f.write(current_abi)
         elif abi == "3" and current_abi == "4":
             bb.note("Converting staging layout from version 3 to layout version 4")
@@ -629,14 +629,14 @@ def check_sanity(sanity_data):
                 subprocess.call(sanity_data.expand("mv ${STAGING_DIR_NATIVE}${bindir_native}/${MULTIMACH_HOST_SYS} ${STAGING_BINDIR_CROSS}"), shell=True)
                 subprocess.call(sanity_data.expand("ln -s ${STAGING_BINDIR_CROSS} ${STAGING_DIR_NATIVE}${bindir_native}/${MULTIMACH_HOST_SYS}"), shell=True)
 
-            f = file(abifile, "w")
+            f = open(abifile, "w")
             f.write(current_abi)
         elif abi == "4":
             messages = messages + "Staging layout has changed. The cross directory has been deprecated and cross packages are now built under the native sysroot.\nThis requires a rebuild.\n"
         elif abi == "5" and current_abi == "6":
             bb.note("Converting staging layout from version 5 to layout version 6")
             subprocess.call(sanity_data.expand("mv ${TMPDIR}/pstagelogs ${SSTATE_MANIFESTS}"), shell=True)
-            f = file(abifile, "w")
+            f = open(abifile, "w")
             f.write(current_abi)
         elif abi == "7" and current_abi == "8":
             messages = messages + "Your configuration is using stamp files including the sstate hash but your build directory was built with stamp files that do not include this.\nTo continue, either rebuild or switch back to the OEBasic signature handler with BB_SIGNATURE_HANDLER = 'OEBasic'.\n"
@@ -646,7 +646,7 @@ def check_sanity(sanity_data):
             # Code to convert from one ABI to another could go here if possible.
             messages = messages + "Error, TMPDIR has changed its layout version number (%s to %s) and you need to either rebuild, revert or adjust it at your own risk.\n" % (abi, current_abi)
     else:
-        f = file(abifile, "w")
+        f = open(abifile, "w")
         f.write(current_abi)
     f.close()
 
-- 
1.7.10.4




^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 10/15] metadata_scm: Replace depracated operator
  2013-05-07 12:55 [PATCH 01/15] classes/recipes/lib: Fix various python whitespace issues Richard Purdie
                   ` (7 preceding siblings ...)
  2013-05-07 12:56 ` [PATCH 09/15] sanity.bbclass: Use open(), not file() Richard Purdie
@ 2013-05-07 12:56 ` Richard Purdie
  2013-05-07 13:11   ` Phil Blundell
  2013-05-07 12:56 ` [PATCH 11/15] insane: Open file in binary mode Richard Purdie
                   ` (5 subsequent siblings)
  14 siblings, 1 reply; 20+ messages in thread
From: Richard Purdie @ 2013-05-07 12:56 UTC (permalink / raw)
  To: openembedded-core

The <> operator is depracted, use != instead which is equavalent.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/metadata_scm.bbclass |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/meta/classes/metadata_scm.bbclass b/meta/classes/metadata_scm.bbclass
index 502d400..e9b207c 100644
--- a/meta/classes/metadata_scm.bbclass
+++ b/meta/classes/metadata_scm.bbclass
@@ -9,7 +9,7 @@ def base_detect_revision(d):
 
     for scm in scms:
         rev = scm(path, d)
-        if rev <> "<unknown>":
+        if rev != "<unknown>":
             return rev
 
     return "<unknown>"
@@ -21,7 +21,7 @@ def base_detect_branch(d):
 
     for scm in scms:
         rev = scm(path, d)
-        if rev <> "<unknown>":
+        if rev != "<unknown>":
             return rev.strip()
 
     return "<unknown>"
-- 
1.7.10.4




^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 11/15] insane: Open file in binary mode
  2013-05-07 12:55 [PATCH 01/15] classes/recipes/lib: Fix various python whitespace issues Richard Purdie
                   ` (8 preceding siblings ...)
  2013-05-07 12:56 ` [PATCH 10/15] metadata_scm: Replace depracated operator Richard Purdie
@ 2013-05-07 12:56 ` Richard Purdie
  2013-05-07 12:56 ` [PATCH 12/15] image/kernel-module-split/eglibc-ld.inc: Remove has_key() usage Richard Purdie
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Richard Purdie @ 2013-05-07 12:56 UTC (permalink / raw)
  To: openembedded-core

We open the file we're writing to in binary mode so open the input stream with the
same mode so things match. This avoids errors with python3.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/insane.bbclass |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass
index 271e9ff..c5d8ad9 100644
--- a/meta/classes/insane.bbclass
+++ b/meta/classes/insane.bbclass
@@ -578,7 +578,7 @@ def package_qa_check_license(workdir, d):
         if (not beginline) and (not endline):
             md5chksum = bb.utils.md5_file(srclicfile)
         else:
-            fi = open(srclicfile, 'r')
+            fi = open(srclicfile, 'rb')
             fo = tempfile.NamedTemporaryFile(mode='wb', prefix='poky.', suffix='.tmp', delete=False)
             tmplicfile = fo.name;
             lineno = 0
-- 
1.7.10.4




^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 12/15] image/kernel-module-split/eglibc-ld.inc: Remove has_key() usage
  2013-05-07 12:55 [PATCH 01/15] classes/recipes/lib: Fix various python whitespace issues Richard Purdie
                   ` (9 preceding siblings ...)
  2013-05-07 12:56 ` [PATCH 11/15] insane: Open file in binary mode Richard Purdie
@ 2013-05-07 12:56 ` Richard Purdie
  2013-05-07 12:56 ` [PATCH 13/15] sanity/patch.py: Remove commands module usage Richard Purdie
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Richard Purdie @ 2013-05-07 12:56 UTC (permalink / raw)
  To: openembedded-core

The has_key() attribute has been removed in python 3 since there is better
syntax available. Use the improved syntax.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/image.bbclass               |    2 +-
 meta/classes/kernel-module-split.bbclass |    2 +-
 meta/recipes-core/eglibc/eglibc-ld.inc   |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 979921f..251bc9a 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -368,7 +368,7 @@ for dir in dirs.split():
       key=str(os.path.join("/",os.path.relpath(item,dir)))
 
       valid=True;
-      if files.has_key(key):
+      if key in files:
         #check whether the file is allow to replace
         if allow_rep.match(key):
           valid=True
diff --git a/meta/classes/kernel-module-split.bbclass b/meta/classes/kernel-module-split.bbclass
index 45639c6..23714d5 100644
--- a/meta/classes/kernel-module-split.bbclass
+++ b/meta/classes/kernel-module-split.bbclass
@@ -109,7 +109,7 @@ python split_kernel_module_packages () {
         # instead is prefixed with /lib/modules/${KERNEL_VERSION}
         file = file.replace("/lib/modules/%s/" % d.getVar('KERNEL_VERSION', True) or '', '', 1)
 
-        if module_deps.has_key(file):
+        if file in module_deps:
             dependencies = []
             for i in module_deps[file]:
                 m = re.match(pattern, os.path.basename(i))
diff --git a/meta/recipes-core/eglibc/eglibc-ld.inc b/meta/recipes-core/eglibc/eglibc-ld.inc
index e596b55..b1701f00 100644
--- a/meta/recipes-core/eglibc/eglibc-ld.inc
+++ b/meta/recipes-core/eglibc/eglibc-ld.inc
@@ -1,7 +1,7 @@
 def ld_append_if_tune_exists(d, infos, dict):
     tune = d.getVar("DEFAULTTUNE", True) or ""
     libdir = d.getVar("base_libdir", True) or ""
-    if dict.has_key(tune):
+    if tune in dict:
         infos['ldconfig'].add('{"' + libdir + '/' + dict[tune][0] + '",' + dict[tune][1] + ' }')
         infos['lddrewrite'].add(libdir+'/'+dict[tune][0])
 
-- 
1.7.10.4




^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 13/15] sanity/patch.py: Remove commands module usage
  2013-05-07 12:55 [PATCH 01/15] classes/recipes/lib: Fix various python whitespace issues Richard Purdie
                   ` (10 preceding siblings ...)
  2013-05-07 12:56 ` [PATCH 12/15] image/kernel-module-split/eglibc-ld.inc: Remove has_key() usage Richard Purdie
@ 2013-05-07 12:56 ` Richard Purdie
  2013-05-07 12:56 ` [PATCH 14/15] bitbake.conf: Use casting to ensure valid comparision Richard Purdie
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Richard Purdie @ 2013-05-07 12:56 UTC (permalink / raw)
  To: openembedded-core

The commands module is removed in python3. Use the subprocess module instead
and the pipes module to replace the mkargs usage.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/sanity.bbclass |    6 +++---
 meta/lib/oe/patch.py        |    6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass
index 63ea079..3836c04 100644
--- a/meta/classes/sanity.bbclass
+++ b/meta/classes/sanity.bbclass
@@ -342,13 +342,13 @@ def check_gcc_march(sanity_data):
         f = open("gcc_test.c", "w")
         f.write("int main (){ __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4; return 0;}\n")
         f.close()
-        import commands
+        import subprocess
 
         # Check if GCC could work without march
-        status,result = commands.getstatusoutput("${BUILD_PREFIX}gcc gcc_test.c -o gcc_test")
+        status,result = subprocess.getstatusoutput("${BUILD_PREFIX}gcc gcc_test.c -o gcc_test")
         if status != 0:
             # Check if GCC could work with march
-            status,result = commands.getstatusoutput("${BUILD_PREFIX}gcc -march=native gcc_test.c -o gcc_test")
+            status,result = subprocess.getstatusoutput("${BUILD_PREFIX}gcc -march=native gcc_test.c -o gcc_test")
             if status == 0: 
                 result = True
             else:
diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py
index cbc5cd9..8de73a7 100644
--- a/meta/lib/oe/patch.py
+++ b/meta/lib/oe/patch.py
@@ -17,7 +17,7 @@ class CmdError(bb.BBHandledException):
 
 
 def runcmd(args, dir = None):
-    import commands
+    import subprocess, pipes
 
     if dir:
         olddir = os.path.abspath(os.curdir)
@@ -27,10 +27,10 @@ def runcmd(args, dir = None):
         # print("cwd: %s -> %s" % (olddir, dir))
 
     try:
-        args = [ commands.mkarg(str(arg)) for arg in args ]
+        args = [ pipes.quote(str(arg)) for arg in args ]
         cmd = " ".join(args)
         # print("cmd: %s" % cmd)
-        (exitstatus, output) = commands.getstatusoutput(cmd)
+        (exitstatus, output) = subprocess.getstatusoutput(cmd)
         if exitstatus != 0:
             raise CmdError(exitstatus >> 8, output)
         return output
-- 
1.7.10.4




^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 14/15] bitbake.conf: Use casting to ensure valid comparision
  2013-05-07 12:55 [PATCH 01/15] classes/recipes/lib: Fix various python whitespace issues Richard Purdie
                   ` (11 preceding siblings ...)
  2013-05-07 12:56 ` [PATCH 13/15] sanity/patch.py: Remove commands module usage Richard Purdie
@ 2013-05-07 12:56 ` Richard Purdie
  2013-05-07 12:56 ` [PATCH 15/15] base.bbclass: Drop unused/obsolete import Richard Purdie
  2013-05-07 15:37 ` [PATCH 01/15] classes/recipes/lib: Fix various python whitespace issues Martin Jansa
  14 siblings, 0 replies; 20+ messages in thread
From: Richard Purdie @ 2013-05-07 12:56 UTC (permalink / raw)
  To: openembedded-core

python3 is stricter about type comparisions so add an explicit cast to int()
to ensure this code is portable.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/conf/bitbake.conf |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
index d5e923b..8d4ccce 100644
--- a/meta/conf/bitbake.conf
+++ b/meta/conf/bitbake.conf
@@ -188,7 +188,7 @@ PV = "${@bb.parse.BBHandler.vars_from_file(d.getVar('FILE'),d)[1] or '1.0'}"
 PR = "${@bb.parse.BBHandler.vars_from_file(d.getVar('FILE'),d)[2] or 'r0'}"
 PRINC ?= "0"
 PF = "${PN}-${EXTENDPE}${PV}-${PR}"
-EXTENDPE = "${@['','${PE\x7d_'][d.getVar('PE',1) > 0]}"
+EXTENDPE = "${@['','${PE\x7d_'][int(d.getVar('PE',1) or 0) > 0]}"
 P = "${PN}-${PV}"
 
 EXTENDPRAUTO = "${@['.${PRAUTO\x7d',''][d.getVar('PRAUTO',1) is None]}"
@@ -196,7 +196,7 @@ PRAUTOINX = "${PF}"
 
 PKGV ?= "${PV}"
 PKGR ?= "${PR}${EXTENDPRAUTO}"
-PKGE ?= "${@['','${PE\x7d'][d.getVar('PE',1) > 0]}"
+PKGE ?= "${@['','${PE\x7d'][int(d.getVar('PE',1) or 0) > 0]}"
 EXTENDPKGEVER = "${@['','${PKGE\x7d:'][d.getVar('PKGE',1).strip() != '']}"
 EXTENDPKGV ?= "${EXTENDPKGEVER}${PKGV}-${PKGR}"
 
-- 
1.7.10.4




^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 15/15] base.bbclass: Drop unused/obsolete import
  2013-05-07 12:55 [PATCH 01/15] classes/recipes/lib: Fix various python whitespace issues Richard Purdie
                   ` (12 preceding siblings ...)
  2013-05-07 12:56 ` [PATCH 14/15] bitbake.conf: Use casting to ensure valid comparision Richard Purdie
@ 2013-05-07 12:56 ` Richard Purdie
  2013-05-07 15:37 ` [PATCH 01/15] classes/recipes/lib: Fix various python whitespace issues Martin Jansa
  14 siblings, 0 replies; 20+ messages in thread
From: Richard Purdie @ 2013-05-07 12:56 UTC (permalink / raw)
  To: openembedded-core

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/base.bbclass |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index 196acdb..b1642a2 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -394,7 +394,7 @@ def set_packagetriplet(d):
     settriplet(d, "PKGMLTRIPLETS", archs, tos, tvs)
 
 python () {
-    import exceptions, string, re
+    import string, re
 
     # Handle PACKAGECONFIG
     #
-- 
1.7.10.4




^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH 10/15] metadata_scm: Replace depracated operator
  2013-05-07 12:56 ` [PATCH 10/15] metadata_scm: Replace depracated operator Richard Purdie
@ 2013-05-07 13:11   ` Phil Blundell
  0 siblings, 0 replies; 20+ messages in thread
From: Phil Blundell @ 2013-05-07 13:11 UTC (permalink / raw)
  To: Richard Purdie; +Cc: openembedded-core

On Tue, 2013-05-07 at 13:56 +0100, Richard Purdie wrote:
> The <> operator is depracted, use != instead which is equavalent.

typos: "deprecated" (both long and short messages) and "equivalent"

p.





^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 01/15] classes/recipes/lib: Fix various python whitespace issues
  2013-05-07 12:55 [PATCH 01/15] classes/recipes/lib: Fix various python whitespace issues Richard Purdie
                   ` (13 preceding siblings ...)
  2013-05-07 12:56 ` [PATCH 15/15] base.bbclass: Drop unused/obsolete import Richard Purdie
@ 2013-05-07 15:37 ` Martin Jansa
  14 siblings, 0 replies; 20+ messages in thread
From: Martin Jansa @ 2013-05-07 15:37 UTC (permalink / raw)
  To: Richard Purdie; +Cc: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 3309 bytes --]

On Tue, May 07, 2013 at 01:55:53PM +0100, Richard Purdie wrote:
> There are some left over tab characters in the python functions. This
> removes them and resolves python 3 errors.
> 
> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
>  
> @@ -202,13 +202,13 @@ def package_qa_check_useless_rpaths(file, name, d, elf, messages):
>      import re
>      rpath_re = re.compile("\s+RPATH\s+(.*)")
>      for line in phdrs.split("\n"):
> -    	m = rpath_re.match(line)
> -	if m:
> -	   rpath = m.group(1)
> -	   if rpath_eq(rpath, libdir) or rpath_eq(rpath, base_libdir):
> -	      # The dynamic linker searches both these places anyway.  There is no point in
> -	      # looking there again.
> -	      messages.append("%s: %s contains probably-redundant RPATH %s" % (name, package_qa_clean_path(file, d), rpath))
> +        m = rpath_re.match(line)
> +        if m:
> +           rpath = m.group(1)
> +           if rpath_eq(rpath, libdir) or rpath_eq(rpath, base_libdir):
> +              # The dynamic linker searches both these places anyway.  There is no point in
> +              # looking there again.
> +              messages.append("%s: %s contains probably-redundant RPATH %s" % (name, package_qa_clean_path(file, d), rpath))

last 2 blocks are indented only by 3 spaces

>      if not sane:
>          messages.append("ELF binary '%s' has relocations in .text" % path)
> @@ -498,7 +498,7 @@ def package_qa_hash_style(path, name, d, elf, messages):
>          if "GNU_HASH" in line:
>              sane = True
>          if "[mips32]" in line or "[mips64]" in line:
> -	    sane = True
> +             sane = True

this has 5 spaces

>  
>      if has_syms and not sane:
>          messages.append("No GNU_HASH in the elf binary: '%s'" % path)
> diff --git a/meta/classes/multilib_global.bbclass b/meta/classes/multilib_global.bbclass
> index 529e82a..40ae006 100644
> --- a/meta/classes/multilib_global.bbclass
> +++ b/meta/classes/multilib_global.bbclass
> @@ -5,7 +5,7 @@ python multilib_virtclass_handler_global () {
>      if isinstance(e, bb.event.RecipePreFinalise):
>          for v in e.data.getVar("MULTILIB_VARIANTS", True).split():
>              if e.data.getVar("TARGET_VENDOR_virtclass-multilib-" + v, False) is None:
> -	       e.data.setVar("TARGET_VENDOR_virtclass-multilib-" + v, e.data.getVar("TARGET_VENDOR", False) + "ml" + v)
> +               e.data.setVar("TARGET_VENDOR_virtclass-multilib-" + v, e.data.getVar("TARGET_VENDOR", False) + "ml" + v)

3 spaces again

>  
>      variant = e.data.getVar("BBEXTENDVARIANT", True)
>  
> diff --git a/meta/recipes-core/meta/external-sourcery-toolchain.bb b/meta/recipes-core/meta/external-sourcery-toolchain.bb
> index 24c7ce8..3218754 100644
> --- a/meta/recipes-core/meta/external-sourcery-toolchain.bb
> +++ b/meta/recipes-core/meta/external-sourcery-toolchain.bb
> @@ -142,6 +142,6 @@ CSL_VER_MAIN ??= ""
>  
>  python () {
>      if not d.getVar("CSL_VER_MAIN"):
> -	raise bb.parse.SkipPackage("External CSL toolchain not configured (CSL_VER_MAIN not set).")
> +        	raise bb.parse.SkipPackage("External CSL toolchain not configured (CSL_VER_MAIN not set).")

spaces AND tab

-- 
Martin 'JaMa' Jansa     jabber: Martin.Jansa@gmail.com

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 205 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 02/15] core-image-minimal-initramfs: Remove odd quote characters
  2013-05-07 12:55 ` [PATCH 02/15] core-image-minimal-initramfs: Remove odd quote characters Richard Purdie
@ 2013-05-07 15:38   ` Martin Jansa
  0 siblings, 0 replies; 20+ messages in thread
From: Martin Jansa @ 2013-05-07 15:38 UTC (permalink / raw)
  To: Richard Purdie; +Cc: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 1515 bytes --]

On Tue, May 07, 2013 at 01:55:54PM +0100, Richard Purdie wrote:
> The quote characters present trigger pyhton 3 characters type warnings,

                                      ^python^

> we don't need them so replace them with normal quote characters.
> 
> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> ---
>  meta/recipes-core/images/core-image-minimal-initramfs.bb |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/meta/recipes-core/images/core-image-minimal-initramfs.bb b/meta/recipes-core/images/core-image-minimal-initramfs.bb
> index 6de24b3..46a9dc4 100644
> --- a/meta/recipes-core/images/core-image-minimal-initramfs.bb
> +++ b/meta/recipes-core/images/core-image-minimal-initramfs.bb
> @@ -1,7 +1,7 @@
>  # Simple initramfs image. Mostly used for live images.
>  DESCRIPTION = "Small image capable of booting a device. The kernel includes \
>  the Minimal RAM-based Initial Root Filesystem (initramfs), which finds the \
> -first “init” program more efficiently."
> +first 'init' program more efficiently."
>  
>  IMAGE_INSTALL = "initramfs-live-boot initramfs-live-install initramfs-live-install-efi busybox udev base-passwd"
>  
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

-- 
Martin 'JaMa' Jansa     jabber: Martin.Jansa@gmail.com

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 205 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 05/15] classes/lib: Update to use print as a function call
  2013-05-07 12:55 ` [PATCH 05/15] classes/lib: Update to use print as a function call Richard Purdie
@ 2013-05-07 15:40   ` Martin Jansa
  0 siblings, 0 replies; 20+ messages in thread
From: Martin Jansa @ 2013-05-07 15:40 UTC (permalink / raw)
  To: Richard Purdie; +Cc: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 1251 bytes --]

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
>  

-- 
Martin 'JaMa' Jansa     jabber: Martin.Jansa@gmail.com

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 205 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 07/15] bin/bitbake: Ensure early errors are shown to the user
  2013-05-07 12:55 ` [PATCH 07/15] bin/bitbake: Ensure early errors are shown to the user Richard Purdie
@ 2013-05-13  1:31   ` Jonathan Liu
  0 siblings, 0 replies; 20+ messages in thread
From: Jonathan Liu @ 2013-05-13  1:31 UTC (permalink / raw)
  To: Richard Purdie; +Cc: openembedded-core@lists.openembedded.org

[-- Attachment #1: Type: text/plain, Size: 2071 bytes --]

On 7 May 2013 22:55, Richard Purdie <richard.purdie@linuxfoundation.org>wrote:

> Currently if errors occur early in the init process, the errors may
> not be shown to the user. This change ensures that if a failure does
> occur, the messages are flushed from the queue and shown to the user.
>
> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> ---
>  bitbake/bin/bitbake |   21 ++++++++++++++++-----
>  1 file changed, 16 insertions(+), 5 deletions(-)
>
> diff --git a/bitbake/bin/bitbake b/bitbake/bin/bitbake
> index 0e69207..e05ff5b 100755
> --- a/bitbake/bin/bitbake
> +++ b/bitbake/bin/bitbake
> @@ -240,11 +240,22 @@ Default BBFILES are the .bb files in the current
> directory.""")
>
>      idle = server.getServerIdleCB()
>
> -    cooker = bb.cooker.BBCooker(configuration, idle, initialenv)
> -    cooker.parseCommandLine()
> -
> -    server.addcooker(cooker)
> -    server.saveConnectionDetails()
> +    try:
> +        cooker = bb.cooker.BBCooker(configuration, idle, initialenv)
> +        cooker.parseCommandLine()
> +
> +        server.addcooker(cooker)
> +        server.saveConnectionDetails()
> +    except:
> +        while True:
> +            import queue
>
import queue is Python 3. It is import Queue in Python 2.
If I run bitbake when it is already running, I get:

ImportError: No module named queue
ERROR: Only one copy of bitbake should be run against a build directory


> +            try:
> +                event = server.event_queue.get(block=False)
> +            except (queue.Empty, IOError):
> +                break
> +            if isinstance(event, logging.LogRecord):
> +                logger.handle(event)
> +        raise
>      server.detach()
>
>      # Should no longer need to ever reference cooker
> --
> 1.7.10.4
>
>
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
>

Regards,
Jonathan

[-- Attachment #2: Type: text/html, Size: 3275 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2013-05-13  1:49 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-07 12:55 [PATCH 01/15] classes/recipes/lib: Fix various python whitespace issues Richard Purdie
2013-05-07 12:55 ` [PATCH 02/15] core-image-minimal-initramfs: Remove odd quote characters Richard Purdie
2013-05-07 15:38   ` Martin Jansa
2013-05-07 12:55 ` [PATCH 03/15] clases/lib: Use modern exception syntax Richard Purdie
2013-05-07 12:55 ` [PATCH 04/15] classes: Use modern exception raising syntax Richard Purdie
2013-05-07 12:55 ` [PATCH 05/15] classes/lib: Update to use print as a function call Richard Purdie
2013-05-07 15:40   ` Martin Jansa
2013-05-07 12:55 ` [PATCH 06/15] buildstats: Update to ensure files are closed Richard Purdie
2013-05-07 12:55 ` [PATCH 07/15] bin/bitbake: Ensure early errors are shown to the user Richard Purdie
2013-05-13  1:31   ` Jonathan Liu
2013-05-07 12:56 ` [PATCH 08/15] meta/lib/oe: Replace StandardError with Exception Richard Purdie
2013-05-07 12:56 ` [PATCH 09/15] sanity.bbclass: Use open(), not file() Richard Purdie
2013-05-07 12:56 ` [PATCH 10/15] metadata_scm: Replace depracated operator Richard Purdie
2013-05-07 13:11   ` Phil Blundell
2013-05-07 12:56 ` [PATCH 11/15] insane: Open file in binary mode Richard Purdie
2013-05-07 12:56 ` [PATCH 12/15] image/kernel-module-split/eglibc-ld.inc: Remove has_key() usage Richard Purdie
2013-05-07 12:56 ` [PATCH 13/15] sanity/patch.py: Remove commands module usage Richard Purdie
2013-05-07 12:56 ` [PATCH 14/15] bitbake.conf: Use casting to ensure valid comparision Richard Purdie
2013-05-07 12:56 ` [PATCH 15/15] base.bbclass: Drop unused/obsolete import Richard Purdie
2013-05-07 15:37 ` [PATCH 01/15] classes/recipes/lib: Fix various python whitespace issues Martin Jansa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox