stderr=subprocess.PIPE,
)
p.wait()
- for line in p.stderr.readlines():
- line = ensure_str(line.strip())
+ for line in p.stderr:
+ line = line.decode()
+ line = line.strip()
if line and not line.startswith('#'):
log.error(line)
- for line in p.stdout.readlines():
- host, key = ensure_str(line.strip()).split(' ', 1)
+ for line in p.stdout:
+ host, key = line.strip().decode().split(' ', 1)
return key
lines = []
truncated = False
with proc.stdout:
- for line in iter(proc.stdout.readline, b''):
- line = ensure_str(line)
+ for line in proc.stdout:
+ line = line.decode()
lines.append(line)
line = line.strip()
if len(line) > log_limit:
import re
import shutil
import subprocess
-
-from six import ensure_str
-
import time
from teuthology import misc
result = subprocess.check_output(
cmd, shell=True).split()
if result:
- sha1 = ensure_str(result[0])
+ sha1 = result[0].decode()
log.debug("{} -> {}".format(cmd, sha1))
return sha1
stderr=subprocess.STDOUT)
not_found_str = "Remote branch %s not found" % branch
- out = ensure_str(proc.stdout.read())
+ out = proc.stdout.read().decode()
result = proc.wait()
# Newer git versions will bail if the branch is not found, but older ones
# will not. Fortunately they both output similar text.
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
if proc.wait() != 0:
- out = ensure_str(proc.stdout.read())
+ out = proc.stdout.read().decode()
log.error(out)
raise GitError("git fetch failed!")
stderr=subprocess.STDOUT)
if proc.wait() != 0:
not_found_str = "fatal: couldn't find remote ref %s" % branch
- out = ensure_str(proc.stdout.read())
+ out = proc.stdout.read().decode()
log.error(out)
if not_found_str in out.lower():
raise BranchNotFoundError(branch)
m_check_output.return_value = ''
assert False == util.git_branch_exists(
project_or_url, 'nobranchnowaycanthappen')
- m_check_output.return_value = 'HHH branch'
+ m_check_output.return_value = b'HHH branch'
assert True == util.git_branch_exists(project_or_url, 'master')
process_mock = mock.Mock()
attrs = {
'wait.return_value': 1,
- 'stdout.read.return_value': "%s %s" % (git_str, branch_name),
+ 'stdout.read.return_value': f"{git_str} {branch_name}".encode(),
}
process_mock.configure_mock(**attrs)
mock_popen.return_value = process_mock