diff options
Diffstat (limited to 'meta/lib/oeqa/utils/sshcontrol.py')
-rw-r--r-- | meta/lib/oeqa/utils/sshcontrol.py | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/meta/lib/oeqa/utils/sshcontrol.py b/meta/lib/oeqa/utils/sshcontrol.py index f5d46e03cc..36c2ecb3db 100644 --- a/meta/lib/oeqa/utils/sshcontrol.py +++ b/meta/lib/oeqa/utils/sshcontrol.py @@ -1,7 +1,8 @@ -# -*- coding: utf-8 -*- +# # Copyright (C) 2013 Intel Corporation # -# Released under the MIT license (see COPYING.MIT) +# SPDX-License-Identifier: MIT +# # Provides a class for setting up ssh connections, # running commands and copying files to/from a target. @@ -22,7 +23,7 @@ class SSHProcess(object): "stdin": None, "shell": False, "bufsize": -1, - "preexec_fn": os.setsid, + "start_new_session": True, } self.options = dict(self.defaultopts) self.options.update(options) @@ -52,17 +53,19 @@ class SSHProcess(object): endtime = self.starttime + timeout eof = False while time.time() < endtime and not eof: - if select.select([self.process.stdout], [], [], 5)[0] != []: - data = os.read(self.process.stdout.fileno(), 1024) - if not data: - self.process.stdout.close() - eof = True - else: - data = data.decode("utf-8") - output += data - self.log(data) - endtime = time.time() + timeout - + try: + if select.select([self.process.stdout], [], [], 5)[0] != []: + data = os.read(self.process.stdout.fileno(), 1024) + if not data: + self.process.stdout.close() + eof = True + else: + data = data.decode("utf-8") + output += data + self.log(data) + endtime = time.time() + timeout + except InterruptedError: + continue # process hasn't returned yet if not eof: @@ -147,6 +150,8 @@ class SSHControl(object): return self._internal_run(command, timeout, self.ignore_status) def copy_to(self, localpath, remotepath): + if os.path.islink(localpath): + localpath = os.path.dirname(localpath) + "/" + os.readlink(localpath) command = self.scp + [localpath, '%s@%s:%s' % (self.user, self.ip, remotepath)] return self._internal_run(command, ignore_status=False) |