summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2016-05-20 11:17:05 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-06-02 08:24:00 +0100
commita7309d5790f5dac46e84d3c14959943eb2496fda (patch)
tree48e1fcb886b8ef2974bade09694356f3230fb8a8 /meta/lib
parent297438e965053b2eb56cc8ef3e59465642f10a24 (diff)
downloadpoky-a7309d5790f5dac46e84d3c14959943eb2496fda.tar.gz
classes/lib: Update to use python3 command pipeline decoding
In python3, strings are unicode by default. We need to encode/decode from command pipelines and other places where we interface with the real world using the correct locales. This patch updates various call sites to use the correct encoding/decodings. (From OE-Core rev: bb4685af1bffe17b3aa92a6d21398f38a44ea874) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oe/gpg_sign.py10
-rw-r--r--meta/lib/oe/package.py4
-rw-r--r--meta/lib/oe/package_manager.py88
-rw-r--r--meta/lib/oe/packagedata.py2
-rw-r--r--meta/lib/oeqa/oetest.py4
-rw-r--r--meta/lib/oeqa/runtime/parselogs.py4
-rw-r--r--meta/lib/oeqa/runtime/ping.py2
-rw-r--r--meta/lib/oeqa/utils/commands.py2
-rw-r--r--meta/lib/oeqa/utils/qemurunner.py26
-rw-r--r--meta/lib/oeqa/utils/qemutinyrunner.py4
-rw-r--r--meta/lib/oeqa/utils/sshcontrol.py1
11 files changed, 78 insertions, 69 deletions
diff --git a/meta/lib/oe/gpg_sign.py b/meta/lib/oe/gpg_sign.py
index b83ee86728..a8a478aa95 100644
--- a/meta/lib/oe/gpg_sign.py
+++ b/meta/lib/oe/gpg_sign.py
@@ -24,7 +24,7 @@ class LocalSigner(object):
24 status, output = oe.utils.getstatusoutput(cmd) 24 status, output = oe.utils.getstatusoutput(cmd)
25 if status: 25 if status:
26 raise bb.build.FuncFailed('Failed to export gpg public key (%s): %s' % 26 raise bb.build.FuncFailed('Failed to export gpg public key (%s): %s' %
27 (keyid, output)) 27 (keyid, output.decode("utf-8")))
28 28
29 def sign_rpms(self, files, keyid, passphrase): 29 def sign_rpms(self, files, keyid, passphrase):
30 """Sign RPM files""" 30 """Sign RPM files"""
@@ -39,7 +39,7 @@ class LocalSigner(object):
39 39
40 status, output = oe.utils.getstatusoutput(cmd) 40 status, output = oe.utils.getstatusoutput(cmd)
41 if status: 41 if status:
42 raise bb.build.FuncFailed("Failed to sign RPM packages: %s" % output) 42 raise bb.build.FuncFailed("Failed to sign RPM packages: %s" % output.decode("utf-8"))
43 43
44 def detach_sign(self, input_file, keyid, passphrase_file, passphrase=None, armor=True): 44 def detach_sign(self, input_file, keyid, passphrase_file, passphrase=None, armor=True):
45 """Create a detached signature of a file""" 45 """Create a detached signature of a file"""
@@ -71,11 +71,11 @@ class LocalSigner(object):
71 passphrase = fobj.readline(); 71 passphrase = fobj.readline();
72 72
73 job = subprocess.Popen(cmd, stdin=subprocess.PIPE, stderr=subprocess.PIPE) 73 job = subprocess.Popen(cmd, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
74 (_, stderr) = job.communicate(passphrase) 74 (_, stderr) = job.communicate(passphrase.encode("utf-8"))
75 75
76 if job.returncode: 76 if job.returncode:
77 raise bb.build.FuncFailed("GPG exited with code %d: %s" % 77 raise bb.build.FuncFailed("GPG exited with code %d: %s" %
78 (job.returncode, stderr)) 78 (job.returncode, stderr.decode("utf-8")))
79 79
80 except IOError as e: 80 except IOError as e:
81 bb.error("IO error (%s): %s" % (e.errno, e.strerror)) 81 bb.error("IO error (%s): %s" % (e.errno, e.strerror))
@@ -90,7 +90,7 @@ class LocalSigner(object):
90 """Return the gpg version""" 90 """Return the gpg version"""
91 import subprocess 91 import subprocess
92 try: 92 try:
93 return subprocess.check_output((self.gpg_bin, "--version")).split()[2] 93 return subprocess.check_output((self.gpg_bin, "--version")).split()[2].decode("utf-8")
94 except subprocess.CalledProcessError as e: 94 except subprocess.CalledProcessError as e:
95 raise bb.build.FuncFailed("Could not get gpg version: %s" % e) 95 raise bb.build.FuncFailed("Could not get gpg version: %s" % e)
96 96
diff --git a/meta/lib/oe/package.py b/meta/lib/oe/package.py
index 252e32d1df..5bb15bbc09 100644
--- a/meta/lib/oe/package.py
+++ b/meta/lib/oe/package.py
@@ -64,8 +64,8 @@ def filedeprunner(arg):
64 64
65 def process_deps(pipe, pkg, pkgdest, provides, requires): 65 def process_deps(pipe, pkg, pkgdest, provides, requires):
66 for line in pipe: 66 for line in pipe:
67 f = line.split(" ", 1)[0].strip() 67 f = line.decode("utf-8").split(" ", 1)[0].strip()
68 line = line.split(" ", 1)[1].strip() 68 line = line.decode("utf-8").split(" ", 1)[1].strip()
69 69
70 if line.startswith("Requires:"): 70 if line.startswith("Requires:"):
71 i = requires 71 i = requires
diff --git a/meta/lib/oe/package_manager.py b/meta/lib/oe/package_manager.py
index 3bc4ebf5b4..abe9f6878b 100644
--- a/meta/lib/oe/package_manager.py
+++ b/meta/lib/oe/package_manager.py
@@ -17,10 +17,10 @@ def create_index(arg):
17 17
18 try: 18 try:
19 bb.note("Executing '%s' ..." % index_cmd) 19 bb.note("Executing '%s' ..." % index_cmd)
20 result = subprocess.check_output(index_cmd, stderr=subprocess.STDOUT, shell=True) 20 result = subprocess.check_output(index_cmd, stderr=subprocess.STDOUT, shell=True).decode("utf-8")
21 except subprocess.CalledProcessError as e: 21 except subprocess.CalledProcessError as e:
22 return("Index creation command '%s' failed with return code %d:\n%s" % 22 return("Index creation command '%s' failed with return code %d:\n%s" %
23 (e.cmd, e.returncode, e.output)) 23 (e.cmd, e.returncode, e.output.decode("utf-8")))
24 24
25 if result: 25 if result:
26 bb.note(result) 26 bb.note(result)
@@ -367,10 +367,10 @@ class RpmPkgsList(PkgsList):
367 # Determine rpm version 367 # Determine rpm version
368 cmd = "%s --version" % self.rpm_cmd 368 cmd = "%s --version" % self.rpm_cmd
369 try: 369 try:
370 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) 370 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).decode("utf-8")
371 except subprocess.CalledProcessError as e: 371 except subprocess.CalledProcessError as e:
372 bb.fatal("Getting rpm version failed. Command '%s' " 372 bb.fatal("Getting rpm version failed. Command '%s' "
373 "returned %d:\n%s" % (cmd, e.returncode, e.output)) 373 "returned %d:\n%s" % (cmd, e.returncode, e.output.decode("utf-8")))
374 374
375 ''' 375 '''
376 Translate the RPM/Smart format names to the OE multilib format names 376 Translate the RPM/Smart format names to the OE multilib format names
@@ -411,10 +411,10 @@ class RpmPkgsList(PkgsList):
411 "-t", self.image_rpmlib] 411 "-t", self.image_rpmlib]
412 412
413 try: 413 try:
414 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT).strip() 414 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT).strip().decode("utf-8")
415 except subprocess.CalledProcessError as e: 415 except subprocess.CalledProcessError as e:
416 bb.fatal("Cannot get the package dependencies. Command '%s' " 416 bb.fatal("Cannot get the package dependencies. Command '%s' "
417 "returned %d:\n%s" % (' '.join(cmd), e.returncode, e.output)) 417 "returned %d:\n%s" % (' '.join(cmd), e.returncode, e.output.decode("utf-8")))
418 418
419 return output 419 return output
420 420
@@ -425,10 +425,10 @@ class RpmPkgsList(PkgsList):
425 425
426 try: 426 try:
427 # bb.note(cmd) 427 # bb.note(cmd)
428 tmp_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).strip() 428 tmp_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).strip().decode("utf-8")
429 except subprocess.CalledProcessError as e: 429 except subprocess.CalledProcessError as e:
430 bb.fatal("Cannot get the installed packages list. Command '%s' " 430 bb.fatal("Cannot get the installed packages list. Command '%s' "
431 "returned %d:\n%s" % (cmd, e.returncode, e.output)) 431 "returned %d:\n%s" % (cmd, e.returncode, e.output.decode("utf-8")))
432 432
433 output = dict() 433 output = dict()
434 deps = dict() 434 deps = dict()
@@ -485,6 +485,8 @@ class OpkgPkgsList(PkgsList):
485 # output streams separately and check for empty stderr. 485 # output streams separately and check for empty stderr.
486 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) 486 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
487 cmd_output, cmd_stderr = p.communicate() 487 cmd_output, cmd_stderr = p.communicate()
488 cmd_output = cmd_output.decode("utf-8")
489 cmd_stderr = cmd_stderr.decode("utf-8")
488 if p.returncode or cmd_stderr: 490 if p.returncode or cmd_stderr:
489 bb.fatal("Cannot get the installed packages list. Command '%s' " 491 bb.fatal("Cannot get the installed packages list. Command '%s' "
490 "returned %d and stderr:\n%s" % (cmd, p.returncode, cmd_stderr)) 492 "returned %d and stderr:\n%s" % (cmd, p.returncode, cmd_stderr))
@@ -502,10 +504,10 @@ class DpkgPkgsList(PkgsList):
502 cmd.append("-f=Package: ${Package}\nArchitecture: ${PackageArch}\nVersion: ${Version}\nFile: ${Package}_${Version}_${Architecture}.deb\nDepends: ${Depends}\nRecommends: ${Recommends}\n\n") 504 cmd.append("-f=Package: ${Package}\nArchitecture: ${PackageArch}\nVersion: ${Version}\nFile: ${Package}_${Version}_${Architecture}.deb\nDepends: ${Depends}\nRecommends: ${Recommends}\n\n")
503 505
504 try: 506 try:
505 cmd_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT).strip() 507 cmd_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT).strip().decode("utf-8")
506 except subprocess.CalledProcessError as e: 508 except subprocess.CalledProcessError as e:
507 bb.fatal("Cannot get the installed packages list. Command '%s' " 509 bb.fatal("Cannot get the installed packages list. Command '%s' "
508 "returned %d:\n%s" % (' '.join(cmd), e.returncode, e.output)) 510 "returned %d:\n%s" % (' '.join(cmd), e.returncode, e.output.decode("utf-8")))
509 511
510 return opkg_query(cmd_output) 512 return opkg_query(cmd_output)
511 513
@@ -608,11 +610,11 @@ class PackageManager(object):
608 try: 610 try:
609 bb.note("Installing complementary packages ...") 611 bb.note("Installing complementary packages ...")
610 bb.note('Running %s' % cmd) 612 bb.note('Running %s' % cmd)
611 complementary_pkgs = subprocess.check_output(cmd, stderr=subprocess.STDOUT) 613 complementary_pkgs = subprocess.check_output(cmd, stderr=subprocess.STDOUT).decode("utf-8")
612 except subprocess.CalledProcessError as e: 614 except subprocess.CalledProcessError as e:
613 bb.fatal("Could not compute complementary packages list. Command " 615 bb.fatal("Could not compute complementary packages list. Command "
614 "'%s' returned %d:\n%s" % 616 "'%s' returned %d:\n%s" %
615 (' '.join(cmd), e.returncode, e.output)) 617 (' '.join(cmd), e.returncode, e.output.decode("utf-8")))
616 self.install(complementary_pkgs.split(), attempt_only=True) 618 self.install(complementary_pkgs.split(), attempt_only=True)
617 os.remove(installed_pkgs_file) 619 os.remove(installed_pkgs_file)
618 620
@@ -784,12 +786,12 @@ class RpmPM(PackageManager):
784 try: 786 try:
785 complementary_pkgs = subprocess.check_output(cmd, 787 complementary_pkgs = subprocess.check_output(cmd,
786 stderr=subprocess.STDOUT, 788 stderr=subprocess.STDOUT,
787 shell=True) 789 shell=True).decode("utf-8")
788 # bb.note(complementary_pkgs) 790 # bb.note(complementary_pkgs)
789 return complementary_pkgs 791 return complementary_pkgs
790 except subprocess.CalledProcessError as e: 792 except subprocess.CalledProcessError as e:
791 bb.fatal("Could not invoke smart. Command " 793 bb.fatal("Could not invoke smart. Command "
792 "'%s' returned %d:\n%s" % (cmd, e.returncode, e.output)) 794 "'%s' returned %d:\n%s" % (cmd, e.returncode, e.output.decode("utf-8")))
793 795
794 def _search_pkg_name_in_feeds(self, pkg, feed_archs): 796 def _search_pkg_name_in_feeds(self, pkg, feed_archs):
795 for arch in feed_archs: 797 for arch in feed_archs:
@@ -808,7 +810,7 @@ class RpmPM(PackageManager):
808 (self.smart_cmd, self.smart_opt, pkg) 810 (self.smart_cmd, self.smart_opt, pkg)
809 cmd += " | sed -ne 's/ *Provides://p'" 811 cmd += " | sed -ne 's/ *Provides://p'"
810 bb.note('cmd: %s' % cmd) 812 bb.note('cmd: %s' % cmd)
811 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) 813 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).decode("utf-8")
812 # Found a provider 814 # Found a provider
813 if output: 815 if output:
814 bb.note('Found providers for %s: %s' % (pkg, output)) 816 bb.note('Found providers for %s: %s' % (pkg, output))
@@ -956,7 +958,7 @@ class RpmPM(PackageManager):
956 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) 958 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
957 except subprocess.CalledProcessError as e: 959 except subprocess.CalledProcessError as e:
958 bb.fatal("Create rpm database failed. Command '%s' " 960 bb.fatal("Create rpm database failed. Command '%s' "
959 "returned %d:\n%s" % (cmd, e.returncode, e.output)) 961 "returned %d:\n%s" % (cmd, e.returncode, e.output.decode("utf-8")))
960 # Import GPG key to RPM database of the target system 962 # Import GPG key to RPM database of the target system
961 if self.d.getVar('RPM_SIGN_PACKAGES', True) == '1': 963 if self.d.getVar('RPM_SIGN_PACKAGES', True) == '1':
962 pubkey_path = self.d.getVar('RPM_GPG_PUBKEY', True) 964 pubkey_path = self.d.getVar('RPM_GPG_PUBKEY', True)
@@ -1203,11 +1205,11 @@ class RpmPM(PackageManager):
1203 cmd = "%s %s install --attempt -y %s" % \ 1205 cmd = "%s %s install --attempt -y %s" % \
1204 (self.smart_cmd, self.smart_opt, ' '.join(pkgs)) 1206 (self.smart_cmd, self.smart_opt, ' '.join(pkgs))
1205 try: 1207 try:
1206 output = subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT) 1208 output = subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT).decode("utf-8")
1207 bb.note(output) 1209 bb.note(output)
1208 except subprocess.CalledProcessError as e: 1210 except subprocess.CalledProcessError as e:
1209 bb.fatal("Unable to install packages. Command '%s' " 1211 bb.fatal("Unable to install packages. Command '%s' "
1210 "returned %d:\n%s" % (cmd, e.returncode, e.output)) 1212 "returned %d:\n%s" % (cmd, e.returncode, e.output.decode("utf-8")))
1211 1213
1212 ''' 1214 '''
1213 Remove pkgs with smart, the pkg name is smart/rpm format 1215 Remove pkgs with smart, the pkg name is smart/rpm format
@@ -1233,11 +1235,11 @@ class RpmPM(PackageManager):
1233 1235
1234 try: 1236 try:
1235 bb.note(cmd) 1237 bb.note(cmd)
1236 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) 1238 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).decode("utf-8")
1237 bb.note(output) 1239 bb.note(output)
1238 except subprocess.CalledProcessError as e: 1240 except subprocess.CalledProcessError as e:
1239 bb.note("Unable to remove packages. Command '%s' " 1241 bb.note("Unable to remove packages. Command '%s' "
1240 "returned %d:\n%s" % (cmd, e.returncode, e.output)) 1242 "returned %d:\n%s" % (cmd, e.returncode, e.output.decode("utf-8")))
1241 1243
1242 def upgrade(self): 1244 def upgrade(self):
1243 bb.note('smart upgrade') 1245 bb.note('smart upgrade')
@@ -1310,7 +1312,7 @@ class RpmPM(PackageManager):
1310 install_pkgs.append(pkg) 1312 install_pkgs.append(pkg)
1311 except subprocess.CalledProcessError as e: 1313 except subprocess.CalledProcessError as e:
1312 bb.note("Unable to dump install packages. Command '%s' " 1314 bb.note("Unable to dump install packages. Command '%s' "
1313 "returned %d:\n%s" % (cmd, e.returncode, e.output)) 1315 "returned %d:\n%s" % (cmd, e.returncode, e.output.decode("utf-8")))
1314 # Recovery rpmsys channel 1316 # Recovery rpmsys channel
1315 self._invoke_smart('channel --enable rpmsys') 1317 self._invoke_smart('channel --enable rpmsys')
1316 return install_pkgs 1318 return install_pkgs
@@ -1352,7 +1354,7 @@ class RpmPM(PackageManager):
1352 available_pkgs.append(pkg.strip()) 1354 available_pkgs.append(pkg.strip())
1353 except subprocess.CalledProcessError as e: 1355 except subprocess.CalledProcessError as e:
1354 bb.note("Unable to list all available packages. Command '%s' " 1356 bb.note("Unable to list all available packages. Command '%s' "
1355 "returned %d:\n%s" % (cmd, e.returncode, e.output)) 1357 "returned %d:\n%s" % (cmd, e.returncode, e.output.decode("utf-8")))
1356 1358
1357 self.fullpkglist = available_pkgs 1359 self.fullpkglist = available_pkgs
1358 1360
@@ -1379,12 +1381,12 @@ class RpmPM(PackageManager):
1379 1381
1380 try: 1382 try:
1381 bb.note(cmd) 1383 bb.note(cmd)
1382 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).strip() 1384 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).strip().decode("utf-8")
1383 bb.note(output) 1385 bb.note(output)
1384 os.chmod(saved_dir, 0755) 1386 os.chmod(saved_dir, 0o755)
1385 except subprocess.CalledProcessError as e: 1387 except subprocess.CalledProcessError as e:
1386 bb.fatal("Invoke save_rpmpostinst failed. Command '%s' " 1388 bb.fatal("Invoke save_rpmpostinst failed. Command '%s' "
1387 "returned %d:\n%s" % (cmd, e.returncode, e.output)) 1389 "returned %d:\n%s" % (cmd, e.returncode, e.output.decode("utf-8")))
1388 1390
1389 '''Write common configuration for target usage''' 1391 '''Write common configuration for target usage'''
1390 def rpm_setup_smart_target_config(self): 1392 def rpm_setup_smart_target_config(self):
@@ -1417,7 +1419,7 @@ class RpmPM(PackageManager):
1417 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) 1419 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
1418 except subprocess.CalledProcessError as e: 1420 except subprocess.CalledProcessError as e:
1419 bb.fatal("Unable to list available packages. Command '%s' " 1421 bb.fatal("Unable to list available packages. Command '%s' "
1420 "returned %d:\n%s" % (cmd, e.returncode, e.output)) 1422 "returned %d:\n%s" % (cmd, e.returncode, e.output.decode("utf-8")))
1421 1423
1422 # Set default values to avoid UnboundLocalError 1424 # Set default values to avoid UnboundLocalError
1423 arch = "" 1425 arch = ""
@@ -1482,7 +1484,7 @@ class RpmPM(PackageManager):
1482 except subprocess.CalledProcessError as e: 1484 except subprocess.CalledProcessError as e:
1483 bb.utils.remove(tmp_dir, recurse=True) 1485 bb.utils.remove(tmp_dir, recurse=True)
1484 bb.fatal("Unable to extract %s package. Command '%s' " 1486 bb.fatal("Unable to extract %s package. Command '%s' "
1485 "returned %d:\n%s" % (pkg_path, cmd, e.returncode, e.output)) 1487 "returned %d:\n%s" % (pkg_path, cmd, e.returncode, e.output.decode("utf-8")))
1486 except OSError as e: 1488 except OSError as e:
1487 bb.utils.remove(tmp_dir, recurse=True) 1489 bb.utils.remove(tmp_dir, recurse=True)
1488 bb.fatal("Unable to extract %s package. Command '%s' " 1490 bb.fatal("Unable to extract %s package. Command '%s' "
@@ -1512,7 +1514,7 @@ class OpkgDpkgPM(PackageManager):
1512 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) 1514 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
1513 except subprocess.CalledProcessError as e: 1515 except subprocess.CalledProcessError as e:
1514 bb.fatal("Unable to list available packages. Command '%s' " 1516 bb.fatal("Unable to list available packages. Command '%s' "
1515 "returned %d:\n%s" % (cmd, e.returncode, e.output)) 1517 "returned %d:\n%s" % (cmd, e.returncode, e.output.decode("utf-8")))
1516 return opkg_query(output) 1518 return opkg_query(output)
1517 1519
1518 """ 1520 """
@@ -1544,7 +1546,7 @@ class OpkgDpkgPM(PackageManager):
1544 except subprocess.CalledProcessError as e: 1546 except subprocess.CalledProcessError as e:
1545 bb.utils.remove(tmp_dir, recurse=True) 1547 bb.utils.remove(tmp_dir, recurse=True)
1546 bb.fatal("Unable to extract %s package. Command '%s' " 1548 bb.fatal("Unable to extract %s package. Command '%s' "
1547 "returned %d:\n%s" % (pkg_path, cmd, e.returncode, e.output)) 1549 "returned %d:\n%s" % (pkg_path, cmd, e.returncode, e.output.decode("utf-8")))
1548 except OSError as e: 1550 except OSError as e:
1549 bb.utils.remove(tmp_dir, recurse=True) 1551 bb.utils.remove(tmp_dir, recurse=True)
1550 bb.fatal("Unable to extract %s package. Command '%s' " 1552 bb.fatal("Unable to extract %s package. Command '%s' "
@@ -1733,7 +1735,7 @@ class OpkgPM(OpkgDpkgPM):
1733 except subprocess.CalledProcessError as e: 1735 except subprocess.CalledProcessError as e:
1734 self.deploy_dir_unlock() 1736 self.deploy_dir_unlock()
1735 bb.fatal("Unable to update the package index files. Command '%s' " 1737 bb.fatal("Unable to update the package index files. Command '%s' "
1736 "returned %d:\n%s" % (cmd, e.returncode, e.output)) 1738 "returned %d:\n%s" % (cmd, e.returncode, e.output.decode("utf-8")))
1737 1739
1738 self.deploy_dir_unlock() 1740 self.deploy_dir_unlock()
1739 1741
@@ -1754,12 +1756,12 @@ class OpkgPM(OpkgDpkgPM):
1754 try: 1756 try:
1755 bb.note("Installing the following packages: %s" % ' '.join(pkgs)) 1757 bb.note("Installing the following packages: %s" % ' '.join(pkgs))
1756 bb.note(cmd) 1758 bb.note(cmd)
1757 output = subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT) 1759 output = subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT).decode("utf-8")
1758 bb.note(output) 1760 bb.note(output)
1759 except subprocess.CalledProcessError as e: 1761 except subprocess.CalledProcessError as e:
1760 (bb.fatal, bb.note)[attempt_only]("Unable to install packages. " 1762 (bb.fatal, bb.note)[attempt_only]("Unable to install packages. "
1761 "Command '%s' returned %d:\n%s" % 1763 "Command '%s' returned %d:\n%s" %
1762 (cmd, e.returncode, e.output)) 1764 (cmd, e.returncode, e.output.decode("utf-8")))
1763 1765
1764 def remove(self, pkgs, with_dependencies=True): 1766 def remove(self, pkgs, with_dependencies=True):
1765 if with_dependencies: 1767 if with_dependencies:
@@ -1771,11 +1773,11 @@ class OpkgPM(OpkgDpkgPM):
1771 1773
1772 try: 1774 try:
1773 bb.note(cmd) 1775 bb.note(cmd)
1774 output = subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT) 1776 output = subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT).decode("utf-8")
1775 bb.note(output) 1777 bb.note(output)
1776 except subprocess.CalledProcessError as e: 1778 except subprocess.CalledProcessError as e:
1777 bb.fatal("Unable to remove packages. Command '%s' " 1779 bb.fatal("Unable to remove packages. Command '%s' "
1778 "returned %d:\n%s" % (e.cmd, e.returncode, e.output)) 1780 "returned %d:\n%s" % (e.cmd, e.returncode, e.output.decode("utf-8")))
1779 1781
1780 def write_index(self): 1782 def write_index(self):
1781 self.deploy_dir_lock() 1783 self.deploy_dir_lock()
@@ -1818,10 +1820,10 @@ class OpkgPM(OpkgDpkgPM):
1818 pkg_info = cmd + pkg 1820 pkg_info = cmd + pkg
1819 1821
1820 try: 1822 try:
1821 output = subprocess.check_output(pkg_info.split(), stderr=subprocess.STDOUT).strip() 1823 output = subprocess.check_output(pkg_info.split(), stderr=subprocess.STDOUT).strip().decode("utf-8")
1822 except subprocess.CalledProcessError as e: 1824 except subprocess.CalledProcessError as e:
1823 bb.fatal("Cannot get package info. Command '%s' " 1825 bb.fatal("Cannot get package info. Command '%s' "
1824 "returned %d:\n%s" % (pkg_info, e.returncode, e.output)) 1826 "returned %d:\n%s" % (pkg_info, e.returncode, e.output.decode("utf-8")))
1825 1827
1826 if output == "": 1828 if output == "":
1827 bb.note("Ignored bad recommendation: '%s' is " 1829 bb.note("Ignored bad recommendation: '%s' is "
@@ -1858,7 +1860,7 @@ class OpkgPM(OpkgDpkgPM):
1858 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) 1860 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
1859 except subprocess.CalledProcessError as e: 1861 except subprocess.CalledProcessError as e:
1860 bb.fatal("Unable to update. Command '%s' " 1862 bb.fatal("Unable to update. Command '%s' "
1861 "returned %d:\n%s" % (cmd, e.returncode, e.output)) 1863 "returned %d:\n%s" % (cmd, e.returncode, e.output.decode("utf-8")))
1862 1864
1863 # Dummy installation 1865 # Dummy installation
1864 cmd = "%s %s --noaction install %s " % (self.opkg_cmd, 1866 cmd = "%s %s --noaction install %s " % (self.opkg_cmd,
@@ -1868,7 +1870,7 @@ class OpkgPM(OpkgDpkgPM):
1868 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) 1870 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
1869 except subprocess.CalledProcessError as e: 1871 except subprocess.CalledProcessError as e:
1870 bb.fatal("Unable to dummy install packages. Command '%s' " 1872 bb.fatal("Unable to dummy install packages. Command '%s' "
1871 "returned %d:\n%s" % (cmd, e.returncode, e.output)) 1873 "returned %d:\n%s" % (cmd, e.returncode, e.output.decode("utf-8")))
1872 1874
1873 bb.utils.remove(temp_rootfs, True) 1875 bb.utils.remove(temp_rootfs, True)
1874 1876
@@ -2012,7 +2014,7 @@ class DpkgPM(OpkgDpkgPM):
2012 subprocess.check_output(p_full, stderr=subprocess.STDOUT) 2014 subprocess.check_output(p_full, stderr=subprocess.STDOUT)
2013 except subprocess.CalledProcessError as e: 2015 except subprocess.CalledProcessError as e:
2014 bb.note("%s for package %s failed with %d:\n%s" % 2016 bb.note("%s for package %s failed with %d:\n%s" %
2015 (suffix[1], pkg_name, e.returncode, e.output)) 2017 (suffix[1], pkg_name, e.returncode, e.output.decode("utf-8")))
2016 failed_pkgs.append(pkg_name) 2018 failed_pkgs.append(pkg_name)
2017 break 2019 break
2018 2020
@@ -2030,7 +2032,7 @@ class DpkgPM(OpkgDpkgPM):
2030 subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT) 2032 subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
2031 except subprocess.CalledProcessError as e: 2033 except subprocess.CalledProcessError as e:
2032 bb.fatal("Unable to update the package index files. Command '%s' " 2034 bb.fatal("Unable to update the package index files. Command '%s' "
2033 "returned %d:\n%s" % (e.cmd, e.returncode, e.output)) 2035 "returned %d:\n%s" % (e.cmd, e.returncode, e.output.decode("utf-8")))
2034 2036
2035 self.deploy_dir_unlock() 2037 self.deploy_dir_unlock()
2036 2038
@@ -2049,7 +2051,7 @@ class DpkgPM(OpkgDpkgPM):
2049 except subprocess.CalledProcessError as e: 2051 except subprocess.CalledProcessError as e:
2050 (bb.fatal, bb.note)[attempt_only]("Unable to install packages. " 2052 (bb.fatal, bb.note)[attempt_only]("Unable to install packages. "
2051 "Command '%s' returned %d:\n%s" % 2053 "Command '%s' returned %d:\n%s" %
2052 (cmd, e.returncode, e.output)) 2054 (cmd, e.returncode, e.output.decode("utf-8")))
2053 2055
2054 # rename *.dpkg-new files/dirs 2056 # rename *.dpkg-new files/dirs
2055 for root, dirs, files in os.walk(self.target_rootfs): 2057 for root, dirs, files in os.walk(self.target_rootfs):
@@ -2080,7 +2082,7 @@ class DpkgPM(OpkgDpkgPM):
2080 subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT) 2082 subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
2081 except subprocess.CalledProcessError as e: 2083 except subprocess.CalledProcessError as e:
2082 bb.fatal("Unable to remove packages. Command '%s' " 2084 bb.fatal("Unable to remove packages. Command '%s' "
2083 "returned %d:\n%s" % (e.cmd, e.returncode, e.output)) 2085 "returned %d:\n%s" % (e.cmd, e.returncode, e.output.decode("utf-8")))
2084 2086
2085 def write_index(self): 2087 def write_index(self):
2086 self.deploy_dir_lock() 2088 self.deploy_dir_lock()
@@ -2213,7 +2215,7 @@ class DpkgPM(OpkgDpkgPM):
2213 subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT) 2215 subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
2214 except subprocess.CalledProcessError as e: 2216 except subprocess.CalledProcessError as e:
2215 bb.fatal("Cannot fix broken dependencies. Command '%s' " 2217 bb.fatal("Cannot fix broken dependencies. Command '%s' "
2216 "returned %d:\n%s" % (cmd, e.returncode, e.output)) 2218 "returned %d:\n%s" % (cmd, e.returncode, e.output.decode("utf-8")))
2217 2219
2218 def list_installed(self): 2220 def list_installed(self):
2219 return DpkgPkgsList(self.d, self.target_rootfs).list_pkgs() 2221 return DpkgPkgsList(self.d, self.target_rootfs).list_pkgs()
diff --git a/meta/lib/oe/packagedata.py b/meta/lib/oe/packagedata.py
index bc0fd06bce..df1b4c52e3 100644
--- a/meta/lib/oe/packagedata.py
+++ b/meta/lib/oe/packagedata.py
@@ -8,7 +8,7 @@ def read_pkgdatafile(fn):
8 pkgdata = {} 8 pkgdata = {}
9 9
10 def decode(str): 10 def decode(str):
11 c = codecs.getdecoder("string_escape") 11 c = codecs.getdecoder("unicode_escape")
12 return c(str)[0] 12 return c(str)[0]
13 13
14 if os.access(fn, os.R_OK): 14 if os.access(fn, os.R_OK):
diff --git a/meta/lib/oeqa/oetest.py b/meta/lib/oeqa/oetest.py
index a50f9d8187..4211ffc379 100644
--- a/meta/lib/oeqa/oetest.py
+++ b/meta/lib/oeqa/oetest.py
@@ -132,7 +132,7 @@ class oeSDKTest(oeTest):
132 return False 132 return False
133 133
134 def _run(self, cmd): 134 def _run(self, cmd):
135 return subprocess.check_output(". %s > /dev/null; %s;" % (self.tc.sdkenv, cmd), shell=True) 135 return subprocess.check_output(". %s > /dev/null; %s;" % (self.tc.sdkenv, cmd), shell=True).decode("utf-8")
136 136
137class oeSDKExtTest(oeSDKTest): 137class oeSDKExtTest(oeSDKTest):
138 def _run(self, cmd): 138 def _run(self, cmd):
@@ -144,7 +144,7 @@ class oeSDKExtTest(oeSDKTest):
144 env['PATH'] = avoid_paths_in_environ(paths_to_avoid) 144 env['PATH'] = avoid_paths_in_environ(paths_to_avoid)
145 145
146 return subprocess.check_output(". %s > /dev/null;"\ 146 return subprocess.check_output(". %s > /dev/null;"\
147 " %s;" % (self.tc.sdkenv, cmd), shell=True, env=env) 147 " %s;" % (self.tc.sdkenv, cmd), shell=True, env=env).decode("utf-8")
148 148
149def getmodule(pos=2): 149def getmodule(pos=2):
150 # stack returns a list of tuples containg frame information 150 # stack returns a list of tuples containg frame information
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):
238 result = None 238 result = None
239 thegrep = self.build_grepcmd(errors, ignore_errors, log) 239 thegrep = self.build_grepcmd(errors, ignore_errors, log)
240 try: 240 try:
241 result = subprocess.check_output(thegrep, shell=True) 241 result = subprocess.check_output(thegrep, shell=True).decode("utf-8")
242 except: 242 except:
243 pass 243 pass
244 if (result is not None): 244 if (result is not None):
@@ -246,7 +246,7 @@ class ParseLogsTest(oeRuntimeTest):
246 rez = result.splitlines() 246 rez = result.splitlines()
247 for xrez in rez: 247 for xrez in rez:
248 try: 248 try:
249 grep_output = subprocess.check_output(['grep', '-F', xrez, '-B', str(lines_before), '-A', str(lines_after), log]) 249 grep_output = subprocess.check_output(['grep', '-F', xrez, '-B', str(lines_before), '-A', str(lines_after), log]).decode("utf-8")
250 except: 250 except:
251 pass 251 pass
252 results[log.replace('target_logs/','')][xrez]=grep_output 252 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):
14 endtime = time.time() + 60 14 endtime = time.time() + 60
15 while count < 5 and time.time() < endtime: 15 while count < 5 and time.time() < endtime:
16 proc = subprocess.Popen("ping -c 1 %s" % self.target.ip, shell=True, stdout=subprocess.PIPE) 16 proc = subprocess.Popen("ping -c 1 %s" % self.target.ip, shell=True, stdout=subprocess.PIPE)
17 output += proc.communicate()[0] 17 output += proc.communicate()[0].decode("utf-8")
18 if proc.poll() == 0: 18 if proc.poll() == 0:
19 count += 1 19 count += 1
20 else: 20 else:
diff --git a/meta/lib/oeqa/utils/commands.py b/meta/lib/oeqa/utils/commands.py
index 48f6441290..9a7c1d1375 100644
--- a/meta/lib/oeqa/utils/commands.py
+++ b/meta/lib/oeqa/utils/commands.py
@@ -78,7 +78,7 @@ class Command(object):
78 self.process.kill() 78 self.process.kill()
79 self.thread.join() 79 self.thread.join()
80 80
81 self.output = self.output.rstrip() 81 self.output = self.output.decode("utf-8").rstrip()
82 self.status = self.process.poll() 82 self.status = self.process.poll()
83 83
84 self.log.debug("Command '%s' returned %d as exit code." % (self.cmd, self.status)) 84 self.log.debug("Command '%s' returned %d as exit code." % (self.cmd, self.status))
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index 695402fead..f51de99458 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -71,7 +71,8 @@ class QemuRunner:
71 if self.logfile: 71 if self.logfile:
72 # It is needed to sanitize the data received from qemu 72 # It is needed to sanitize the data received from qemu
73 # because is possible to have control characters 73 # because is possible to have control characters
74 msg = re_control_char.sub('', unicode(msg, 'utf-8')) 74 msg = msg.decode("utf-8")
75 msg = re_control_char.sub('', msg)
75 with codecs.open(self.logfile, "a", encoding="utf-8") as f: 76 with codecs.open(self.logfile, "a", encoding="utf-8") as f:
76 f.write("%s" % msg) 77 f.write("%s" % msg)
77 78
@@ -79,7 +80,7 @@ class QemuRunner:
79 import fcntl 80 import fcntl
80 fl = fcntl.fcntl(o, fcntl.F_GETFL) 81 fl = fcntl.fcntl(o, fcntl.F_GETFL)
81 fcntl.fcntl(o, fcntl.F_SETFL, fl | os.O_NONBLOCK) 82 fcntl.fcntl(o, fcntl.F_SETFL, fl | os.O_NONBLOCK)
82 return os.read(o.fileno(), 1000000) 83 return os.read(o.fileno(), 1000000).decode("utf-8")
83 84
84 85
85 def handleSIGCHLD(self, signum, frame): 86 def handleSIGCHLD(self, signum, frame):
@@ -229,14 +230,19 @@ class QemuRunner:
229 socklist.remove(self.server_socket) 230 socklist.remove(self.server_socket)
230 logger.info("Connection from %s:%s" % addr) 231 logger.info("Connection from %s:%s" % addr)
231 else: 232 else:
232 data = sock.recv(1024) 233 data = data + sock.recv(1024)
233 if data: 234 if data:
234 bootlog += data 235 try:
235 if re.search(".* login:", bootlog): 236 data = data.decode("utf-8")
236 self.server_socket = qemusock 237 bootlog += data
237 stopread = True 238 data = b''
238 reachedlogin = True 239 if re.search(".* login:", bootlog):
239 logger.info("Reached login banner") 240 self.server_socket = qemusock
241 stopread = True
242 reachedlogin = True
243 logger.info("Reached login banner")
244 except UnicodeDecodeError:
245 continue
240 else: 246 else:
241 socklist.remove(sock) 247 socklist.remove(sock)
242 sock.close() 248 sock.close()
@@ -325,7 +331,7 @@ class QemuRunner:
325 # Walk the process tree from the process specified looking for a qemu-system. Return its [pid'cmd] 331 # Walk the process tree from the process specified looking for a qemu-system. Return its [pid'cmd]
326 # 332 #
327 ps = subprocess.Popen(['ps', 'axww', '-o', 'pid,ppid,command'], stdout=subprocess.PIPE).communicate()[0] 333 ps = subprocess.Popen(['ps', 'axww', '-o', 'pid,ppid,command'], stdout=subprocess.PIPE).communicate()[0]
328 processes = ps.split('\n') 334 processes = ps.decode("utf-8").split('\n')
329 nfields = len(processes[0].split()) - 1 335 nfields = len(processes[0].split()) - 1
330 pids = {} 336 pids = {}
331 commands = {} 337 commands = {}
diff --git a/meta/lib/oeqa/utils/qemutinyrunner.py b/meta/lib/oeqa/utils/qemutinyrunner.py
index d6ce09645c..054ab0ec5d 100644
--- a/meta/lib/oeqa/utils/qemutinyrunner.py
+++ b/meta/lib/oeqa/utils/qemutinyrunner.py
@@ -102,7 +102,7 @@ class QemuTinyRunner(QemuRunner):
102 bb.note("Qemu pid didn't appeared in %s seconds" % self.runqemutime) 102 bb.note("Qemu pid didn't appeared in %s seconds" % self.runqemutime)
103 output = self.runqemu.stdout 103 output = self.runqemu.stdout
104 self.stop() 104 self.stop()
105 bb.note("Output from runqemu:\n%s" % output.read()) 105 bb.note("Output from runqemu:\n%s" % output.read().decode("utf-8"))
106 return False 106 return False
107 107
108 return self.is_alive() 108 return self.is_alive()
@@ -131,7 +131,7 @@ class QemuTinyRunner(QemuRunner):
131 # Walk the process tree from the process specified looking for a qemu-system. Return its [pid'cmd] 131 # Walk the process tree from the process specified looking for a qemu-system. Return its [pid'cmd]
132 # 132 #
133 ps = subprocess.Popen(['ps', 'axww', '-o', 'pid,ppid,command'], stdout=subprocess.PIPE).communicate()[0] 133 ps = subprocess.Popen(['ps', 'axww', '-o', 'pid,ppid,command'], stdout=subprocess.PIPE).communicate()[0]
134 processes = ps.split('\n') 134 processes = ps.decode("utf-8").split('\n')
135 nfields = len(processes[0].split()) - 1 135 nfields = len(processes[0].split()) - 1
136 pids = {} 136 pids = {}
137 commands = {} 137 commands = {}
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):
58 self.process.stdout.close() 58 self.process.stdout.close()
59 eof = True 59 eof = True
60 else: 60 else:
61 data = data.decode("utf-8")
61 output += data 62 output += data
62 self.log(data) 63 self.log(data)
63 endtime = time.time() + timeout 64 endtime = time.time() + timeout