releasetools: Don't write outputs if not in verbose mode.
The change in [1] allows brillo_update_payload to write to stdout/stderr
directly without buffering, to ensure dumping progress to screen
continously. However, it now unconditionally writes to stdout/stderr
even if caller doesn't specify `-v`. The behavior upsets
PythonUnitTestResultParser in [2], which doesn't want any unexpected
output from stderr for result parsing.
This CL updates the logic to only give continous outputs in verbose
mode.
[1] commit 2f7e11ef27
[2] https://android.googlesource.com/platform/tools/tradefederation/+/refs/heads/master/test_framework/com/android/tradefed/testtype/PythonUnitTestResultParser.java
Test: Run ota_from_target_files.py with `-v`. Check there's continous
output from brillo_update_payload.
Test: `python -m unittest -v test_ota_from_target_files > /dev/null`
doesn't show outputs from brillo_update_payload.
Change-Id: I3b851203ef011a5b4d982948cf52793f6fb6ad2d
This commit is contained in:
@@ -517,7 +517,7 @@ class PayloadSigner(object):
|
||||
"""Signs the given input file. Returns the output filename."""
|
||||
out_file = common.MakeTempFile(prefix="signed-", suffix=".bin")
|
||||
cmd = [self.signer] + self.signer_args + ['-in', in_file, '-out', out_file]
|
||||
common.RunAndCheckOutput(cmd, stdout=None, stderr=None)
|
||||
common.RunAndCheckOutput(cmd)
|
||||
return out_file
|
||||
|
||||
|
||||
@@ -539,6 +539,15 @@ class Payload(object):
|
||||
self.payload_properties = None
|
||||
self.secondary = secondary
|
||||
|
||||
def _Run(self, cmd):
|
||||
# Don't pipe (buffer) the output if verbose is set. Let
|
||||
# brillo_update_payload write to stdout/stderr directly, so its progress can
|
||||
# be monitored.
|
||||
if OPTIONS.verbose:
|
||||
common.RunAndCheckOutput(cmd, stdout=None, stderr=None)
|
||||
else:
|
||||
common.RunAndCheckOutput(cmd)
|
||||
|
||||
def Generate(self, target_file, source_file=None, additional_args=None):
|
||||
"""Generates a payload from the given target-files zip(s).
|
||||
|
||||
@@ -559,7 +568,7 @@ class Payload(object):
|
||||
if source_file is not None:
|
||||
cmd.extend(["--source_image", source_file])
|
||||
cmd.extend(additional_args)
|
||||
common.RunAndCheckOutput(cmd, stdout=None, stderr=None)
|
||||
self._Run(cmd)
|
||||
|
||||
self.payload_file = payload_file
|
||||
self.payload_properties = None
|
||||
@@ -583,7 +592,7 @@ class Payload(object):
|
||||
"--signature_size", str(payload_signer.key_size),
|
||||
"--metadata_hash_file", metadata_sig_file,
|
||||
"--payload_hash_file", payload_sig_file]
|
||||
common.RunAndCheckOutput(cmd, stdout=None, stderr=None)
|
||||
self._Run(cmd)
|
||||
|
||||
# 2. Sign the hashes.
|
||||
signed_payload_sig_file = payload_signer.Sign(payload_sig_file)
|
||||
@@ -598,7 +607,7 @@ class Payload(object):
|
||||
"--signature_size", str(payload_signer.key_size),
|
||||
"--metadata_signature_file", signed_metadata_sig_file,
|
||||
"--payload_signature_file", signed_payload_sig_file]
|
||||
common.RunAndCheckOutput(cmd, stdout=None, stderr=None)
|
||||
self._Run(cmd)
|
||||
|
||||
# 4. Dump the signed payload properties.
|
||||
properties_file = common.MakeTempFile(prefix="payload-properties-",
|
||||
@@ -606,7 +615,7 @@ class Payload(object):
|
||||
cmd = ["brillo_update_payload", "properties",
|
||||
"--payload", signed_payload_file,
|
||||
"--properties_file", properties_file]
|
||||
common.RunAndCheckOutput(cmd, stdout=None, stderr=None)
|
||||
self._Run(cmd)
|
||||
|
||||
if self.secondary:
|
||||
with open(properties_file, "a") as f:
|
||||
|
Reference in New Issue
Block a user