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

View File

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

View File

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

View File

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