Convert _ssh_run output to str for python3

This is for fixing "a bytes-like object is required, not 'str'" issue
in runroot task.

JIRA: RHELCMP-9224
Signed-off-by: Haibo Lin <hlin@redhat.com>
This commit is contained in:
Haibo Lin 2022-07-15 13:17:46 +08:00
parent 19cb013fec
commit b0b494fff0

View File

@ -15,6 +15,7 @@
import os import os
import re import re
import six
from six.moves import shlex_quote from six.moves import shlex_quote
import kobo.log import kobo.log
from kobo.shortcuts import run from kobo.shortcuts import run
@ -149,7 +150,11 @@ class Runroot(kobo.log.LoggingBase):
""" """
formatted_cmd = command.format(**fmt_dict) if fmt_dict else command formatted_cmd = command.format(**fmt_dict) if fmt_dict else command
ssh_cmd = ["ssh", "-oBatchMode=yes", "-n", "-l", user, hostname, formatted_cmd] ssh_cmd = ["ssh", "-oBatchMode=yes", "-n", "-l", user, hostname, formatted_cmd]
return run(ssh_cmd, show_cmd=True, logfile=log_file)[1] output = run(ssh_cmd, show_cmd=True, logfile=log_file)[1]
if six.PY3 and isinstance(output, bytes):
return output.decode()
else:
return output
def _log_file(self, base, suffix): def _log_file(self, base, suffix):
return base.replace(".log", "." + suffix + ".log") return base.replace(".log", "." + suffix + ".log")