From 1fc840ffc0267ecf3a15c4a59ab44869ef1d6339 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Thu, 9 May 2013 16:31:22 +0000 Subject: meta: python3 megapatch This needs splutting into smaller units, WIP atm. (From OE-Core rev: 21529228a7dca96a6a1b44ed9380c523efdeeb3e) Signed-off-by: Richard Purdie --- meta/classes/base.bbclass | 4 +- meta/classes/buildhistory.bbclass | 21 ++++---- meta/classes/chrpath.bbclass | 3 +- meta/classes/insane.bbclass | 11 ++--- meta/classes/kernel-uimage.bbclass | 12 ++--- meta/classes/libc-package.bbclass | 3 ++ meta/classes/license.bbclass | 6 +-- meta/classes/metadata_scm.bbclass | 9 ++-- meta/classes/package.bbclass | 10 ++-- meta/classes/package_deb.bbclass | 30 +++++------- meta/classes/package_ipk.bbclass | 2 +- meta/classes/report-error.bbclass | 2 +- meta/classes/sstate.bbclass | 5 +- meta/classes/staging.bbclass | 2 +- meta/classes/terminal.bbclass | 2 +- meta/classes/toaster.bbclass | 1 + meta/classes/utility-tasks.bbclass | 2 +- meta/conf/bitbake.conf | 2 +- meta/lib/oe/buildhistory_analysis.py | 4 +- meta/lib/oe/classutils.py | 17 +++---- meta/lib/oe/copy_buildsystem.py | 4 +- meta/lib/oe/data.py | 7 ++- meta/lib/oe/distro_check.py | 8 ++-- meta/lib/oe/license.py | 10 ++-- meta/lib/oe/lsb.py | 4 +- meta/lib/oe/maketype.py | 10 ++-- meta/lib/oe/manifest.py | 7 ++- meta/lib/oe/package.py | 6 +-- meta/lib/oe/package_manager.py | 51 ++++++++++---------- meta/lib/oe/packagedata.py | 4 +- meta/lib/oe/packagegroup.py | 4 +- meta/lib/oe/patch.py | 4 +- meta/lib/oe/prservice.py | 6 +-- meta/lib/oe/qa.py | 14 +++--- meta/lib/oe/recipeutils.py | 22 ++++----- meta/lib/oe/rootfs.py | 15 +++--- meta/lib/oe/sdk.py | 8 ++-- meta/lib/oe/sstatesig.py | 4 +- meta/lib/oe/terminal.py | 6 +-- meta/lib/oe/tests/test_path.py | 2 +- meta/lib/oe/types.py | 4 +- meta/lib/oe/utils.py | 16 +++---- meta/lib/oeqa/controllers/masterimage.py | 4 +- meta/lib/oeqa/oetest.py | 10 +++- meta/lib/oeqa/runtime/files/test.py | 2 +- meta/lib/oeqa/runtime/parselogs.py | 4 +- meta/lib/oeqa/runtime/ping.py | 2 +- meta/lib/oeqa/runtime/systemd.py | 6 +-- meta/lib/oeqa/selftest/_toaster.py | 4 +- meta/lib/oeqa/selftest/devtool.py | 2 +- meta/lib/oeqa/selftest/pkgdata.py | 56 +++++++++++----------- meta/lib/oeqa/selftest/recipetool.py | 4 +- meta/lib/oeqa/selftest/sstatetests.py | 4 +- meta/lib/oeqa/targetcontrol.py | 4 +- meta/lib/oeqa/utils/commands.py | 6 +-- meta/lib/oeqa/utils/decorators.py | 19 +++++++- meta/lib/oeqa/utils/dump.py | 2 +- meta/lib/oeqa/utils/httpserver.py | 6 +-- meta/lib/oeqa/utils/logparser.py | 2 +- meta/lib/oeqa/utils/qemurunner.py | 54 ++++++++++++--------- meta/lib/oeqa/utils/qemutinyrunner.py | 10 ++-- meta/lib/oeqa/utils/sshcontrol.py | 1 + meta/lib/oeqa/utils/targetbuild.py | 4 +- meta/lib/oeqa/utils/testexport.py | 2 +- meta/recipes-devtools/apt/apt-native.inc | 2 +- .../recipes-graphics/xorg-xserver/xserver-xorg.inc | 5 +- scripts/oe-selftest | 10 ++-- 67 files changed, 310 insertions(+), 279 deletions(-) diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass index e5c58b1e20..4b6aab4562 100644 --- a/meta/classes/base.bbclass +++ b/meta/classes/base.bbclass @@ -10,7 +10,7 @@ inherit utility-tasks inherit metadata_scm inherit logging -OE_IMPORTS += "os sys time oe.path oe.utils oe.data oe.package oe.packagegroup oe.sstatesig oe.lsb oe.cachedpath" +OE_IMPORTS += "os sys time oe.path oe.utils oe.types oe.package oe.packagegroup oe.sstatesig oe.lsb oe.cachedpath" OE_IMPORTS[type] = "list" def oe_import(d): @@ -658,7 +658,7 @@ python do_cleanall() { try: fetcher = bb.fetch2.Fetch(src_uri, d) fetcher.clean() - except bb.fetch2.BBFetchException, e: + except bb.fetch2.BBFetchException as e: raise bb.build.FuncFailed(e) } do_cleanall[nostamp] = "1" diff --git a/meta/classes/buildhistory.bbclass b/meta/classes/buildhistory.bbclass index 581d532693..3db92d4de7 100644 --- a/meta/classes/buildhistory.bbclass +++ b/meta/classes/buildhistory.bbclass @@ -64,6 +64,11 @@ python buildhistory_emit_pkghistory() { if not d.getVar('BB_CURRENTTASK', True) in ['packagedata', 'packagedata_setscene']: return 0 + import re + import sys + if sys.version > '3': + long = int + if not "package" in (d.getVar('BUILDHISTORY_FEATURES', True) or "").split(): return 0 @@ -233,7 +238,7 @@ python buildhistory_emit_pkghistory() { key = item[0] if key.endswith('_' + pkg): key = key[:-len(pkg)-1] - pkgdata[key] = item[1].decode('utf-8').decode('string_escape') + pkgdata[key] = item[1] pkge = pkgdata.get('PKGE', '0') pkgv = pkgdata['PKGV'] @@ -274,7 +279,7 @@ python buildhistory_emit_pkghistory() { # Gather information about packaged files val = pkgdata.get('FILES_INFO', '') dictval = json.loads(val) - filelist = dictval.keys() + filelist = list(dictval.keys()) filelist.sort() pkginfo.filelist = " ".join(filelist) @@ -288,14 +293,12 @@ python buildhistory_emit_pkghistory() { def write_recipehistory(rcpinfo, d): - import codecs - bb.debug(2, "Writing recipe history") pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE', True) infofile = os.path.join(pkghistdir, "latest") - with codecs.open(infofile, "w", encoding='utf8') as f: + with open(infofile, "w") as f: if rcpinfo.pe != "0": f.write(u"PE = %s\n" % rcpinfo.pe) f.write(u"PV = %s\n" % rcpinfo.pv) @@ -305,8 +308,6 @@ def write_recipehistory(rcpinfo, d): def write_pkghistory(pkginfo, d): - import codecs - bb.debug(2, "Writing package history for package %s" % pkginfo.name) pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE', True) @@ -316,7 +317,7 @@ def write_pkghistory(pkginfo, d): bb.utils.mkdirhier(pkgpath) infofile = os.path.join(pkgpath, "latest") - with codecs.open(infofile, "w", encoding='utf8') as f: + with open(infofile, "w") as f: if pkginfo.pe != "0": f.write(u"PE = %s\n" % pkginfo.pe) f.write(u"PV = %s\n" % pkginfo.pv) @@ -349,7 +350,7 @@ def write_pkghistory(pkginfo, d): filevarpath = os.path.join(pkgpath, "latest.%s" % filevar) val = pkginfo.filevars[filevar] if val: - with codecs.open(filevarpath, "w", encoding='utf8') as f: + with open(filevarpath, "w") as f: f.write(val) else: if os.path.exists(filevarpath): @@ -842,7 +843,7 @@ python write_srcrev() { f.write('# SRCREV_%s = "%s"\n' % (name, orig_srcrev)) f.write('SRCREV_%s = "%s"\n' % (name, srcrev)) else: - f.write('SRCREV = "%s"\n' % srcrevs.itervalues().next()) + f.write('SRCREV = "%s"\n' % srcrevs.values()) if len(tag_srcrevs) > 0: for name, srcrev in tag_srcrevs.items(): f.write('# tag_%s = "%s"\n' % (name, srcrev)) diff --git a/meta/classes/chrpath.bbclass b/meta/classes/chrpath.bbclass index 9c68855ab2..0182062adf 100644 --- a/meta/classes/chrpath.bbclass +++ b/meta/classes/chrpath.bbclass @@ -10,6 +10,8 @@ def process_file_linux(cmd, fpath, rootdir, baseprefix, tmpdir, d): if p.returncode != 0: return + err = err.decode('ascii') + # Handle RUNPATH as well as RPATH err = err.replace("RUNPATH=","RPATH=") # Throw away everything other than the rpath list @@ -103,7 +105,6 @@ def process_dir (rootdir, directory, d): # Temporarily make the file writeable so we can chrpath it os.chmod(fpath, perms|stat.S_IRWXU) process_file(cmd, fpath, rootdir, baseprefix, tmpdir, d) - if perms: os.chmod(fpath, perms) diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass index 0b151c214d..d4b9825c93 100644 --- a/meta/classes/insane.bbclass +++ b/meta/classes/insane.bbclass @@ -177,9 +177,8 @@ def package_qa_write_error(type, error, d): logfile = d.getVar('QA_LOGFILE', True) if logfile: p = d.getVar('P', True) - f = file( logfile, "a+") - print >> f, "%s: %s [%s]" % (p, error, type) - f.close() + with open(logfile, "a+") as f: + f.write("%s: %s [%s]" % (p, error, type)) def package_qa_handle_error(error_class, error_msg, d): package_qa_write_error(error_class, error_msg, d) @@ -987,12 +986,12 @@ def package_qa_check_expanded_d(path,name,d,elf,messages): return sane def package_qa_check_encoding(keys, encode, d): - def check_encoding(key,enc): + def check_encoding(key, enc): sane = True value = d.getVar(key, True) if value: try: - s = unicode(value, enc) + s = value.encode(enc) except UnicodeDecodeError as e: error_msg = "%s has non %s characters" % (key,enc) sane = False @@ -1218,7 +1217,7 @@ Missing inherit gettext?""" % (gt, config)) try: flag = "WARNING: unrecognized options:" log = os.path.join(d.getVar('B', True), 'config.log') - output = subprocess.check_output(['grep', '-F', flag, log]).replace(', ', ' ') + output = subprocess.check_output(['grep', '-F', flag, log]).decode("utf-8").replace(', ', ' ') options = set() for line in output.splitlines(): options |= set(line.partition(flag)[2].split()) diff --git a/meta/classes/kernel-uimage.bbclass b/meta/classes/kernel-uimage.bbclass index de7ca38e94..543f5432ba 100644 --- a/meta/classes/kernel-uimage.bbclass +++ b/meta/classes/kernel-uimage.bbclass @@ -7,12 +7,12 @@ python __anonymous () { depends = "%s u-boot-mkimage-native" % depends d.setVar("DEPENDS", depends) - # Override KERNEL_IMAGETYPE_FOR_MAKE variable, which is internal - # to kernel.bbclass . We override the variable here, since we need - # to build uImage using the kernel build system if and only if - # KEEPUIMAGE == yes. Otherwise, we pack compressed vmlinux into - # the uImage . - if d.getVar("KEEPUIMAGE", True) != 'yes': + # Override KERNEL_IMAGETYPE_FOR_MAKE variable, which is internal + # to kernel.bbclass . We override the variable here, since we need + # to build uImage using the kernel build system if and only if + # KEEPUIMAGE == yes. Otherwise, we pack compressed vmlinux into + # the uImage . + if d.getVar("KEEPUIMAGE", True) != 'yes': d.setVar("KERNEL_IMAGETYPE_FOR_MAKE", "vmlinux") } diff --git a/meta/classes/libc-package.bbclass b/meta/classes/libc-package.bbclass index 467d567923..70f479bb41 100644 --- a/meta/classes/libc-package.bbclass +++ b/meta/classes/libc-package.bbclass @@ -150,6 +150,7 @@ python package_do_split_gconvs () { c_re = re.compile('^copy "(.*)"') i_re = re.compile('^include "(\w+)".*') for l in f.readlines(): + l = l.decode("latin-1") m = c_re.match(l) or i_re.match(l) if m: dp = legitimize_package_name('%s%s-gconv-%s' % (mlprefix, bpn, m.group(1))) @@ -171,6 +172,7 @@ python package_do_split_gconvs () { c_re = re.compile('^copy "(.*)"') i_re = re.compile('^include "(\w+)".*') for l in f.readlines(): + l = l.decode("latin-1") m = c_re.match(l) or i_re.match(l) if m: dp = legitimize_package_name('%s%s-charmap-%s' % (mlprefix, bpn, m.group(1))) @@ -191,6 +193,7 @@ python package_do_split_gconvs () { c_re = re.compile('^copy "(.*)"') i_re = re.compile('^include "(\w+)".*') for l in f.readlines(): + l = l.decode("latin-1") m = c_re.match(l) or i_re.match(l) if m: dp = legitimize_package_name(mlprefix+bpn+'-localedata-%s' % m.group(1)) diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass index 69335d650d..10d6ed853a 100644 --- a/meta/classes/license.bbclass +++ b/meta/classes/license.bbclass @@ -200,7 +200,7 @@ def get_deployed_dependencies(d): # it might contain the bootloader. taskdata = d.getVar("BB_TASKDEPDATA", False) depends = list(set([dep[0] for dep - in taskdata.itervalues() + in list(taskdata.values()) if not dep[0].endswith("-native")])) extra_depends = d.getVar("EXTRA_IMAGEDEPENDS", True) boot_depends = get_boot_dependencies(d) @@ -261,7 +261,7 @@ def get_boot_dependencies(d): depends.append(dep) # We need to search for the provider of the dependency else: - for taskdep in taskdepdata.itervalues(): + for taskdep in taskdepdata.values(): # The fifth field contains what the task provides if dep in taskdep[4]: info_file = os.path.join( @@ -635,7 +635,7 @@ def check_license_format(d): licenses = d.getVar('LICENSE', True) from oe.license import license_operator, license_operator_chars, license_pattern - elements = filter(lambda x: x.strip(), license_operator.split(licenses)) + elements = list(filter(lambda x: x.strip(), license_operator.split(licenses))) for pos, element in enumerate(elements): if license_pattern.match(element): if pos > 0 and license_pattern.match(elements[pos - 1]): diff --git a/meta/classes/metadata_scm.bbclass b/meta/classes/metadata_scm.bbclass index 2e6fac209a..257df3c99a 100644 --- a/meta/classes/metadata_scm.bbclass +++ b/meta/classes/metadata_scm.bbclass @@ -69,8 +69,8 @@ def base_get_metadata_git_branch(path, d): try: rev, _ = bb.process.run('git rev-parse --abbrev-ref HEAD', cwd=path) except bb.process.ExecutionError: - rev = '' - return rev.strip() + return '' + return rev.strip().decode("utf-8") def base_get_metadata_git_revision(path, d): import bb.process @@ -78,5 +78,6 @@ def base_get_metadata_git_revision(path, d): try: rev, _ = bb.process.run('git rev-parse HEAD', cwd=path) except bb.process.ExecutionError: - rev = '' - return rev.strip() + return '' + return rev.strip().decode("utf-8") + diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass index ffd4eff7b1..f2df923273 100644 --- a/meta/classes/package.bbclass +++ b/meta/classes/package.bbclass @@ -63,7 +63,7 @@ def legitimize_package_name(s): def fixutf(m): cp = m.group(1) if cp: - return ('\u%s' % cp).decode('unicode_escape').encode('utf-8') + return ('\\u%s' % cp).encode('latin-1').decode('unicode_escape') # Handle unicode codepoints encoded as , as in glibc locale files. s = re.sub('', fixutf, s) @@ -1258,8 +1258,8 @@ python emit_pkgdata() { def write_if_exists(f, pkg, var): def encode(str): import codecs - c = codecs.getencoder("string_escape") - return c(str)[0] + c = codecs.getencoder("unicode_escape") + return c(str)[0].decode("latin1") val = d.getVar('%s_%s' % (var, pkg), True) if val: @@ -1503,7 +1503,7 @@ python package_do_shlibs() { m = re.match("\s+RPATH\s+([^\s]*)", l) if m: rpaths = m.group(1).replace("$ORIGIN", ldir).split(":") - rpath = map(os.path.normpath, rpaths) + rpath = list(map(os.path.normpath, rpaths)) for l in lines: m = re.match("\s+NEEDED\s+([^\s]*)", l) if m: @@ -1673,7 +1673,7 @@ python package_do_shlibs() { bb.debug(2, '%s: Dependency %s covered by PRIVATE_LIBS' % (pkg, n[0])) continue if n[0] in shlib_provider.keys(): - shlib_provider_path = list() + shlib_provider_path = [] for k in shlib_provider[n[0]].keys(): shlib_provider_path.append(k) match = None diff --git a/meta/classes/package_deb.bbclass b/meta/classes/package_deb.bbclass index e1d05a74c2..e35f427ea2 100644 --- a/meta/classes/package_deb.bbclass +++ b/meta/classes/package_deb.bbclass @@ -117,7 +117,7 @@ python do_package_deb () { controldir = os.path.join(root, 'DEBIAN') bb.utils.mkdirhier(controldir) - os.chmod(controldir, 0755) + os.chmod(controldir, 0o755) try: import codecs ctrlfile = codecs.open(os.path.join(controldir, 'control'), 'w', 'utf-8') @@ -173,7 +173,7 @@ python do_package_deb () { # Special behavior for description... if 'DESCRIPTION' in fs: summary = localdata.getVar('SUMMARY', True) or localdata.getVar('DESCRIPTION', True) or "." - ctrlfile.write('Description: %s\n' % unicode(summary,'utf-8')) + ctrlfile.write('Description: %s\n' % summary) description = localdata.getVar('DESCRIPTION', True) or "." description = textwrap.dedent(description).strip() if '\\n' in description: @@ -182,29 +182,25 @@ python do_package_deb () { # We don't limit the width when manually indent, but we do # need the textwrap.fill() to set the initial_indent and # subsequent_indent, so set a large width - ctrlfile.write('%s\n' % unicode(textwrap.fill(t, width=100000, initial_indent=' ', subsequent_indent=' '),'utf-8')) + ctrlfile.write('%s\n' % textwrap.fill(t, width=100000, initial_indent=' ', subsequent_indent=' ')) else: # Auto indent - ctrlfile.write('%s\n' % unicode(textwrap.fill(description.strip(), width=74, initial_indent=' ', subsequent_indent=' '),'utf-8')) + ctrlfile.write('%s\n' % textwrap.fill(description.strip(), width=74, initial_indent=' ', subsequent_indent=' ')) else: - ctrlfile.write(unicode(c % tuple(pullData(fs, localdata)),'utf-8')) + ctrlfile.write(c % tuple(pullData(fs, localdata))) except KeyError: import sys (type, value, traceback) = sys.exc_info() bb.utils.unlockfile(lf) ctrlfile.close() raise bb.build.FuncFailed("Missing field for deb generation: %s" % value) - except UnicodeDecodeError: - bb.utils.unlockfile(lf) - ctrlfile.close() - raise bb.build.FuncFailed("Non UTF-8 characters found in one of the fields") # more fields custom_fields_chunk = get_package_additional_metadata("deb", localdata) if custom_fields_chunk is not None: - ctrlfile.write(unicode(custom_fields_chunk)) + ctrlfile.write(custom_fields_chunk) ctrlfile.write("\n") mapping_rename_hook(localdata) @@ -255,17 +251,17 @@ python do_package_deb () { rconflicts = bb.utils.explode_dep_versions2(localdata.getVar("RCONFLICTS", True) or "") debian_cmp_remap(rconflicts) if rdepends: - ctrlfile.write("Depends: %s\n" % unicode(bb.utils.join_deps(rdepends))) + ctrlfile.write("Depends: %s\n" % bb.utils.join_deps(rdepends)) if rsuggests: - ctrlfile.write("Suggests: %s\n" % unicode(bb.utils.join_deps(rsuggests))) + ctrlfile.write("Suggests: %s\n" % bb.utils.join_deps(rsuggests)) if rrecommends: - ctrlfile.write("Recommends: %s\n" % unicode(bb.utils.join_deps(rrecommends))) + ctrlfile.write("Recommends: %s\n" % bb.utils.join_deps(rrecommends)) if rprovides: - ctrlfile.write("Provides: %s\n" % unicode(bb.utils.join_deps(rprovides))) + ctrlfile.write("Provides: %s\n" % bb.utils.join_deps(rprovides)) if rreplaces: - ctrlfile.write("Replaces: %s\n" % unicode(bb.utils.join_deps(rreplaces))) + ctrlfile.write("Replaces: %s\n" % bb.utils.join_deps(rreplaces)) if rconflicts: - ctrlfile.write("Conflicts: %s\n" % unicode(bb.utils.join_deps(rconflicts))) + ctrlfile.write("Conflicts: %s\n" % bb.utils.join_deps(rconflicts)) ctrlfile.close() for script in ["preinst", "postinst", "prerm", "postrm"]: @@ -293,7 +289,7 @@ python do_package_deb () { scriptfile.write(scriptvar[pos:]) scriptfile.write('\n') scriptfile.close() - os.chmod(os.path.join(controldir, script), 0755) + os.chmod(os.path.join(controldir, script), 0o755) conffiles_str = ' '.join(get_conffiles(pkg, d)) if conffiles_str: diff --git a/meta/classes/package_ipk.bbclass b/meta/classes/package_ipk.bbclass index f1ad1d5c17..08f7020a9e 100644 --- a/meta/classes/package_ipk.bbclass +++ b/meta/classes/package_ipk.bbclass @@ -225,7 +225,7 @@ python do_package_ipk () { raise bb.build.FuncFailed("unable to open %s script file for writing." % script) scriptfile.write(scriptvar) scriptfile.close() - os.chmod(os.path.join(controldir, script), 0755) + os.chmod(os.path.join(controldir, script), 0o755) conffiles_str = ' '.join(get_conffiles(pkg, d)) if conffiles_str: diff --git a/meta/classes/report-error.bbclass b/meta/classes/report-error.bbclass index 20d2bef797..5cbf8f07fd 100644 --- a/meta/classes/report-error.bbclass +++ b/meta/classes/report-error.bbclass @@ -43,7 +43,7 @@ python errorreport_handler () { data['target_sys'] = e.data.getVar("TARGET_SYS", True) data['failures'] = [] data['component'] = e.getPkgs()[0] - data['branch_commit'] = base_detect_branch(e.data) + ": " + base_detect_revision(e.data) + data['branch_commit'] = str(base_detect_branch(e.data)) + ": " + str(base_detect_revision(e.data)) lock = bb.utils.lockfile(datafile + '.lock') errorreport_savedata(e, data, "error-report.txt") bb.utils.unlockfile(lock) diff --git a/meta/classes/sstate.bbclass b/meta/classes/sstate.bbclass index ab8ca6e215..6491bad204 100644 --- a/meta/classes/sstate.bbclass +++ b/meta/classes/sstate.bbclass @@ -235,10 +235,11 @@ def sstate_install(ss, d): bb.fatal("If the above message is too much, the simpler version is you're advised to wipe out tmp and rebuild (reusing sstate is fine). That will likely fix things in most (but not all) cases.") # Write out the manifest - f = open(manifest, "w") + f = open(manifest, "w", encoding="utf-8", errors="surrogateescape") for file in sharedfiles: f.write(file + "\n") + # We want to ensure that directories appear at the end of the manifest # so that when we test to see if they should be deleted any contents # added by the task will have been removed first. @@ -382,7 +383,7 @@ def sstate_clean_cachefiles(d): def sstate_clean_manifest(manifest, d): import oe.path - mfile = open(manifest) + mfile = open(manifest, encoding="utf-8") entries = mfile.readlines() mfile.close() diff --git a/meta/classes/staging.bbclass b/meta/classes/staging.bbclass index a0f82be4ab..30f2b507e1 100644 --- a/meta/classes/staging.bbclass +++ b/meta/classes/staging.bbclass @@ -187,7 +187,7 @@ def sysroot_checkhashes(covered, tasknames, fnids, fns, d, invalidtasks = None): problems = set() configurefnids = set() if not invalidtasks: - invalidtasks = xrange(len(tasknames)) + invalidtasks = range(len(tasknames)) for task in invalidtasks: if tasknames[task] == "do_configure" and task not in covered: configurefnids.add(fnids[task]) diff --git a/meta/classes/terminal.bbclass b/meta/classes/terminal.bbclass index a94f755a40..d1cc4d2c16 100644 --- a/meta/classes/terminal.bbclass +++ b/meta/classes/terminal.bbclass @@ -73,7 +73,7 @@ def oe_terminal(command, title, d): # Replace command with an executable wrapper script command = emit_terminal_func(command, envdata, d) - terminal = oe.data.typed_value('OE_TERMINAL', d).lower() + terminal = "auto" #oe.data.typed_value('OE_TERMINAL', d).lower() if terminal == 'none': bb.fatal('Devshell usage disabled with OE_TERMINAL') elif terminal != 'auto': diff --git a/meta/classes/toaster.bbclass b/meta/classes/toaster.bbclass index 1a70f14a92..1878fe095d 100644 --- a/meta/classes/toaster.bbclass +++ b/meta/classes/toaster.bbclass @@ -33,6 +33,7 @@ python toaster_layerinfo_dumpdata() { def _get_git_branch(layer_path): branch = subprocess.Popen("git symbolic-ref HEAD 2>/dev/null ", cwd=layer_path, shell=True, stdout=subprocess.PIPE).communicate()[0] + branch = branch.decode('utf-8') branch = branch.replace('refs/heads/', '').rstrip() return branch diff --git a/meta/classes/utility-tasks.bbclass b/meta/classes/utility-tasks.bbclass index 5bcfd0b72c..7bc584abb9 100644 --- a/meta/classes/utility-tasks.bbclass +++ b/meta/classes/utility-tasks.bbclass @@ -46,7 +46,7 @@ python do_checkuri() { try: fetcher = bb.fetch2.Fetch(src_uri, d) fetcher.checkstatus() - except bb.fetch2.BBFetchException, e: + except bb.fetch2.BBFetchException as e: raise bb.build.FuncFailed(e) } diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf index 382dadca6d..f5675577fa 100644 --- a/meta/conf/bitbake.conf +++ b/meta/conf/bitbake.conf @@ -484,7 +484,7 @@ export BUILD_NM = "${BUILD_PREFIX}nm" export MAKE = "make" EXTRA_OEMAKE = "" EXTRA_OECONF = "" -export LC_ALL = "C" +export LC_ALL = "us_EN.UTF-8" ################################################################## # Patch handling. diff --git a/meta/lib/oe/buildhistory_analysis.py b/meta/lib/oe/buildhistory_analysis.py index 5395c768a3..0dcd49f4f1 100644 --- a/meta/lib/oe/buildhistory_analysis.py +++ b/meta/lib/oe/buildhistory_analysis.py @@ -62,7 +62,7 @@ class ChangeRecord: def pkglist_combine(depver): pkglist = [] - for k,v in depver.iteritems(): + for k,v in depver.items(): if v: pkglist.append("%s (%s)" % (k,v)) else: @@ -220,7 +220,7 @@ def compare_file_lists(alines, blines): adict = file_list_to_dict(alines) bdict = file_list_to_dict(blines) filechanges = [] - for path, splitv in adict.iteritems(): + for path, splitv in adict.items(): newsplitv = bdict.pop(path, None) if newsplitv: # Check type diff --git a/meta/lib/oe/classutils.py b/meta/lib/oe/classutils.py index 58188fdd6e..e7856c86f2 100644 --- a/meta/lib/oe/classutils.py +++ b/meta/lib/oe/classutils.py @@ -1,4 +1,11 @@ -class ClassRegistry(type): + +class ClassRegistryMeta(type): + """Give each ClassRegistry their own registry""" + def __init__(cls, name, bases, attrs): + cls.registry = {} + type.__init__(cls, name, bases, attrs) + +class ClassRegistry(type, metaclass=ClassRegistryMeta): """Maintain a registry of classes, indexed by name. Note that this implementation requires that the names be unique, as it uses @@ -12,12 +19,6 @@ Subclasses of ClassRegistry may define an 'implemented' property to exert control over whether the class will be added to the registry (e.g. to keep abstract base classes out of the registry).""" priority = 0 - class __metaclass__(type): - """Give each ClassRegistry their own registry""" - def __init__(cls, name, bases, attrs): - cls.registry = {} - type.__init__(cls, name, bases, attrs) - def __init__(cls, name, bases, attrs): super(ClassRegistry, cls).__init__(name, bases, attrs) try: @@ -34,7 +35,7 @@ abstract base classes out of the registry).""" @classmethod def prioritized(tcls): - return sorted(tcls.registry.values(), + return sorted(list(tcls.registry.values()), key=lambda v: v.priority, reverse=True) def unregister(cls): diff --git a/meta/lib/oe/copy_buildsystem.py b/meta/lib/oe/copy_buildsystem.py index 7b9a0ee065..eddf5bb2da 100644 --- a/meta/lib/oe/copy_buildsystem.py +++ b/meta/lib/oe/copy_buildsystem.py @@ -124,7 +124,7 @@ class BuildSystem(object): def generate_locked_sigs(sigfile, d): bb.utils.mkdirhier(os.path.dirname(sigfile)) depd = d.getVar('BB_TASKDEPDATA', False) - tasks = ['%s.%s' % (v[2], v[1]) for v in depd.itervalues()] + tasks = ['%s.%s' % (v[2], v[1]) for v in depd.values()] bb.parse.siggen.dump_lockedsigs(sigfile, tasks) def prune_lockedsigs(excluded_tasks, excluded_targets, lockedsigs, pruned_output): @@ -195,7 +195,7 @@ def merge_lockedsigs(copy_tasks, lockedsigs_main, lockedsigs_extra, merged_outpu fulltypes.append(typename) f.write('SIGGEN_LOCKEDSIGS_TYPES = "%s"\n' % ' '.join(fulltypes)) - write_sigs_file(copy_output, tocopy.keys(), tocopy) + write_sigs_file(copy_output, list(tocopy.keys()), tocopy) if merged_output: write_sigs_file(merged_output, arch_order, merged) diff --git a/meta/lib/oe/data.py b/meta/lib/oe/data.py index e49572177b..58e764699d 100644 --- a/meta/lib/oe/data.py +++ b/meta/lib/oe/data.py @@ -1,17 +1,20 @@ import oe.maketype def typed_value(key, d): + #return d.getVar(key, True).split() + """Construct a value for the specified metadata variable, using its flags to determine the type and parameters for construction.""" var_type = d.getVarFlag(key, 'type', True) flags = d.getVarFlags(key) if flags is not None: flags = dict((flag, d.expand(value)) - for flag, value in flags.iteritems()) + for flag, value in list(flags.items())) else: flags = {} try: return oe.maketype.create(d.getVar(key, True) or '', var_type, **flags) - except (TypeError, ValueError), exc: + except (TypeError, ValueError) as exc: bb.msg.fatal("Data", "%s: %s" % (key, str(exc))) + diff --git a/meta/lib/oe/distro_check.py b/meta/lib/oe/distro_check.py index 8655a6fc14..746e242f5d 100644 --- a/meta/lib/oe/distro_check.py +++ b/meta/lib/oe/distro_check.py @@ -1,8 +1,8 @@ from contextlib import contextmanager @contextmanager def create_socket(url, d): - import urllib - socket = urllib.urlopen(url, proxies=get_proxies(d)) + import urllib.request, urllib.parse, urllib.error + socket = urllib.request.urlopen(url, proxies=get_proxies(d)) try: yield socket finally: @@ -104,8 +104,8 @@ def get_source_package_list_from_url(url, section, d): bb.note("Reading %s: %s" % (url, section)) links = get_links_from_url(url, d) - srpms = filter(is_src_rpm, links) - names_list = map(package_name_from_srpm, srpms) + srpms = list(filter(is_src_rpm, links)) + names_list = list(map(package_name_from_srpm, srpms)) new_pkgs = [] for pkgs in names_list: diff --git a/meta/lib/oe/license.py b/meta/lib/oe/license.py index f0f661c3ba..39ef9654fc 100644 --- a/meta/lib/oe/license.py +++ b/meta/lib/oe/license.py @@ -47,7 +47,7 @@ class LicenseVisitor(ast.NodeVisitor): """Get elements based on OpenEmbedded license strings""" def get_elements(self, licensestr): new_elements = [] - elements = filter(lambda x: x.strip(), license_operator.split(licensestr)) + elements = list([x for x in license_operator.split(licensestr) if x.strip()]) for pos, element in enumerate(elements): if license_pattern.match(element): if pos > 0 and license_pattern.match(elements[pos-1]): @@ -118,8 +118,8 @@ def is_included(licensestr, whitelist=None, blacklist=None): def choose_licenses(alpha, beta): """Select the option in an OR which is the 'best' (has the most included licenses).""" - alpha_weight = len(filter(include_license, alpha)) - beta_weight = len(filter(include_license, beta)) + alpha_weight = len(list(filter(include_license, alpha))) + beta_weight = len(list(filter(include_license, beta))) if alpha_weight > beta_weight: return alpha else: @@ -132,8 +132,8 @@ def is_included(licensestr, whitelist=None, blacklist=None): blacklist = [] licenses = flattened_licenses(licensestr, choose_licenses) - excluded = filter(lambda lic: exclude_license(lic), licenses) - included = filter(lambda lic: include_license(lic), licenses) + excluded = [lic for lic in licenses if exclude_license(lic)] + included = [lic for lic in licenses if include_license(lic)] if excluded: return False, excluded else: diff --git a/meta/lib/oe/lsb.py b/meta/lib/oe/lsb.py index e0bdfba255..b7e142387c 100644 --- a/meta/lib/oe/lsb.py +++ b/meta/lib/oe/lsb.py @@ -9,9 +9,9 @@ def release_dict(): data = {} for line in output.splitlines(): - if line.startswith("-e"): line = line[3:] + if line.startswith(b"-e"): line = line[3:] try: - key, value = line.split(":\t", 1) + key, value = line.decode().split(":\t", 1) except ValueError: continue else: diff --git a/meta/lib/oe/maketype.py b/meta/lib/oe/maketype.py index 139f333691..de344a802c 100644 --- a/meta/lib/oe/maketype.py +++ b/meta/lib/oe/maketype.py @@ -6,7 +6,8 @@ the arguments of the type's factory for details. """ import inspect -import types +import oe.types as types +import collections available_types = {} @@ -53,7 +54,9 @@ def get_callable_args(obj): if type(obj) is type: obj = obj.__init__ - args, varargs, keywords, defaults = inspect.getargspec(obj) + sig = inspect.signature(obj) + args = list(sig.parameters.keys()) + defaults = list(s for s in sig.parameters.keys() if sig.parameters[s].default != inspect.Parameter.empty) flaglist = [] if args: if len(args) > 1 and args[0] == 'self': @@ -93,7 +96,8 @@ for name in dir(types): continue obj = getattr(types, name) - if not callable(obj): + if not isinstance(obj, collections.Callable): continue register(name, obj) + diff --git a/meta/lib/oe/manifest.py b/meta/lib/oe/manifest.py index 42832f15d2..95f8eb2df3 100644 --- a/meta/lib/oe/manifest.py +++ b/meta/lib/oe/manifest.py @@ -4,11 +4,10 @@ import re import bb -class Manifest(object): +class Manifest(object, metaclass=ABCMeta): """ This is an abstract class. Do not instantiate this directly. """ - __metaclass__ = ABCMeta PKG_TYPE_MUST_INSTALL = "mip" PKG_TYPE_MULTILIB = "mlp" @@ -219,7 +218,7 @@ class RpmManifest(Manifest): if var in self.vars_to_split: split_pkgs = self._split_multilib(self.d.getVar(var, True)) if split_pkgs is not None: - pkgs = dict(pkgs.items() + split_pkgs.items()) + pkgs = dict(list(pkgs.items()) + list(split_pkgs.items())) else: pkg_list = self.d.getVar(var, True) if pkg_list is not None: @@ -269,7 +268,7 @@ class OpkgManifest(Manifest): if var in self.vars_to_split: split_pkgs = self._split_multilib(self.d.getVar(var, True)) if split_pkgs is not None: - pkgs = dict(pkgs.items() + split_pkgs.items()) + pkgs = dict(list(pkgs.items()) + list(split_pkgs.items())) else: pkg_list = self.d.getVar(var, True) if pkg_list is not None: diff --git a/meta/lib/oe/package.py b/meta/lib/oe/package.py index 252e32d1df..faa0ab2edb 100644 --- a/meta/lib/oe/package.py +++ b/meta/lib/oe/package.py @@ -8,7 +8,7 @@ def runstrip(arg): # 8 - shared library # 16 - kernel module - import commands, stat, subprocess + import stat, subprocess (file, elftype, strip) = arg @@ -64,8 +64,8 @@ def filedeprunner(arg): def process_deps(pipe, pkg, pkgdest, provides, requires): for line in pipe: - f = line.split(" ", 1)[0].strip() - line = line.split(" ", 1)[1].strip() + f = line.decode("utf-8").split(" ", 1)[0].strip() + line = line.decode("utf-8").split(" ", 1)[1].strip() if line.startswith("Requires:"): i = requires diff --git a/meta/lib/oe/package_manager.py b/meta/lib/oe/package_manager.py index 1eedeb8526..0ea17f8153 100644 --- a/meta/lib/oe/package_manager.py +++ b/meta/lib/oe/package_manager.py @@ -17,7 +17,7 @@ def create_index(arg): try: bb.note("Executing '%s' ..." % index_cmd) - result = subprocess.check_output(index_cmd, stderr=subprocess.STDOUT, shell=True) + result = subprocess.check_output(index_cmd, stderr=subprocess.STDOUT, shell=True).decode("utf-8") except subprocess.CalledProcessError as e: return("Index creation command '%s' failed with return code %d:\n%s" % (e.cmd, e.returncode, e.output)) @@ -89,9 +89,7 @@ def opkg_query(cmd_output): return output -class Indexer(object): - __metaclass__ = ABCMeta - +class Indexer(object, metaclass=ABCMeta): def __init__(self, d, deploy_dir): self.d = d self.deploy_dir = deploy_dir @@ -342,9 +340,7 @@ class DpkgIndexer(Indexer): -class PkgsList(object): - __metaclass__ = ABCMeta - +class PkgsList(object, metaclass=ABCMeta): def __init__(self, d, rootfs_dir): self.d = d self.rootfs_dir = rootfs_dir @@ -367,7 +363,7 @@ class RpmPkgsList(PkgsList): # Determine rpm version cmd = "%s --version" % self.rpm_cmd try: - output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) + output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).decode("utf-8") except subprocess.CalledProcessError as e: bb.fatal("Getting rpm version failed. Command '%s' " "returned %d:\n%s" % (cmd, e.returncode, e.output)) @@ -411,7 +407,7 @@ class RpmPkgsList(PkgsList): "-t", self.image_rpmlib] try: - output = subprocess.check_output(cmd, stderr=subprocess.STDOUT).strip() + output = subprocess.check_output(cmd, stderr=subprocess.STDOUT).strip().decode("utf-8") except subprocess.CalledProcessError as e: bb.fatal("Cannot get the package dependencies. Command '%s' " "returned %d:\n%s" % (' '.join(cmd), e.returncode, e.output)) @@ -425,7 +421,7 @@ class RpmPkgsList(PkgsList): try: # bb.note(cmd) - tmp_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).strip() + tmp_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).strip().decode("utf-8") except subprocess.CalledProcessError as e: bb.fatal("Cannot get the installed packages list. Command '%s' " "returned %d:\n%s" % (cmd, e.returncode, e.output)) @@ -485,6 +481,8 @@ class OpkgPkgsList(PkgsList): # output streams separately and check for empty stderr. p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) cmd_output, cmd_stderr = p.communicate() + cmd_output = cmd_output.decode("utf-8") + cmd_stderr = cmd_stderr.decode("utf-8") if p.returncode or cmd_stderr: bb.fatal("Cannot get the installed packages list. Command '%s' " "returned %d and stderr:\n%s" % (cmd, p.returncode, cmd_stderr)) @@ -502,7 +500,7 @@ class DpkgPkgsList(PkgsList): cmd.append("-f=Package: ${Package}\nArchitecture: ${PackageArch}\nVersion: ${Version}\nFile: ${Package}_${Version}_${Architecture}.deb\nDepends: ${Depends}\nRecommends: ${Recommends}\n\n") try: - cmd_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT).strip() + cmd_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT).strip().decode("utf-8") except subprocess.CalledProcessError as e: bb.fatal("Cannot get the installed packages list. Command '%s' " "returned %d:\n%s" % (' '.join(cmd), e.returncode, e.output)) @@ -510,11 +508,10 @@ class DpkgPkgsList(PkgsList): return opkg_query(cmd_output) -class PackageManager(object): +class PackageManager(object, metaclass=ABCMeta): """ This is an abstract class. Do not instantiate this directly. """ - __metaclass__ = ABCMeta def __init__(self, d): self.d = d @@ -608,7 +605,7 @@ class PackageManager(object): try: bb.note("Installing complementary packages ...") bb.note('Running %s' % cmd) - complementary_pkgs = subprocess.check_output(cmd, stderr=subprocess.STDOUT) + complementary_pkgs = subprocess.check_output(cmd, stderr=subprocess.STDOUT).decode("utf-8") except subprocess.CalledProcessError as e: bb.fatal("Could not compute complementary packages list. Command " "'%s' returned %d:\n%s" % @@ -641,8 +638,8 @@ class PackageManager(object): def construct_uris(self, uris, base_paths): def _append(arr1, arr2, sep='/'): res = [] - narr1 = map(lambda a: string.rstrip(a, sep), arr1) - narr2 = map(lambda a: string.lstrip(string.rstrip(a, sep), sep), arr2) + narr1 = [string.rstrip(a, sep) for a in arr1] + narr2 = [string.lstrip(string.rstrip(a, sep), sep) for a in arr2] for a1 in narr1: if arr2: for a2 in narr2: @@ -784,7 +781,7 @@ class RpmPM(PackageManager): try: complementary_pkgs = subprocess.check_output(cmd, stderr=subprocess.STDOUT, - shell=True) + shell=True).decode("utf-8") # bb.note(complementary_pkgs) return complementary_pkgs except subprocess.CalledProcessError as e: @@ -808,7 +805,7 @@ class RpmPM(PackageManager): (self.smart_cmd, self.smart_opt, pkg) cmd += " | sed -ne 's/ *Provides://p'" bb.note('cmd: %s' % cmd) - output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) + output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).decode("utf-8") # Found a provider if output: bb.note('Found providers for %s: %s' % (pkg, output)) @@ -1091,7 +1088,7 @@ class RpmPM(PackageManager): open(self.scriptlet_wrapper, 'w+').write(scriptlet_content) bb.note("Note: configuring RPM cross-install scriptlet_wrapper") - os.chmod(self.scriptlet_wrapper, 0755) + os.chmod(self.scriptlet_wrapper, 0o755) cmd = 'config --set rpm-extra-macros._cross_scriptlet_wrapper=%s' % \ self.scriptlet_wrapper self._invoke_smart(cmd) @@ -1109,7 +1106,7 @@ class RpmPM(PackageManager): sub_rdep = sub_data.get("RDEPENDS_" + pkg) if not sub_rdep: continue - done = bb.utils.explode_dep_versions2(sub_rdep).keys() + done = list(bb.utils.explode_dep_versions2(sub_rdep).keys()) next = done # Find all the rdepends on dependency chain while next: @@ -1203,7 +1200,7 @@ class RpmPM(PackageManager): cmd = "%s %s install --attempt -y %s" % \ (self.smart_cmd, self.smart_opt, ' '.join(pkgs)) try: - output = subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT) + output = subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT).decode("utf-8") bb.note(output) except subprocess.CalledProcessError as e: bb.fatal("Unable to install packages. Command '%s' " @@ -1233,7 +1230,7 @@ class RpmPM(PackageManager): try: bb.note(cmd) - output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) + output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).decode("utf-8") bb.note(output) except subprocess.CalledProcessError as e: bb.note("Unable to remove packages. Command '%s' " @@ -1379,9 +1376,9 @@ class RpmPM(PackageManager): try: bb.note(cmd) - output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).strip() + output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).strip().decode("utf-8") bb.note(output) - os.chmod(saved_dir, 0755) + os.chmod(saved_dir, 0o755) except subprocess.CalledProcessError as e: bb.fatal("Invoke save_rpmpostinst failed. Command '%s' " "returned %d:\n%s" % (cmd, e.returncode, e.output)) @@ -1753,7 +1750,7 @@ class OpkgPM(OpkgDpkgPM): try: bb.note("Installing the following packages: %s" % ' '.join(pkgs)) bb.note(cmd) - output = subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT) + output = subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT).decode("utf-8") bb.note(output) except subprocess.CalledProcessError as e: (bb.fatal, bb.note)[attempt_only]("Unable to install packages. " @@ -1770,7 +1767,7 @@ class OpkgPM(OpkgDpkgPM): try: bb.note(cmd) - output = subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT) + output = subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT).decode("utf-8") bb.note(output) except subprocess.CalledProcessError as e: bb.fatal("Unable to remove packages. Command '%s' " @@ -1817,7 +1814,7 @@ class OpkgPM(OpkgDpkgPM): pkg_info = cmd + pkg try: - output = subprocess.check_output(pkg_info.split(), stderr=subprocess.STDOUT).strip() + output = subprocess.check_output(pkg_info.split(), stderr=subprocess.STDOUT).strip().decode("utf-8") except subprocess.CalledProcessError as e: bb.fatal("Cannot get package info. Command '%s' " "returned %d:\n%s" % (pkg_info, e.returncode, e.output)) diff --git a/meta/lib/oe/packagedata.py b/meta/lib/oe/packagedata.py index bc0fd06bce..21d4de914f 100644 --- a/meta/lib/oe/packagedata.py +++ b/meta/lib/oe/packagedata.py @@ -8,7 +8,7 @@ def read_pkgdatafile(fn): pkgdata = {} def decode(str): - c = codecs.getdecoder("string_escape") + c = codecs.getdecoder("unicode_escape") return c(str)[0] if os.access(fn, os.R_OK): @@ -66,7 +66,7 @@ def _pkgmap(d): bb.warn("No files in %s?" % pkgdatadir) files = [] - for pn in filter(lambda f: not os.path.isdir(os.path.join(pkgdatadir, f)), files): + for pn in [f for f in files if not os.path.isdir(os.path.join(pkgdatadir, f))]: try: pkgdata = read_pkgdatafile(os.path.join(pkgdatadir, pn)) except OSError: diff --git a/meta/lib/oe/packagegroup.py b/meta/lib/oe/packagegroup.py index a6fee5f950..97819279b7 100644 --- a/meta/lib/oe/packagegroup.py +++ b/meta/lib/oe/packagegroup.py @@ -16,11 +16,11 @@ def packages(features, d): yield pkg def required_packages(features, d): - req = filter(lambda feature: not is_optional(feature, d), features) + req = [feature for feature in features if not is_optional(feature, d)] return packages(req, d) def optional_packages(features, d): - opt = filter(lambda feature: is_optional(feature, d), features) + opt = [feature for feature in features if is_optional(feature, d)] return packages(opt, d) def active_packages(features, d): diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py index add41045f3..a25fd527f6 100644 --- a/meta/lib/oe/patch.py +++ b/meta/lib/oe/patch.py @@ -434,7 +434,7 @@ class GitApplyTree(PatchTree): # change other places which read it back f.write('echo >> $1\n') f.write('echo "%s: $PATCHFILE" >> $1\n' % GitApplyTree.patch_line_prefix) - os.chmod(commithook, 0755) + os.chmod(commithook, 0o755) shutil.copy2(commithook, applyhook) try: patchfilevar = 'PATCHFILE="%s"' % os.path.basename(patch['file']) @@ -672,7 +672,7 @@ class UserResolver(Resolver): f.write("echo 'Run \"quilt refresh\" when patch is corrected, press CTRL+D to exit.'\n") f.write("echo ''\n") f.write(" ".join(patchcmd) + "\n") - os.chmod(rcfile, 00775) + os.chmod(rcfile, 0o775) self.terminal("bash --rcfile " + rcfile, 'Patch Rejects: Please fix patch rejects manually', self.patchset.d) diff --git a/meta/lib/oe/prservice.py b/meta/lib/oe/prservice.py index b0cbcb1fbc..0054f954cc 100644 --- a/meta/lib/oe/prservice.py +++ b/meta/lib/oe/prservice.py @@ -1,7 +1,7 @@ def prserv_make_conn(d, check = False): import prserv.serv - host_params = filter(None, (d.getVar("PRSERV_HOST", True) or '').split(':')) + host_params = list([_f for _f in (d.getVar("PRSERV_HOST", True) or '').split(':') if _f]) try: conn = None conn = prserv.serv.PRServerConnection(host_params[0], int(host_params[1])) @@ -9,7 +9,7 @@ def prserv_make_conn(d, check = False): if not conn.ping(): raise Exception('service not available') d.setVar("__PRSERV_CONN",conn) - except Exception, exc: + except Exception as exc: bb.fatal("Connecting to PR service %s:%s failed: %s" % (host_params[0], host_params[1], str(exc))) return conn @@ -114,7 +114,7 @@ def prserv_export_tofile(d, metainfo, datainfo, lockdown, nomax=False): bb.utils.unlockfile(lf) def prserv_check_avail(d): - host_params = filter(None, (d.getVar("PRSERV_HOST", True) or '').split(':')) + host_params = list([_f for _f in (d.getVar("PRSERV_HOST", True) or '').split(':') if _f]) try: if len(host_params) != 2: raise TypeError diff --git a/meta/lib/oe/qa.py b/meta/lib/oe/qa.py index 3cfeee737b..ff0c87a383 100644 --- a/meta/lib/oe/qa.py +++ b/meta/lib/oe/qa.py @@ -43,17 +43,17 @@ class ELFFile: if not os.path.isfile(self.name): raise NotELFFileError("%s is not a normal file" % self.name) - self.file = file(self.name, "r") - # Read 4k which should cover most of the headers we're after - self.data = self.file.read(4096) + with open(self.name, "rb") as f: + # Read 4k which should cover most of the headers we're after + self.data = f.read(4096) if len(self.data) < ELFFile.EI_NIDENT + 4: raise NotELFFileError("%s is not an ELF" % self.name) self.my_assert(self.data[0], chr(0x7f) ) - self.my_assert(self.data[1], 'E') - self.my_assert(self.data[2], 'L') - self.my_assert(self.data[3], 'F') + self.my_assert(self.data[1], b'E') + self.my_assert(self.data[2], b'L') + self.my_assert(self.data[3], b'F') if self.bits == 0: if self.data[ELFFile.EI_CLASS] == chr(ELFFile.ELFCLASS32): self.bits = 32 @@ -148,4 +148,4 @@ if __name__ == "__main__": import sys elf = ELFFile(sys.argv[1]) elf.open() - print elf.isDynamic() + print(elf.isDynamic()) diff --git a/meta/lib/oe/recipeutils.py b/meta/lib/oe/recipeutils.py index 6c7adb5bdb..c183f71d3c 100644 --- a/meta/lib/oe/recipeutils.py +++ b/meta/lib/oe/recipeutils.py @@ -11,7 +11,7 @@ import os.path import tempfile import textwrap import difflib -import utils +from . import utils import shutil import re import fnmatch @@ -318,7 +318,7 @@ def patch_recipe(d, fn, varvalues, patch=False, relpath=''): varfiles = get_var_files(fn, varlist, d) locs = localise_file_vars(fn, varfiles, varlist) patches = [] - for f,v in locs.iteritems(): + for f,v in locs.items(): vals = {k: varvalues[k] for k in v} patchdata = patch_recipe_file(f, vals, patch, relpath) if patch: @@ -536,7 +536,7 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False, bbappendlines = [] if extralines: if isinstance(extralines, dict): - for name, value in extralines.iteritems(): + for name, value in extralines.items(): bbappendlines.append((name, '=', value)) else: # Do our best to split it @@ -550,14 +550,14 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False, raise Exception('Invalid extralines value passed') def popline(varname): - for i in xrange(0, len(bbappendlines)): + for i in range(0, len(bbappendlines)): if bbappendlines[i][0] == varname: line = bbappendlines.pop(i) return line return None def appendline(varname, op, value): - for i in xrange(0, len(bbappendlines)): + for i in range(0, len(bbappendlines)): item = bbappendlines[i] if item[0] == varname: bbappendlines[i] = (item[0], item[1], item[2] + ' ' + value) @@ -576,7 +576,7 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False, copyfiles = {} if srcfiles: instfunclines = [] - for newfile, origsrcfile in srcfiles.iteritems(): + for newfile, origsrcfile in srcfiles.items(): srcfile = origsrcfile srcurientry = None if not srcfile: @@ -644,7 +644,7 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False, if removevar in removevalues: remove = removevalues[removevar] - if isinstance(remove, basestring): + if isinstance(remove, str): if remove in splitval: splitval.remove(remove) changed = True @@ -674,7 +674,7 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False, varnames = [item[0] for item in bbappendlines] if removevalues: - varnames.extend(removevalues.keys()) + varnames.extend(list(removevalues.keys())) with open(appendpath, 'r') as f: (updated, newlines) = bb.utils.edit_metadata(f, varnames, appendfile_varfunc) @@ -699,7 +699,7 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False, if copyfiles: if machine: destsubdir = os.path.join(destsubdir, machine) - for newfile, srcfile in copyfiles.iteritems(): + for newfile, srcfile in copyfiles.items(): filedest = os.path.join(appenddir, destsubdir, os.path.basename(srcfile)) if os.path.abspath(newfile) != os.path.abspath(filedest): bb.note('Copying %s to %s' % (newfile, filedest)) @@ -725,12 +725,12 @@ def replace_dir_vars(path, d): """Replace common directory paths with appropriate variable references (e.g. /etc becomes ${sysconfdir})""" dirvars = {} # Sort by length so we get the variables we're interested in first - for var in sorted(d.keys(), key=len): + for var in sorted(list(d.keys()), key=len): if var.endswith('dir') and var.lower() == var: value = d.getVar(var, True) if value.startswith('/') and not '\n' in value and value not in dirvars: dirvars[value] = var - for dirpath in sorted(dirvars.keys(), reverse=True): + for dirpath in sorted(list(dirvars.keys()), reverse=True): path = path.replace(dirpath, '${%s}' % dirvars[dirpath]) return path diff --git a/meta/lib/oe/rootfs.py b/meta/lib/oe/rootfs.py index 95fd3ab7f1..528f50c0df 100644 --- a/meta/lib/oe/rootfs.py +++ b/meta/lib/oe/rootfs.py @@ -10,11 +10,10 @@ import subprocess import re -class Rootfs(object): +class Rootfs(object, metaclass=ABCMeta): """ This is an abstract class. Do not instantiate this directly. """ - __metaclass__ = ABCMeta def __init__(self, d): self.d = d @@ -51,8 +50,8 @@ class Rootfs(object): m = r.search(line) if m: bb.warn('[log_check] %s: found a warning message in the logfile (keyword \'%s\'):\n[log_check] %s' - % (self.d.getVar('PN', True), m.group(), line)) - + % (self.d.getVar('PN', True), m.group(), line)) + def _log_check_error(self): r = re.compile(self.log_check_regex) log_path = self.d.expand("${T}/log.do_rootfs") @@ -77,7 +76,7 @@ class Rootfs(object): found_error = 1 bb.warn('[log_check] In line: [%s]' % line) bb.warn('[log_check] %s: found an error message in the logfile (keyword \'%s\'):\n[log_check] %s' - % (self.d.getVar('PN', True), m.group(), line)) + % (self.d.getVar('PN', True), m.group(), line)) if found_error >= 1 and found_error <= 5: message += line + '\n' @@ -485,7 +484,7 @@ class RpmRootfs(Rootfs): continue # sh -x may emit code which isn't actually executed if line.startswith('+'): - continue + continue m = r.search(line) if m: @@ -565,7 +564,7 @@ class DpkgOpkgRootfs(Rootfs): pkg_depends = m_depends.group(1) # remove package dependencies not in postinsts - pkg_names = pkgs.keys() + pkg_names = list(pkgs.keys()) for pkg_name in pkg_names: deps = pkgs[pkg_name][:] @@ -598,7 +597,7 @@ class DpkgOpkgRootfs(Rootfs): pkgs = self._get_pkgs_postinsts(status_file) if pkgs: root = "__packagegroup_postinst__" - pkgs[root] = pkgs.keys() + pkgs[root] = list(pkgs.keys()) _dep_resolve(pkgs, root, pkg_list, []) pkg_list.remove(root) diff --git a/meta/lib/oe/sdk.py b/meta/lib/oe/sdk.py index f1bbef6f58..c74525f929 100644 --- a/meta/lib/oe/sdk.py +++ b/meta/lib/oe/sdk.py @@ -8,9 +8,7 @@ import glob import traceback -class Sdk(object): - __metaclass__ = ABCMeta - +class Sdk(object, metaclass=ABCMeta): def __init__(self, d, manifest_dir): self.d = d self.sdk_output = self.d.getVar('SDK_OUTPUT', True) @@ -251,12 +249,12 @@ class OpkgSdk(Sdk): self.mkdirhier(target_sysconfdir) shutil.copy(self.target_conf, target_sysconfdir) os.chmod(os.path.join(target_sysconfdir, - os.path.basename(self.target_conf)), 0644) + os.path.basename(self.target_conf)), 0o644) self.mkdirhier(host_sysconfdir) shutil.copy(self.host_conf, host_sysconfdir) os.chmod(os.path.join(host_sysconfdir, - os.path.basename(self.host_conf)), 0644) + os.path.basename(self.host_conf)), 0o644) native_opkg_state_dir = os.path.join(self.sdk_output, self.sdk_native_path, self.d.getVar('localstatedir_nativesdk', True).strip('/'), diff --git a/meta/lib/oe/sstatesig.py b/meta/lib/oe/sstatesig.py index 01dce660cf..a58f03a342 100644 --- a/meta/lib/oe/sstatesig.py +++ b/meta/lib/oe/sstatesig.py @@ -210,7 +210,7 @@ class SignatureGeneratorOEBasicHash(bb.siggen.SignatureGeneratorBasicHash): continue f.write(" " + self.lockedpnmap[fn] + ":" + task + ":" + self.taskhash[k] + " \\\n") f.write(' "\n') - f.write('SIGGEN_LOCKEDSIGS_TYPES_%s = "%s"' % (self.machine, " ".join(types.keys()))) + f.write('SIGGEN_LOCKEDSIGS_TYPES_%s = "%s"' % (self.machine, " ".join(list(types.keys())))) def checkhashes(self, missed, ret, sq_fn, sq_task, sq_hash, sq_hashfn, d): warn_msgs = [] @@ -220,7 +220,7 @@ class SignatureGeneratorOEBasicHash(bb.siggen.SignatureGeneratorBasicHash): for task in range(len(sq_fn)): if task not in ret: for pn in self.lockedsigs: - if sq_hash[task] in self.lockedsigs[pn].itervalues(): + if sq_hash[task] in iter(self.lockedsigs[pn].values()): if sq_task[task] == 'do_shared_workdir': continue sstate_missing_msgs.append("Locked sig is set for %s:%s (%s) yet not in sstate cache?" diff --git a/meta/lib/oe/terminal.py b/meta/lib/oe/terminal.py index 634daa9033..dc25d14ff6 100644 --- a/meta/lib/oe/terminal.py +++ b/meta/lib/oe/terminal.py @@ -25,9 +25,7 @@ class Registry(oe.classutils.ClassRegistry): return bool(cls.command) -class Terminal(Popen): - __metaclass__ = Registry - +class Terminal(Popen, metaclass=Registry): def __init__(self, sh_cmd, title=None, env=None, d=None): fmt_sh_cmd = self.format_command(sh_cmd, title) try: @@ -41,7 +39,7 @@ class Terminal(Popen): def format_command(self, sh_cmd, title): fmt = {'title': title or 'Terminal', 'command': sh_cmd} - if isinstance(self.command, basestring): + if isinstance(self.command, str): return shlex.split(self.command.format(**fmt)) else: return [element.format(**fmt) for element in self.command] diff --git a/meta/lib/oe/tests/test_path.py b/meta/lib/oe/tests/test_path.py index 3d41ce157a..5aa024d393 100644 --- a/meta/lib/oe/tests/test_path.py +++ b/meta/lib/oe/tests/test_path.py @@ -85,5 +85,5 @@ class TestRealPath(unittest.TestCase): def test_loop(self): for e in self.EXCEPTIONS: - self.assertRaisesRegexp(OSError, r'\[Errno %u\]' % e[1], + self.assertRaisesRegex(OSError, r'\[Errno %u\]' % e[1], self.__realpath, e[0], False, False) diff --git a/meta/lib/oe/types.py b/meta/lib/oe/types.py index 7f47c17d0e..4ae58acfac 100644 --- a/meta/lib/oe/types.py +++ b/meta/lib/oe/types.py @@ -33,7 +33,7 @@ def choice(value, choices): Acts as a multiple choice for the user. To use this, set the variable type flag to 'choice', and set the 'choices' flag to a space separated list of valid values.""" - if not isinstance(value, basestring): + if not isinstance(value, str): raise TypeError("choice accepts a string, not '%s'" % type(value)) value = value.lower() @@ -106,7 +106,7 @@ def boolean(value): Valid values for false: 'no', 'n', 'false', 'f', '0' """ - if not isinstance(value, basestring): + if not isinstance(value, str): raise TypeError("boolean accepts a string, not '%s'" % type(value)) value = value.lower() diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py index 30d30629f1..cecddc657f 100644 --- a/meta/lib/oe/utils.py +++ b/meta/lib/oe/utils.py @@ -46,7 +46,7 @@ def both_contain(variable1, variable2, checkvalue, d): val2 = d.getVar(variable2, True) val1 = set(val1.split()) val2 = set(val2.split()) - if isinstance(checkvalue, basestring): + if isinstance(checkvalue, str): checkvalue = set(checkvalue.split()) else: checkvalue = set(checkvalue) @@ -85,11 +85,11 @@ def prune_suffix(var, suffixes, d): def str_filter(f, str, d): from re import match - return " ".join(filter(lambda x: match(f, x, 0), str.split())) + return " ".join([x for x in str.split() if match(f, x, 0)]) def str_filter_out(f, str, d): from re import match - return " ".join(filter(lambda x: not match(f, x, 0), str.split())) + return " ".join([x for x in str.split() if not match(f, x, 0)]) def param_bool(cfg, field, dflt = None): """Lookup in map and convert it to a boolean; take @@ -134,7 +134,7 @@ def packages_filter_out_system(d): PN-dbg PN-doc PN-locale-eb-gb removed. """ pn = d.getVar('PN', True) - blacklist = map(lambda suffix: pn + suffix, ('', '-dbg', '-dev', '-doc', '-locale', '-staticdev')) + blacklist = [pn + suffix for suffix in ('', '-dbg', '-dev', '-doc', '-locale', '-staticdev')] localepkg = pn + "-locale-" pkgs = [] @@ -235,7 +235,7 @@ def format_pkg_list(pkg_dict, ret_format=None): # so implement a version here # -from Queue import Queue +from queue import Queue from threading import Thread class ThreadedWorker(Thread): @@ -249,7 +249,7 @@ class ThreadedWorker(Thread): self.worker_end = worker_end def run(self): - from Queue import Empty + from queue import Empty if self.worker_init is not None: self.worker_init(self) @@ -264,8 +264,8 @@ class ThreadedWorker(Thread): try: func(self, *args, **kargs) - except Exception, e: - print e + except Exception as e: + print(e) finally: self.tasks.task_done() diff --git a/meta/lib/oeqa/controllers/masterimage.py b/meta/lib/oeqa/controllers/masterimage.py index 522f9ebd76..4cb75539ee 100644 --- a/meta/lib/oeqa/controllers/masterimage.py +++ b/meta/lib/oeqa/controllers/masterimage.py @@ -24,9 +24,7 @@ from oeqa.utils import CommandError from abc import ABCMeta, abstractmethod -class MasterImageHardwareTarget(oeqa.targetcontrol.BaseTarget): - - __metaclass__ = ABCMeta +class MasterImageHardwareTarget(oeqa.targetcontrol.BaseTarget, metaclass=ABCMeta): supported_image_fstypes = ['tar.gz', 'tar.bz2'] diff --git a/meta/lib/oeqa/oetest.py b/meta/lib/oeqa/oetest.py index 3ed5bb8c2b..869132273f 100644 --- a/meta/lib/oeqa/oetest.py +++ b/meta/lib/oeqa/oetest.py @@ -12,6 +12,7 @@ import unittest import inspect import subprocess import signal +import functools try: import bb except ImportError: @@ -314,7 +315,14 @@ class TestContext(object): for index, suite in enumerate(suites): set_suite_depth(suite) suite.index = index - suites.sort(cmp=lambda a,b: cmp((a.depth, a.index), (b.depth, b.index))) + + def cmp(a, b): + return (a > b) - (a < b) + + def cmpfunc(a, b): + return cmp((a.depth, a.index), (b.depth, b.index)) + + suites.sort(key=functools.cmp_to_key(cmpfunc)) self.suite = testloader.suiteClass(suites) diff --git a/meta/lib/oeqa/runtime/files/test.py b/meta/lib/oeqa/runtime/files/test.py index f3a2273c52..f389225d72 100644 --- a/meta/lib/oeqa/runtime/files/test.py +++ b/meta/lib/oeqa/runtime/files/test.py @@ -3,4 +3,4 @@ import os os.system('touch /tmp/testfile.python') a = 9.01e+21 - 9.01e+21 + 0.01 -print "the value of a is %s" % a +print("the value of a is %s" % a) diff --git a/meta/lib/oeqa/runtime/parselogs.py b/meta/lib/oeqa/runtime/parselogs.py index a93660131d..242cd8cdd5 100644 --- a/meta/lib/oeqa/runtime/parselogs.py +++ b/meta/lib/oeqa/runtime/parselogs.py @@ -238,7 +238,7 @@ class ParseLogsTest(oeRuntimeTest): result = None thegrep = self.build_grepcmd(errors, ignore_errors, log) try: - result = subprocess.check_output(thegrep, shell=True) + result = subprocess.check_output(thegrep, shell=True).decode("utf-8") except: pass if (result is not None): @@ -246,7 +246,7 @@ class ParseLogsTest(oeRuntimeTest): rez = result.splitlines() for xrez in rez: try: - grep_output = subprocess.check_output(['grep', '-F', xrez, '-B', str(lines_before), '-A', str(lines_after), log]) + grep_output = subprocess.check_output(['grep', '-F', xrez, '-B', str(lines_before), '-A', str(lines_after), log]).decode("utf-8") except: pass results[log.replace('target_logs/','')][xrez]=grep_output diff --git a/meta/lib/oeqa/runtime/ping.py b/meta/lib/oeqa/runtime/ping.py index 80c460161b..0f27447926 100644 --- a/meta/lib/oeqa/runtime/ping.py +++ b/meta/lib/oeqa/runtime/ping.py @@ -14,7 +14,7 @@ class PingTest(oeRuntimeTest): endtime = time.time() + 60 while count < 5 and time.time() < endtime: proc = subprocess.Popen("ping -c 1 %s" % self.target.ip, shell=True, stdout=subprocess.PIPE) - output += proc.communicate()[0] + output += proc.communicate()[0].decode("utf-8") if proc.poll() == 0: count += 1 else: diff --git a/meta/lib/oeqa/runtime/systemd.py b/meta/lib/oeqa/runtime/systemd.py index 2b2f10d71c..a96efa28dc 100644 --- a/meta/lib/oeqa/runtime/systemd.py +++ b/meta/lib/oeqa/runtime/systemd.py @@ -153,7 +153,7 @@ class SystemdJournalTests(SystemdTest): if check_match: break # put the startup time in the test log if check_match: - print "%s" % check_match + print("%s" % check_match) else: self.skipTest("Error at obtaining the boot time from journalctl") boot_time_sec = 0 @@ -174,5 +174,5 @@ class SystemdJournalTests(SystemdTest): self.skipTest("Error when parsing time from boot string") #Assert the target boot time against systemd's unit start timeout if boot_time_sec > systemd_TimeoutStartSec: - print "Target boot time %s exceeds systemd's TimeoutStartSec %s"\ - %(boot_time_sec, systemd_TimeoutStartSec) + print("Target boot time %s exceeds systemd's TimeoutStartSec %s"\ + %(boot_time_sec, systemd_TimeoutStartSec)) diff --git a/meta/lib/oeqa/selftest/_toaster.py b/meta/lib/oeqa/selftest/_toaster.py index c424659fdc..15ea9df9ef 100644 --- a/meta/lib/oeqa/selftest/_toaster.py +++ b/meta/lib/oeqa/selftest/_toaster.py @@ -2,7 +2,7 @@ import unittest import os import sys import shlex, subprocess -import urllib, commands, time, getpass, re, json, shlex +import urllib.request, urllib.parse, urllib.error, subprocess, time, getpass, re, json, shlex import oeqa.utils.ftools as ftools from oeqa.selftest.base import oeSelfTest @@ -290,7 +290,7 @@ class Toaster_DB_Tests(ToasterSetup): layers = Layer.objects.values('id', 'layer_index_url') cnt_err = [] for layer in layers: - resp = urllib.urlopen(layer['layer_index_url']) + resp = urllib.request.urlopen(layer['layer_index_url']) if (resp.getcode() != 200): cnt_err.append(layer['id']) self.assertEqual(len(cnt_err), 0, msg = 'Errors for layer id: %s' % cnt_err) diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py index 132a73d0ec..d0421e7177 100644 --- a/meta/lib/oeqa/selftest/devtool.py +++ b/meta/lib/oeqa/selftest/devtool.py @@ -50,7 +50,7 @@ class DevtoolBase(oeSelfTest): missingvars = {} - for var, value in checkvars.iteritems(): + for var, value in checkvars.items(): if value is not None: missingvars[var] = value self.assertEqual(missingvars, {}, 'Some expected variables not found in recipe: %s' % checkvars) diff --git a/meta/lib/oeqa/selftest/pkgdata.py b/meta/lib/oeqa/selftest/pkgdata.py index 138b03aadb..5a63f89ff2 100644 --- a/meta/lib/oeqa/selftest/pkgdata.py +++ b/meta/lib/oeqa/selftest/pkgdata.py @@ -131,15 +131,15 @@ class OePkgdataUtilTests(oeSelfTest): # Test recipe-space package name result = runCmd('oe-pkgdata-util list-pkg-files zlib-dev zlib-doc') files = splitoutput(result.output) - self.assertIn('zlib-dev', files.keys(), "listed pkgs. files: %s" %result.output) - self.assertIn('zlib-doc', files.keys(), "listed pkgs. files: %s" %result.output) + self.assertIn('zlib-dev', list(files.keys()), "listed pkgs. files: %s" %result.output) + self.assertIn('zlib-doc', list(files.keys()), "listed pkgs. files: %s" %result.output) self.assertIn(os.path.join(includedir, 'zlib.h'), files['zlib-dev']) self.assertIn(os.path.join(mandir, 'man3/zlib.3'), files['zlib-doc']) # Test runtime package name result = runCmd('oe-pkgdata-util list-pkg-files -r libz1 libz-dev') files = splitoutput(result.output) - self.assertIn('libz1', files.keys(), "listed pkgs. files: %s" %result.output) - self.assertIn('libz-dev', files.keys(), "listed pkgs. files: %s" %result.output) + self.assertIn('libz1', list(files.keys()), "listed pkgs. files: %s" %result.output) + self.assertIn('libz-dev', list(files.keys()), "listed pkgs. files: %s" %result.output) self.assertGreater(len(files['libz1']), 1) libspec = os.path.join(base_libdir, 'libz.so.1.*') found = False @@ -152,12 +152,12 @@ class OePkgdataUtilTests(oeSelfTest): # Test recipe result = runCmd('oe-pkgdata-util list-pkg-files -p zlib') files = splitoutput(result.output) - self.assertIn('zlib-dbg', files.keys(), "listed pkgs. files: %s" %result.output) - self.assertIn('zlib-doc', files.keys(), "listed pkgs. files: %s" %result.output) - self.assertIn('zlib-dev', files.keys(), "listed pkgs. files: %s" %result.output) - self.assertIn('zlib-staticdev', files.keys(), "listed pkgs. files: %s" %result.output) - self.assertIn('zlib', files.keys(), "listed pkgs. files: %s" %result.output) - self.assertNotIn('zlib-locale', files.keys(), "listed pkgs. files: %s" %result.output) + self.assertIn('zlib-dbg', list(files.keys()), "listed pkgs. files: %s" %result.output) + self.assertIn('zlib-doc', list(files.keys()), "listed pkgs. files: %s" %result.output) + self.assertIn('zlib-dev', list(files.keys()), "listed pkgs. files: %s" %result.output) + self.assertIn('zlib-staticdev', list(files.keys()), "listed pkgs. files: %s" %result.output) + self.assertIn('zlib', list(files.keys()), "listed pkgs. files: %s" %result.output) + self.assertNotIn('zlib-locale', list(files.keys()), "listed pkgs. files: %s" %result.output) # (ignore ptest, might not be there depending on config) self.assertIn(os.path.join(includedir, 'zlib.h'), files['zlib-dev']) self.assertIn(os.path.join(mandir, 'man3/zlib.3'), files['zlib-doc']) @@ -165,36 +165,36 @@ class OePkgdataUtilTests(oeSelfTest): # Test recipe, runtime result = runCmd('oe-pkgdata-util list-pkg-files -p zlib -r') files = splitoutput(result.output) - self.assertIn('libz-dbg', files.keys(), "listed pkgs. files: %s" %result.output) - self.assertIn('libz-doc', files.keys(), "listed pkgs. files: %s" %result.output) - self.assertIn('libz-dev', files.keys(), "listed pkgs. files: %s" %result.output) - self.assertIn('libz-staticdev', files.keys(), "listed pkgs. files: %s" %result.output) - self.assertIn('libz1', files.keys(), "listed pkgs. files: %s" %result.output) - self.assertNotIn('libz-locale', files.keys(), "listed pkgs. files: %s" %result.output) + self.assertIn('libz-dbg', list(files.keys()), "listed pkgs. files: %s" %result.output) + self.assertIn('libz-doc', list(files.keys()), "listed pkgs. files: %s" %result.output) + self.assertIn('libz-dev', list(files.keys()), "listed pkgs. files: %s" %result.output) + self.assertIn('libz-staticdev', list(files.keys()), "listed pkgs. files: %s" %result.output) + self.assertIn('libz1', list(files.keys()), "listed pkgs. files: %s" %result.output) + self.assertNotIn('libz-locale', list(files.keys()), "listed pkgs. files: %s" %result.output) self.assertIn(os.path.join(includedir, 'zlib.h'), files['libz-dev']) self.assertIn(os.path.join(mandir, 'man3/zlib.3'), files['libz-doc']) self.assertIn(os.path.join(libdir, 'libz.a'), files['libz-staticdev']) # Test recipe, unpackaged result = runCmd('oe-pkgdata-util list-pkg-files -p zlib -u') files = splitoutput(result.output) - self.assertIn('zlib-dbg', files.keys(), "listed pkgs. files: %s" %result.output) - self.assertIn('zlib-doc', files.keys(), "listed pkgs. files: %s" %result.output) - self.assertIn('zlib-dev', files.keys(), "listed pkgs. files: %s" %result.output) - self.assertIn('zlib-staticdev', files.keys(), "listed pkgs. files: %s" %result.output) - self.assertIn('zlib', files.keys(), "listed pkgs. files: %s" %result.output) - self.assertIn('zlib-locale', files.keys(), "listed pkgs. files: %s" %result.output) # this is the key one + self.assertIn('zlib-dbg', list(files.keys()), "listed pkgs. files: %s" %result.output) + self.assertIn('zlib-doc', list(files.keys()), "listed pkgs. files: %s" %result.output) + self.assertIn('zlib-dev', list(files.keys()), "listed pkgs. files: %s" %result.output) + self.assertIn('zlib-staticdev', list(files.keys()), "listed pkgs. files: %s" %result.output) + self.assertIn('zlib', list(files.keys()), "listed pkgs. files: %s" %result.output) + self.assertIn('zlib-locale', list(files.keys()), "listed pkgs. files: %s" %result.output) # this is the key one self.assertIn(os.path.join(includedir, 'zlib.h'), files['zlib-dev']) self.assertIn(os.path.join(mandir, 'man3/zlib.3'), files['zlib-doc']) self.assertIn(os.path.join(libdir, 'libz.a'), files['zlib-staticdev']) # Test recipe, runtime, unpackaged result = runCmd('oe-pkgdata-util list-pkg-files -p zlib -r -u') files = splitoutput(result.output) - self.assertIn('libz-dbg', files.keys(), "listed pkgs. files: %s" %result.output) - self.assertIn('libz-doc', files.keys(), "listed pkgs. files: %s" %result.output) - self.assertIn('libz-dev', files.keys(), "listed pkgs. files: %s" %result.output) - self.assertIn('libz-staticdev', files.keys(), "listed pkgs. files: %s" %result.output) - self.assertIn('libz1', files.keys(), "listed pkgs. files: %s" %result.output) - self.assertIn('libz-locale', files.keys(), "listed pkgs. files: %s" %result.output) # this is the key one + self.assertIn('libz-dbg', list(files.keys()), "listed pkgs. files: %s" %result.output) + self.assertIn('libz-doc', list(files.keys()), "listed pkgs. files: %s" %result.output) + self.assertIn('libz-dev', list(files.keys()), "listed pkgs. files: %s" %result.output) + self.assertIn('libz-staticdev', list(files.keys()), "listed pkgs. files: %s" %result.output) + self.assertIn('libz1', list(files.keys()), "listed pkgs. files: %s" %result.output) + self.assertIn('libz-locale', list(files.keys()), "listed pkgs. files: %s" %result.output) # this is the key one self.assertIn(os.path.join(includedir, 'zlib.h'), files['libz-dev']) self.assertIn(os.path.join(mandir, 'man3/zlib.3'), files['libz-doc']) self.assertIn(os.path.join(libdir, 'libz.a'), files['libz-staticdev']) diff --git a/meta/lib/oeqa/selftest/recipetool.py b/meta/lib/oeqa/selftest/recipetool.py index e72911b0aa..a93d18e275 100644 --- a/meta/lib/oeqa/selftest/recipetool.py +++ b/meta/lib/oeqa/selftest/recipetool.py @@ -1,7 +1,7 @@ import os import logging import tempfile -import urlparse +import urllib.parse from oeqa.utils.commands import runCmd, bitbake, get_bb_var, create_temp_layer from oeqa.utils.decorators import testcase @@ -471,7 +471,7 @@ class RecipetoolAppendsrcBase(RecipetoolBase): '''Return the first file:// in SRC_URI for the specified recipe.''' src_uri = get_bb_var('SRC_URI', recipe).split() for uri in src_uri: - p = urlparse.urlparse(uri) + p = urllib.parse.urlparse(uri) if p.scheme == 'file': return p.netloc + p.path diff --git a/meta/lib/oeqa/selftest/sstatetests.py b/meta/lib/oeqa/selftest/sstatetests.py index a1e5d33580..cc64c6cb68 100644 --- a/meta/lib/oeqa/selftest/sstatetests.py +++ b/meta/lib/oeqa/selftest/sstatetests.py @@ -445,14 +445,14 @@ http_proxy = "http://example.com/" files1 = get_files(topdir + "/tmp-sstatesamehash/stamps/") files2 = get_files(topdir + "/tmp-sstatesamehash2/stamps/") # Remove items that are identical in both sets - for k,v in files1.viewitems() & files2.viewitems(): + for k,v in files1.items() & files2.items(): del files1[k] del files2[k] if not files1 and not files2: # No changes, so we're done return - for k in files1.viewkeys() | files2.viewkeys(): + for k in files1.keys() | files2.keys(): if k in files1 and k in files2: print("%s differs:" % k) print(subprocess.check_output(("bitbake-diffsigs", diff --git a/meta/lib/oeqa/targetcontrol.py b/meta/lib/oeqa/targetcontrol.py index 5422a617c4..1c57efaaef 100644 --- a/meta/lib/oeqa/targetcontrol.py +++ b/meta/lib/oeqa/targetcontrol.py @@ -43,9 +43,7 @@ def get_target_controller(d): return controller(d) -class BaseTarget(object): - - __metaclass__ = ABCMeta +class BaseTarget(object, metaclass=ABCMeta): supported_image_fstypes = [] diff --git a/meta/lib/oeqa/utils/commands.py b/meta/lib/oeqa/utils/commands.py index 48f6441290..18fe39ecfe 100644 --- a/meta/lib/oeqa/utils/commands.py +++ b/meta/lib/oeqa/utils/commands.py @@ -41,7 +41,7 @@ class Command(object): self.data = data self.options = dict(self.defaultopts) - if isinstance(self.cmd, basestring): + if isinstance(self.cmd, str): self.options["shell"] = True if self.data: self.options['stdin'] = subprocess.PIPE @@ -78,7 +78,7 @@ class Command(object): self.process.kill() self.thread.join() - self.output = self.output.rstrip() + self.output = self.output.decode("utf-8").rstrip() self.status = self.process.poll() self.log.debug("Command '%s' returned %d as exit code." % (self.cmd, self.status)) @@ -123,7 +123,7 @@ def bitbake(command, ignore_status=False, timeout=None, postconfig=None, **optio else: extra_args = "" - if isinstance(command, basestring): + if isinstance(command, str): cmd = "bitbake " + extra_args + " " + command else: cmd = [ "bitbake" ] + [a for a in (command + extra_args.split(" ")) if a not in [""]] diff --git a/meta/lib/oeqa/utils/decorators.py b/meta/lib/oeqa/utils/decorators.py index d52f326f1a..0b23565485 100644 --- a/meta/lib/oeqa/utils/decorators.py +++ b/meta/lib/oeqa/utils/decorators.py @@ -115,6 +115,8 @@ class NoParsingFilter(logging.Filter): def filter(self, record): return record.levelno == 100 +import inspect + def LogResults(original_class): orig_method = original_class.run @@ -124,6 +126,19 @@ def LogResults(original_class): logfile = os.path.join(os.getcwd(),'results-'+caller+'.'+timestamp+'.log') linkfile = os.path.join(os.getcwd(),'results-'+caller+'.log') + def get_class_that_defined_method(meth): + if inspect.ismethod(meth): + for cls in inspect.getmro(meth.__self__.__class__): + if cls.__dict__.get(meth.__name__) is meth: + return cls + meth = meth.__func__ # fallback to __qualname__ parsing + if inspect.isfunction(meth): + cls = getattr(inspect.getmodule(meth), + meth.__qualname__.split('.', 1)[0].rsplit('.', 1)[0]) + if isinstance(cls, type): + return cls + return None + #rewrite the run method of unittest.TestCase to add testcase logging def run(self, result, *args, **kws): orig_method(self, result, *args, **kws) @@ -135,7 +150,7 @@ def LogResults(original_class): except AttributeError: test_case = self._testMethodName - class_name = str(testMethod.im_class).split("'")[1] + class_name = str(get_class_that_defined_method(testMethod)).split("'")[1] #create custom logging level for filtering. custom_log_level = 100 @@ -215,7 +230,7 @@ def tag(*args, **kwargs): def wrap_ob(ob): for name in args: setattr(ob, __tag_prefix + name, True) - for name, value in kwargs.iteritems(): + for name, value in kwargs.items(): setattr(ob, __tag_prefix + name, value) return ob return wrap_ob diff --git a/meta/lib/oeqa/utils/dump.py b/meta/lib/oeqa/utils/dump.py index 63a591d366..71422a9aea 100644 --- a/meta/lib/oeqa/utils/dump.py +++ b/meta/lib/oeqa/utils/dump.py @@ -3,7 +3,7 @@ import sys import errno import datetime import itertools -from commands import runCmd +from .commands import runCmd def get_host_dumper(d): cmds = d.getVar("testimage_dump_host", True) diff --git a/meta/lib/oeqa/utils/httpserver.py b/meta/lib/oeqa/utils/httpserver.py index 76518d8ef9..bd76f36468 100644 --- a/meta/lib/oeqa/utils/httpserver.py +++ b/meta/lib/oeqa/utils/httpserver.py @@ -1,8 +1,8 @@ -import SimpleHTTPServer +import http.server import multiprocessing import os -class HTTPServer(SimpleHTTPServer.BaseHTTPServer.HTTPServer): +class HTTPServer(http.server.HTTPServer): def server_start(self, root_dir): import signal @@ -10,7 +10,7 @@ class HTTPServer(SimpleHTTPServer.BaseHTTPServer.HTTPServer): os.chdir(root_dir) self.serve_forever() -class HTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): +class HTTPRequestHandler(http.server.SimpleHTTPRequestHandler): def log_message(self, format_str, *args): pass diff --git a/meta/lib/oeqa/utils/logparser.py b/meta/lib/oeqa/utils/logparser.py index 87b50354cd..b377dcd271 100644 --- a/meta/lib/oeqa/utils/logparser.py +++ b/meta/lib/oeqa/utils/logparser.py @@ -3,7 +3,7 @@ import sys import os import re -import ftools +from . import ftools # A parser that can be used to identify weather a line is a test result or a section statement. diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py index 4bede3421c..773cf588b1 100644 --- a/meta/lib/oeqa/utils/qemurunner.py +++ b/meta/lib/oeqa/utils/qemurunner.py @@ -22,9 +22,9 @@ import logging logger = logging.getLogger("BitBake.QemuRunner") # Get Unicode non printable control chars -control_range = range(0,32)+range(127,160) -control_chars = [unichr(x) for x in control_range - if unichr(x) not in string.printable] +control_range = list(range(0,32))+list(range(127,160)) +control_chars = [chr(x) for x in control_range + if chr(x) not in string.printable] re_control_char = re.compile('[%s]' % re.escape("".join(control_chars))) class QemuRunner: @@ -71,7 +71,8 @@ class QemuRunner: if self.logfile: # It is needed to sanitize the data received from qemu # because is possible to have control characters - msg = re_control_char.sub('', unicode(msg, 'utf-8')) + msg = msg.decode("utf-8") + msg = re_control_char.sub('', msg) with codecs.open(self.logfile, "a", encoding="utf-8") as f: f.write("%s" % msg) @@ -79,7 +80,7 @@ class QemuRunner: import fcntl fl = fcntl.fcntl(o, fcntl.F_GETFL) fcntl.fcntl(o, fcntl.F_SETFL, fl | os.O_NONBLOCK) - return os.read(o.fileno(), 1000000) + return os.read(o.fileno(), 1000000).decode("utf-8") def handleSIGCHLD(self, signum, frame): @@ -114,7 +115,7 @@ class QemuRunner: try: threadsock, threadport = self.create_socket() self.server_socket, self.serverport = self.create_socket() - except socket.error, msg: + except socket.error as msg: logger.error("Failed to create listening socket: %s" % msg[1]) return False @@ -192,7 +193,7 @@ class QemuRunner: else: self.ip = ips[0] self.server_ip = ips[1] - except IndexError, ValueError: + except (IndexError, ValueError): logger.info("Couldn't get ip from qemu process arguments! Here is the qemu command line used:\n%s\nand output from runqemu:\n%s" % (cmdline, self.getOutput(output))) self._dump_host() self.stop() @@ -219,6 +220,7 @@ class QemuRunner: stopread = False qemusock = None bootlog = '' + data = b'' while time.time() < endtime and not stopread: sread, swrite, serror = select.select(socklist, [], [], 5) for sock in sread: @@ -229,14 +231,19 @@ class QemuRunner: socklist.remove(self.server_socket) logger.info("Connection from %s:%s" % addr) else: - data = sock.recv(1024) + data = data + sock.recv(1024) if data: - bootlog += data - if re.search(".* login:", bootlog): - self.server_socket = qemusock - stopread = True - reachedlogin = True - logger.info("Reached login banner") + try: + data = data.decode("utf-8") + bootlog += data + data = b'' + if re.search(".* login:", bootlog): + self.server_socket = qemusock + stopread = True + reachedlogin = True + logger.info("Reached login banner") + except UnicodeDecodeError: + continue else: socklist.remove(sock) sock.close() @@ -277,13 +284,14 @@ class QemuRunner: if hasattr(self, "origchldhandler"): signal.signal(signal.SIGCHLD, self.origchldhandler) if self.runqemu: - os.kill(self.monitorpid, signal.SIGKILL) - logger.info("Sending SIGTERM to runqemu") - try: - os.killpg(os.getpgid(self.runqemu.pid), signal.SIGTERM) - except OSError as e: - if e.errno != errno.ESRCH: - raise + if hasattr(self, "monitorpid"): + os.kill(self.monitorpid, signal.SIGKILL) + logger.info("Sending SIGTERM to runqemu") + try: + os.killpg(os.getpgid(self.runqemu.pid), signal.SIGTERM) + except OSError as e: + if e.errno != errno.ESRCH: + raise endtime = time.time() + self.runqemutime while self.runqemu.poll() is None and time.time() < endtime: time.sleep(1) @@ -325,7 +333,7 @@ class QemuRunner: # Walk the process tree from the process specified looking for a qemu-system. Return its [pid'cmd] # ps = subprocess.Popen(['ps', 'axww', '-o', 'pid,ppid,command'], stdout=subprocess.PIPE).communicate()[0] - processes = ps.split('\n') + processes = ps.decode("utf-8").split('\n') nfields = len(processes[0].split()) - 1 pids = {} commands = {} @@ -442,7 +450,7 @@ class LoggingThread(threading.Thread): def stop(self): self.logger.info("Stopping logging thread") if self.running: - os.write(self.writepipe, "stop") + os.write(self.writepipe, bytes("stop", "utf-8")) def teardown(self): self.logger.info("Tearing down logging thread") diff --git a/meta/lib/oeqa/utils/qemutinyrunner.py b/meta/lib/oeqa/utils/qemutinyrunner.py index e3d8c669e0..f733258bce 100644 --- a/meta/lib/oeqa/utils/qemutinyrunner.py +++ b/meta/lib/oeqa/utils/qemutinyrunner.py @@ -13,7 +13,7 @@ import re import socket import select import bb -from qemurunner import QemuRunner +from .qemurunner import QemuRunner class QemuTinyRunner(QemuRunner): @@ -50,7 +50,7 @@ class QemuTinyRunner(QemuRunner): self.server_socket.connect(self.socketfile) bb.note("Created listening socket for qemu serial console.") tries = 0 - except socket.error, msg: + except socket.error as msg: self.server_socket.close() bb.fatal("Failed to create listening socket.") tries -= 1 @@ -102,7 +102,7 @@ class QemuTinyRunner(QemuRunner): bb.note("Qemu pid didn't appeared in %s seconds" % self.runqemutime) output = self.runqemu.stdout self.stop() - bb.note("Output from runqemu:\n%s" % output.read()) + bb.note("Output from runqemu:\n%s" % output.read().decode("utf-8")) return False return self.is_alive() @@ -131,7 +131,7 @@ class QemuTinyRunner(QemuRunner): # Walk the process tree from the process specified looking for a qemu-system. Return its [pid'cmd] # ps = subprocess.Popen(['ps', 'axww', '-o', 'pid,ppid,command'], stdout=subprocess.PIPE).communicate()[0] - processes = ps.split('\n') + processes = ps.decode("utf-8").split('\n') nfields = len(processes[0].split()) - 1 pids = {} commands = {} @@ -167,4 +167,4 @@ class QemuTinyRunner(QemuRunner): basecmd = commands[p].split()[0] basecmd = os.path.basename(basecmd) if "qemu-system" in basecmd and "-serial unix" in commands[p]: - return [int(p),commands[p]] \ No newline at end of file + return [int(p),commands[p]] diff --git a/meta/lib/oeqa/utils/sshcontrol.py b/meta/lib/oeqa/utils/sshcontrol.py index ff88d37bd9..f5d46e03cc 100644 --- a/meta/lib/oeqa/utils/sshcontrol.py +++ b/meta/lib/oeqa/utils/sshcontrol.py @@ -58,6 +58,7 @@ class SSHProcess(object): self.process.stdout.close() eof = True else: + data = data.decode("utf-8") output += data self.log(data) endtime = time.time() + timeout diff --git a/meta/lib/oeqa/utils/targetbuild.py b/meta/lib/oeqa/utils/targetbuild.py index f850d78df1..d538f6b65f 100644 --- a/meta/lib/oeqa/utils/targetbuild.py +++ b/meta/lib/oeqa/utils/targetbuild.py @@ -10,9 +10,7 @@ import bb.utils import subprocess from abc import ABCMeta, abstractmethod -class BuildProject(): - - __metaclass__ = ABCMeta +class BuildProject(metaclass=ABCMeta): def __init__(self, d, uri, foldername=None, tmpdir="/tmp/"): self.d = d diff --git a/meta/lib/oeqa/utils/testexport.py b/meta/lib/oeqa/utils/testexport.py index 4fbf4bdcb3..57be2ca449 100644 --- a/meta/lib/oeqa/utils/testexport.py +++ b/meta/lib/oeqa/utils/testexport.py @@ -6,7 +6,7 @@ import os, re, glob as g, shutil as sh,sys from time import sleep -from commands import runCmd +from .commands import runCmd from difflib import SequenceMatcher as SM try: diff --git a/meta/recipes-devtools/apt/apt-native.inc b/meta/recipes-devtools/apt/apt-native.inc index 27cc9ff0b5..74db4a0a13 100644 --- a/meta/recipes-devtools/apt/apt-native.inc +++ b/meta/recipes-devtools/apt/apt-native.inc @@ -30,7 +30,7 @@ python do_install_config () { outpath = oe.path.join(outdir, 'apt.conf.sample') if not os.path.exists(outpath): - outfile = file(outpath, 'w') + outfile = open(outpath, 'w') outfile.write(data) outfile.close() } diff --git a/meta/recipes-graphics/xorg-xserver/xserver-xorg.inc b/meta/recipes-graphics/xorg-xserver/xserver-xorg.inc index 30307bc86d..fda3c93972 100644 --- a/meta/recipes-graphics/xorg-xserver/xserver-xorg.inc +++ b/meta/recipes-graphics/xorg-xserver/xserver-xorg.inc @@ -168,9 +168,10 @@ python populate_packages_prepend() { } p = subprocess.Popen(args="pkg-config --variable=%s xorg-server" % abis[name], shell=True, env=newenv, stdout=subprocess.PIPE) - output = p.communicate()[0] + stdout, stderr = p.communicate() + output = stdout.decode("latin-1").split(".")[0] mlprefix = d.getVar('MLPREFIX', True) or '' - return "%sxorg-abi-%s-%s" % (mlprefix, name, output.split(".")[0]) + return "%sxorg-abi-%s-%s" % (mlprefix, name, output) pn = d.getVar("PN", True) d.appendVar("RPROVIDES_" + pn, " " + get_abi("input")) diff --git a/scripts/oe-selftest b/scripts/oe-selftest index f621fd7e4e..6422505d8f 100755 --- a/scripts/oe-selftest +++ b/scripts/oe-selftest @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2013 Intel Corporation # @@ -34,6 +34,8 @@ import subprocess import time as t import re import fnmatch +import collections +import imp sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '/lib') import scriptpath @@ -211,7 +213,7 @@ def get_tests_from_module(tmod): try: import importlib modlib = importlib.import_module(tmod) - for mod in vars(modlib).values(): + for mod in list(vars(modlib).values()): if isinstance(mod, type(oeSelfTest)) and issubclass(mod, oeSelfTest) and mod is not oeSelfTest: for test in dir(mod): if test.startswith('test_') and hasattr(vars(mod)[test], '__call__'): @@ -415,7 +417,7 @@ def coverage_report(): # Coverage under version 4 uses coverage.coverage from coverage import coverage as Coverage - import cStringIO as StringIO + import io as StringIO from coverage.misc import CoverageException cov_output = StringIO.StringIO() @@ -492,7 +494,7 @@ def main(): if isinstance(t, type(oeSelfTest)) and issubclass(t, oeSelfTest) and t!=oeSelfTest: print(" --", v) for method in dir(t): - if method.startswith("test_") and callable(vars(t)[method]): + if method.startswith("test_") and isinstance(vars(t)[method], collections.Callable): print(" -- --", method) except (AttributeError, ImportError) as e: -- cgit v1.2.3-54-g00ecf