From efbf63042254a5dbcfb31bb7c702558343302008 Mon Sep 17 00:00:00 2001
From: Marc Bonnici <marc.bonnici@arm.com>
Date: Wed, 21 Nov 2018 14:02:20 +0000
Subject: [PATCH] utils/ssh: Remove original traceback from exception

In Python 3 when re-raising an exception the original traceback will
also be included. In the `_scp` method we do not want to expose the
password so hide the original exception when re-raising.
---
 devlib/utils/ssh.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/devlib/utils/ssh.py b/devlib/utils/ssh.py
index f59ea7c..74ece66 100644
--- a/devlib/utils/ssh.py
+++ b/devlib/utils/ssh.py
@@ -27,6 +27,7 @@ import sys
 import time
 import atexit
 from pipes import quote
+from future.utils import raise_from
 
 # pylint: disable=import-error,wrong-import-position,ungrouped-imports,wrong-import-order
 import pexpect
@@ -315,8 +316,8 @@ class SshConnection(object):
         try:
             check_output(command, timeout=timeout, shell=True)
         except subprocess.CalledProcessError as e:
-            raise HostError("Failed to copy file with '{}'. Output:\n{}".format(
-                command_redacted, e.output))
+            raise_from(HostError("Failed to copy file with '{}'. Output:\n{}".format(
+                command_redacted, e.output)), None)
         except TimeoutError as e:
             raise TimeoutError(command_redacted, e.output)