@@ -81,7 +81,7 @@ class OEQemuTarget(OESSHTarget):
blcmd = ["tail", "-20", self.bootlog]
msg += "===== start: snippet =====\n\n"
try:
- out = subprocess.check_output(blcmd, stderr=subprocess.STDOUT, timeout=1).decode('utf-8')
+ out = subprocess.check_output(blcmd, stderr=subprocess.STDOUT, timeout=1, text=True)
msg += "file: %s\n\n" % self.bootlog
msg += out
except (subprocess.CalledProcessError, subprocess.TimeoutExpired, FileNotFoundError) as err:
@@ -24,8 +24,8 @@ class BootTest(OERuntimeTestCase):
while count < 5:
time.sleep(5)
cmd = 'ping -c 1 %s' % self.target.ip
- proc = Popen(cmd, shell=True, stdout=PIPE)
- output += proc.communicate()[0].decode('utf-8')
+ proc = Popen(cmd, shell=True, stdout=PIPE, text=True)
+ output += proc.communicate()[0]
if proc.poll() == 0:
count += 1
else:
@@ -103,7 +103,7 @@ class DnfRepoTest(DnfTest):
@OETestDepends(['dnf.DnfRepoTest.test_dnf_install_from_disk'])
def test_dnf_install_from_http(self):
output = subprocess.check_output('%s %s -name dnf-test-dep*' % (bb.utils.which(os.getenv('PATH'), "find"),
- os.path.join(self.tc.td['WORKDIR'], 'oe-testimage-repo')), shell=True).decode("utf-8")
+ os.path.join(self.tc.td['WORKDIR'], 'oe-testimage-repo')), shell=True, text=True)
rpm_path = output.split("/")[-2] + "/" + output.split("/")[-1]
url = 'http://%s:%s/%s' %(self.target.server_ip, self.repo_server.port, rpm_path)
self.dnf_with_repo('remove -y dnf-test-dep')
@@ -28,8 +28,8 @@ class PingTest(OERuntimeTestCase):
try:
while count < 5:
cmd = 'ping -c 1 %s' % self.target.ip
- proc = Popen(cmd, shell=True, stdout=PIPE)
- output += proc.communicate()[0].decode('utf-8')
+ proc = Popen(cmd, shell=True, stdout=PIPE, text=True)
+ output += proc.communicate()[0]
if proc.poll() == 0:
count += 1
else:
@@ -66,9 +66,9 @@ class TestSDK(TestSDKBase):
import subprocess
try:
- subprocess.check_output("cd %s; %s <<EOF\n./\nY\nEOF" % (sdk_dir, tcname), shell=True)
+ subprocess.check_output("cd %s; %s <<EOF\n./\nY\nEOF" % (sdk_dir, tcname), shell=True, text=True)
except subprocess.CalledProcessError as e:
- bb.fatal("Couldn't install the SDK:\n%s" % e.output.decode("utf-8"))
+ bb.fatal("Couldn't install the SDK:\n%s" % e.output)
def setup_context(self, d):
"""
@@ -46,8 +46,9 @@ class SDKBuildProject(BuildProject):
self.log("Running . %s; " % self.sdkenv + cmd)
try:
output = subprocess.check_output(". %s; " % self.sdkenv + cmd, shell=True,
- executable='/bin/bash', stderr=subprocess.STDOUT)
+ executable='/bin/bash', stderr=subprocess.STDOUT,
+ text=True)
except subprocess.CalledProcessError as exc:
- print(exc.output.decode('utf-8'))
+ print(exc.output)
return exc.returncode
return 0
@@ -47,9 +47,9 @@ class TestSDKExt(TestSDKBase):
bb.utils.remove(sdk_dir, True)
bb.utils.mkdirhier(sdk_dir)
try:
- subprocess.check_output([tcname, '-y', '-d', sdk_dir])
+ subprocess.check_output([tcname, '-y', '-d', sdk_dir], text=True)
except subprocess.CalledProcessError as e:
- msg = "Couldn't install the extensible SDK:\n%s" % e.output.decode("utf-8")
+ msg = "Couldn't install the extensible SDK:\n%s" % e.output
logfn = os.path.join(sdk_dir, 'preparing_build_system.log')
if os.path.exists(logfn):
msg += '\n\nContents of preparing_build_system.log:\n'
@@ -31,7 +31,7 @@ class TestResultsQueryTests(OESelftestTestCase):
workdir = create_workdir()
try:
url = subprocess.check_output(
- ["git", "-C", workdir, "remote", "get-url", "origin"]).strip().decode("utf-8")
+ ["git", "-C", workdir, "remote", "get-url", "origin"], text=True).strip()
except:
shutil.rmtree(workdir, ignore_errors=True)
self.fail(f"Can not execute git commands in {workdir}")
@@ -68,19 +68,19 @@ def git_rev_info(path):
except ImportError:
import subprocess
try:
- info['branch'] = subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"], cwd=path).decode('utf-8').strip()
+ info['branch'] = subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"], cwd=path, text=True).strip()
except subprocess.CalledProcessError:
pass
try:
- info['commit'] = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=path).decode('utf-8').strip()
+ info['commit'] = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=path, text=True).strip()
except subprocess.CalledProcessError:
pass
try:
- info['commit_count'] = int(subprocess.check_output(["git", "rev-list", "--count", "HEAD"], cwd=path).decode('utf-8').strip())
+ info['commit_count'] = int(subprocess.check_output(["git", "rev-list", "--count", "HEAD"], cwd=path, text=True).strip())
except subprocess.CalledProcessError:
pass
try:
- info['commit_time'] = int(subprocess.check_output(["git", "show", "--no-patch", "--format=%ct", "HEAD"], cwd=path).decode('utf-8').strip())
+ info['commit_time'] = int(subprocess.check_output(["git", "show", "--no-patch", "--format=%ct", "HEAD"], cwd=path, text=True).strip())
except subprocess.CalledProcessError:
pass
return info
@@ -316,8 +316,7 @@ class QemuRunner:
% (self.runqemu.poll(), os.path.isfile(self.qemu_pidfile), str(qemu_pid), os.path.exists("/proc/" + str(qemu_pid))))
# Dump all processes to help us to figure out what is going on...
- ps = subprocess.Popen(['ps', 'axww', '-o', 'pid,ppid,pri,ni,command '], stdout=subprocess.PIPE).communicate()[0]
- processes = ps.decode("utf-8")
+ processes = subprocess.Popen(['ps', 'axww', '-o', 'pid,ppid,pri,ni,command '], stdout=subprocess.PIPE, text=True).communicate()[0]
self.logger.debug("Running processes:\n%s" % processes)
op = getOutput(output)
self.stop()
@@ -143,8 +143,8 @@ 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,pri,ni,command'], stdout=subprocess.PIPE).communicate()[0]
- processes = ps.decode("utf-8").split('\n')
+ ps = subprocess.Popen(['ps', 'axww', '-o', 'pid,ppid,pri,ni,command'], stdout=subprocess.PIPE, text=True).communicate()[0]
+ processes = ps.split('\n')
nfields = len(processes[0].split()) - 1
pids = {}
commands = {}
Pass text=True to the subprocess calls rather than decoding the bytes afterwards. This also covers CalledProcessError.output. Raw socket/pty reads and base64 output are left as bytes. AI-Generated: Uses Claude Opus 5.5 Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> --- meta/lib/oeqa/core/target/qemu.py | 2 +- meta/lib/oeqa/runtime/cases/boot.py | 4 ++-- meta/lib/oeqa/runtime/cases/dnf.py | 2 +- meta/lib/oeqa/runtime/cases/ping.py | 4 ++-- meta/lib/oeqa/sdk/testsdk.py | 4 ++-- meta/lib/oeqa/sdk/utils/sdkbuildproject.py | 5 +++-- meta/lib/oeqa/sdkext/testsdk.py | 4 ++-- .../lib/oeqa/selftest/cases/yoctotestresultsquerytests.py | 2 +- meta/lib/oeqa/utils/metadata.py | 8 ++++---- meta/lib/oeqa/utils/qemurunner.py | 3 +-- meta/lib/oeqa/utils/qemutinyrunner.py | 4 ++-- 11 files changed, 21 insertions(+), 21 deletions(-)