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.
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 @@
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: