summaryrefslogtreecommitdiff
path: root/cli/cros/cros_shell.py
diff options
context:
space:
mode:
authorMike Frysinger <vapier@chromium.org>2015-06-03 05:03:34 -0400
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-06-05 19:35:04 +0000
commit684d36eea4096e82c26e93dcf2ee93295dbe3e92 (patch)
tree6afe937a7259a804c2cdae1aa14a4651afe3db11 /cli/cros/cros_shell.py
parent7f96d9f336d1cc8403c63ef73ff1401e4ad2b190 (diff)
downloadchromite-684d36eea4096e82c26e93dcf2ee93295dbe3e92.tar.gz
cli: standardize --debug/exception display
Each tool implements this slightly different (if at all). Pull it back out and into the main runner so we get standard behvaior for all tools. BUG=None TEST=`cros flash ...` shows short error message TEST=`cros --debug flash ...` shows full traceback TEST=`./cbuildbot/run_tests` passes CQ-DEPEND=CL:275395 Change-Id: Icbdc23a63dccbd8afee02bb48ef80f16323f5073 Reviewed-on: https://chromium-review.googlesource.com/274895 Tested-by: Mike Frysinger <vapier@chromium.org> Reviewed-by: Gilad Arnold <garnold@chromium.org> Commit-Queue: Mike Frysinger <vapier@chromium.org>
Diffstat (limited to 'cli/cros/cros_shell.py')
-rw-r--r--cli/cros/cros_shell.py38
1 files changed, 15 insertions, 23 deletions
diff --git a/cli/cros/cros_shell.py b/cli/cros/cros_shell.py
index 9cae92248..ed2a3f0d5 100644
--- a/cli/cros/cros_shell.py
+++ b/cli/cros/cros_shell.py
@@ -174,27 +174,19 @@ Quoting can be tricky; the rules are the same as with ssh:
"""Runs `cros shell`."""
self.options.Freeze()
self._ReadOptions()
- # Nested try blocks so the inner can raise to the outer, which handles
- # overall failures.
try:
- try:
- return self._StartSsh()
- except remote_access.SSHConnectionError as e:
- # Handle a mismatched host key; mismatched keys are a bit of a pain to
- # fix manually since `ssh-keygen -R` doesn't work within the chroot.
- if e.IsKnownHostsMismatch():
- # The full SSH error message has extra info for the user.
- logging.warning('\n%s', e)
- if self._UserConfirmKeyChange():
- remote_access.RemoveKnownHost(self.device.hostname)
- # The user already OK'd so we can skip the additional SSH check.
- self.host_key_checking = 'no'
- return self._StartSsh()
- else:
- return 1
- raise
- except Exception as e:
- logging.error(e)
- if self.options.debug:
- raise
- return 1
+ return self._StartSsh()
+ except remote_access.SSHConnectionError as e:
+ # Handle a mismatched host key; mismatched keys are a bit of a pain to
+ # fix manually since `ssh-keygen -R` doesn't work within the chroot.
+ if e.IsKnownHostsMismatch():
+ # The full SSH error message has extra info for the user.
+ logging.warning('\n%s', e)
+ if self._UserConfirmKeyChange():
+ remote_access.RemoveKnownHost(self.device.hostname)
+ # The user already OK'd so we can skip the additional SSH check.
+ self.host_key_checking = 'no'
+ return self._StartSsh()
+ else:
+ return 1
+ raise