3
0
mirror of https://git.launchpad.net/ubuntu-dev-tools synced 2025-03-16 17:41:08 +00:00

Replace simple Popen() calls with check_output()

This commit is contained in:
Stefano Rivera 2019-09-04 12:47:48 -03:00
parent 2d3765522e
commit 23c7d67425
3 changed files with 5 additions and 8 deletions
ubuntutools

@ -34,8 +34,8 @@ class Builder(object):
def __init__(self, name): def __init__(self, name):
self.name = name self.name = name
cmd = ["dpkg-architecture", "-qDEB_BUILD_ARCH_CPU"] cmd = ["dpkg-architecture", "-qDEB_BUILD_ARCH_CPU"]
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, encoding='utf-8') self.architecture = subprocess.check_output(
self.architecture = process.communicate()[0].strip() cmd, encoding='utf-8').strip()
def _build_failure(self, returncode, dsc_file): def _build_failure(self, returncode, dsc_file):
if returncode != 0: if returncode != 0:

@ -71,8 +71,7 @@ class Patch(object):
patch_f.close() patch_f.close()
cmd = ["diffstat", "-l", "-p0", self._full_path] cmd = ["diffstat", "-l", "-p0", self._full_path]
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, encoding='utf-8') changed_files = subprocess.check_output(cmd, encoding='utf-8')
changed_files = process.communicate()[0]
self._changed_files = [f for f in changed_files.split("\n") if f != ""] self._changed_files = [f for f in changed_files.split("\n") if f != ""]
def get_strip_level(self): def get_strip_level(self):

@ -327,8 +327,7 @@ class SourcePackage(object):
if not Logger.verbose: if not Logger.verbose:
cmd.insert(1, "-q") cmd.insert(1, "-q")
Logger.command(cmd + [">", self._debdiff_filename]) Logger.command(cmd + [">", self._debdiff_filename])
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, encoding='utf-8') debdiff = subprocess.check_output(cmd, encoding='utf-8')
debdiff = process.communicate()[0]
# write debdiff file # write debdiff file
debdiff_file = open(self._debdiff_filename, "w") debdiff_file = open(self._debdiff_filename, "w")
@ -421,8 +420,7 @@ class SourcePackage(object):
self._package + "_" + self._package + "_" +
strip_epoch(self._version) + ".lintian") strip_epoch(self._version) + ".lintian")
Logger.command(cmd + [">", lintian_filename]) Logger.command(cmd + [">", lintian_filename])
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, encoding='utf-8') report = subprocess.check_output(cmd, encoding='utf-8')
report = process.communicate()[0]
# write lintian report file # write lintian report file
lintian_file = open(lintian_filename, "w") lintian_file = open(lintian_filename, "w")