diff options
-rw-r--r-- | at-factory-tool/fastbootsubp.py | 24 | ||||
-rw-r--r-- | at-factory-tool/fastbootsubp_unittest.py | 1 |
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) |