mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-04-19 22:31:07 +00:00
Use the Popen() encoding flag to decode to unicode
This should make behavior identical on Python 2 & 3.
This commit is contained in:
parent
43ad610a66
commit
2d3765522e
@ -620,8 +620,8 @@ def rmadison(url, package, suite=None, arch=None):
|
||||
if arch:
|
||||
cmd += ['-a', arch]
|
||||
cmd.append(package)
|
||||
process = subprocess.Popen(cmd, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, close_fds=True)
|
||||
process = subprocess.Popen(
|
||||
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8')
|
||||
output, error_output = process.communicate()
|
||||
if process.wait() != 0:
|
||||
if error_output:
|
||||
@ -636,7 +636,7 @@ def rmadison(url, package, suite=None, arch=None):
|
||||
|
||||
# pylint bug: http://www.logilab.org/ticket/46273
|
||||
# pylint: disable=E1103
|
||||
for line in output.decode().strip().splitlines():
|
||||
for line in output.strip().splitlines():
|
||||
# pylint: enable=E1103
|
||||
pkg, ver, dist, archs = [x.strip() for x in line.split('|')]
|
||||
comp = 'main'
|
||||
|
@ -34,7 +34,7 @@ class Builder(object):
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
cmd = ["dpkg-architecture", "-qDEB_BUILD_ARCH_CPU"]
|
||||
process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
||||
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, encoding='utf-8')
|
||||
self.architecture = process.communicate()[0].strip()
|
||||
|
||||
def _build_failure(self, returncode, dsc_file):
|
||||
@ -124,7 +124,8 @@ class Sbuild(Builder):
|
||||
def update(self, dist):
|
||||
cmd = ["schroot", "--list"]
|
||||
Logger.command(cmd)
|
||||
process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
||||
process = subprocess.Popen(
|
||||
cmd, stdout=subprocess.PIPE, encoding='utf-8')
|
||||
chroots, _ = process.communicate()[0].strip().split()
|
||||
if process.returncode != 0:
|
||||
return process.returncode
|
||||
|
@ -161,9 +161,10 @@ def mail_bug(srcpkg, subscribe, status, bugtitle, bugtext, bug_mail_domain,
|
||||
gpg_command.extend(('-u', keyid))
|
||||
|
||||
# sign the mail body
|
||||
gpg = subprocess.Popen(gpg_command, stdin=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE)
|
||||
signed_report = gpg.communicate(mailbody.encode('utf-8'))[0].decode('utf-8')
|
||||
gpg = subprocess.Popen(
|
||||
gpg_command, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
||||
encoding='utf-8')
|
||||
signed_report = gpg.communicate(mailbody)[0]
|
||||
if gpg.returncode != 0:
|
||||
Logger.error("%s failed.", gpg_command[0])
|
||||
sys.exit(1)
|
||||
|
@ -71,7 +71,7 @@ class Patch(object):
|
||||
patch_f.close()
|
||||
|
||||
cmd = ["diffstat", "-l", "-p0", self._full_path]
|
||||
process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
||||
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, encoding='utf-8')
|
||||
changed_files = process.communicate()[0]
|
||||
self._changed_files = [f for f in changed_files.split("\n") if f != ""]
|
||||
|
||||
|
@ -327,7 +327,7 @@ class SourcePackage(object):
|
||||
if not Logger.verbose:
|
||||
cmd.insert(1, "-q")
|
||||
Logger.command(cmd + [">", self._debdiff_filename])
|
||||
process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
||||
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, encoding='utf-8')
|
||||
debdiff = process.communicate()[0]
|
||||
|
||||
# write debdiff file
|
||||
@ -421,7 +421,7 @@ class SourcePackage(object):
|
||||
self._package + "_" +
|
||||
strip_epoch(self._version) + ".lintian")
|
||||
Logger.command(cmd + [">", lintian_filename])
|
||||
process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
||||
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, encoding='utf-8')
|
||||
report = process.communicate()[0]
|
||||
|
||||
# write lintian report file
|
||||
|
@ -14,9 +14,9 @@
|
||||
|
||||
"""test_flake8.py - Run flake8 check"""
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from ubuntutools import subprocess
|
||||
from ubuntutools.test import get_source_files, unittest, unittest_verbosity
|
||||
|
||||
|
||||
@ -33,17 +33,18 @@ class Flake8TestCase(unittest.TestCase):
|
||||
cmd = [sys.executable, "-m", "flake8", "--max-line-length=99"] + get_source_files()
|
||||
if unittest_verbosity() >= 2:
|
||||
sys.stderr.write("Running following command:\n{}\n".format(" ".join(cmd)))
|
||||
process = subprocess.Popen(cmd, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, close_fds=True)
|
||||
process = subprocess.Popen(
|
||||
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||
encoding='utf-8')
|
||||
|
||||
out, err = process.communicate()
|
||||
if process.returncode != 0: # pragma: no cover
|
||||
msgs = []
|
||||
if err:
|
||||
msgs.append("flake8 exited with code {} and has unexpected output on stderr:\n{}"
|
||||
.format(process.returncode, err.decode().rstrip()))
|
||||
.format(process.returncode, err.rstrip()))
|
||||
if out:
|
||||
msgs.append("flake8 found issues:\n{}".format(out.decode().rstrip()))
|
||||
msgs.append("flake8 found issues:\n{}".format(out.rstrip()))
|
||||
if not msgs:
|
||||
msgs.append("flake8 exited with code {} and has no output on stdout or stderr."
|
||||
.format(process.returncode))
|
||||
|
@ -46,7 +46,7 @@ class HelpTestCase(unittest.TestCase):
|
||||
def tester(self):
|
||||
null = open('/dev/null', 'r')
|
||||
process = subprocess.Popen(['./' + script, '--help'],
|
||||
close_fds=True, stdin=null,
|
||||
encoding='utf-8', stdin=null,
|
||||
universal_newlines=True,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE)
|
||||
|
@ -40,8 +40,9 @@ class PylintTestCase(unittest.TestCase):
|
||||
"-E", "--"] + get_source_files()
|
||||
if unittest_verbosity() >= 2:
|
||||
sys.stderr.write("Running following command:\n{}\n".format(" ".join(cmd)))
|
||||
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||
close_fds=True)
|
||||
process = subprocess.Popen(
|
||||
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||
encoding='utf-8')
|
||||
out, err = process.communicate()
|
||||
|
||||
if process.returncode != 0: # pragma: no cover
|
||||
@ -50,11 +51,11 @@ class PylintTestCase(unittest.TestCase):
|
||||
# ------------------------------------
|
||||
# Your code has been rated at 10.00/10
|
||||
#
|
||||
out = re.sub("^(-+|Your code has been rated at .*)$", "", out.decode(),
|
||||
out = re.sub("^(-+|Your code has been rated at .*)$", "", out,
|
||||
flags=re.MULTILINE).rstrip()
|
||||
|
||||
# Strip logging of used config file (introduced in pylint 1.8)
|
||||
err = re.sub("^Using config file .*\n", "", err.decode()).rstrip()
|
||||
err = re.sub("^Using config file .*\n", "", err).rstrip()
|
||||
|
||||
msgs = []
|
||||
if err:
|
||||
|
Loading…
x
Reference in New Issue
Block a user