summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Shan <shanyu@google.com>2017-11-17 21:14:58 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-11-17 21:14:58 +0000
commit6a90732afb6634d2cd3be453f59ab1de9286e97c (patch)
treeb6308ea049e6fc8697982c89a96ffc0e59f4ae0a
parent919b2b4d5ff7e77ec7f78a3694bd1a157d496014 (diff)
parentf3d4b3b0cfc1562cfe27a45639ba7d314a630511 (diff)
downloadattestation-6a90732afb6634d2cd3be453f59ab1de9286e97c.tar.gz
Merge "Fix the bug: subprocess not show error message."
am: f3d4b3b0cf Change-Id: I64bda9938176ea6c8f70bfb415ff9139ce67b3a1
-rw-r--r--at-factory-tool/fastbootsubp.py24
-rw-r--r--at-factory-tool/fastbootsubp_unittest.py1
2 files changed, 10 insertions, 15 deletions
diff --git a/at-factory-tool/fastbootsubp.py b/at-factory-tool/fastbootsubp.py
index 786ea2d..b121278 100644
--- a/at-factory-tool/fastbootsubp.py
+++ b/at-factory-tool/fastbootsubp.py
@@ -104,21 +104,15 @@ class FastbootDevice(object):
"""
try:
self._lock.acquire()
- if err_to_out:
- return subprocess.check_output(
- [
- FastbootDevice.fastboot_command, '-s', self.serial_number,
- 'oem', oem_command
- ],
- stderr=subprocess.STDOUT,
- creationflags=CREATE_NO_WINDOW)
- else:
- return subprocess.check_output(
- [
- FastbootDevice.fastboot_command, '-s', self.serial_number,
- 'oem', oem_command
- ],
- creationflags=CREATE_NO_WINDOW)
+ # We need to redirect the output no matter err_to_out is set
+ # So that FastbootFailure can catch the right error.
+ return subprocess.check_output(
+ [
+ FastbootDevice.fastboot_command, '-s', self.serial_number,
+ 'oem', oem_command
+ ],
+ stderr=subprocess.STDOUT,
+ creationflags=CREATE_NO_WINDOW)
except subprocess.CalledProcessError as e:
raise fastboot_exceptions.FastbootFailure(e.output)
finally:
diff --git a/at-factory-tool/fastbootsubp_unittest.py b/at-factory-tool/fastbootsubp_unittest.py
index d966bda..1514883 100644
--- a/at-factory-tool/fastbootsubp_unittest.py
+++ b/at-factory-tool/fastbootsubp_unittest.py
@@ -111,6 +111,7 @@ class FastbootSubpTest(unittest.TestCase):
message = device.Oem(command, False)
mock_fastboot_commands.assert_called_once_with(
['fastboot', '-s', self.TEST_SERIAL, 'oem', command],
+ stderr=subprocess.STDOUT,
creationflags=CREATE_NO_WINDOW)
self.assertEqual(self.TEST_MESSAGE_SUCCESS, message)