Merge "Use strings in package-installs follow output"

This commit is contained in:
Jenkins 2017-02-07 05:50:40 +00:00 committed by Gerrit Code Review
commit 6372de09fe

View File

@ -14,6 +14,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from __future__ import print_function
import argparse import argparse
import json import json
import subprocess import subprocess
@ -23,18 +25,19 @@ import sys
# run a command, return output # run a command, return output
# if follow is set, output will be echoed to stdout # if follow is set, output will be echoed to stdout
def process_output(cmdline, follow=False): def process_output(cmdline, follow=False):
proc = subprocess.Popen(cmdline, stdout=subprocess.PIPE) proc = subprocess.Popen(cmdline, stdout=subprocess.PIPE,
universal_newlines=True)
if follow: if follow:
print("Running command: %s" % cmdline) print("Running command: %s" % cmdline)
out = "" out = ""
with proc.stdout: with proc.stdout:
for line in iter(proc.stdout.readline, b''): for line in iter(proc.stdout.readline, ''):
out += line.decode('utf-8') out += line
print("> %s" % line.strip()) print("> %s" % line, end="")
proc.wait() proc.wait()
print("> -- done") print("returncode: %d" % proc.returncode)
else: else:
out = proc.communicate()[0].decode('utf-8') out = proc.communicate()[0]
if proc.returncode: if proc.returncode:
e = subprocess.CalledProcessError(proc.returncode, cmdline) e = subprocess.CalledProcessError(proc.returncode, cmdline)