From 179e45f98e8e227380eb9ab90b4abb3d8d9be839 Mon Sep 17 00:00:00 2001 From: Brendan Jackman Date: Tue, 31 Jan 2017 19:21:11 +0000 Subject: [PATCH] LocalConnection: Enrich TargetError message from execute method Add exit code, command, and output to TargetError exception message when execute fails. This brings LocalConnection into line with AdbConnection and SshConnection. --- devlib/host.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/devlib/host.py b/devlib/host.py index 510de44..121e5b4 100644 --- a/devlib/host.py +++ b/devlib/host.py @@ -60,7 +60,9 @@ class LocalConnection(object): try: return check_output(command, shell=True, timeout=timeout, ignore=ignore)[0] except subprocess.CalledProcessError as e: - raise TargetError(e) + message = 'Got exit code {}\nfrom: {}\nOUTPUT: {}'.format( + e.returncode, command, e.output) + raise TargetError(message) def background(self, command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, as_root=False): if as_root: