From 68e5e8386473ccfd08b180f2f81e05cd44aa1c78 Mon Sep 17 00:00:00 2001 From: Patrick Bellasi Date: Mon, 12 Oct 2015 18:31:32 +0100 Subject: [PATCH] utils/serial_port: fix fdpexpect import for pexpect versions >= 4.0 The pexpect module exposes a fdpexpect class starting from version 4.0. This patch makes uses of the proper pxssh import statement depending on the version of pexpect available in the host. Signed-off-by: Patrick Bellasi --- devlib/utils/serial_port.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/devlib/utils/serial_port.py b/devlib/utils/serial_port.py index 62df065..d1410a4 100644 --- a/devlib/utils/serial_port.py +++ b/devlib/utils/serial_port.py @@ -19,7 +19,13 @@ from contextlib import contextmanager from logging import Logger import serial -import fdpexpect + +import pexpect +from distutils.version import StrictVersion as V +if V(pexpect.__version__) < V('4.0.0'): + import fdpexpect +else: + from pexpect import fdpexpect # Adding pexpect exceptions into this module's namespace from pexpect import EOF, TIMEOUT # NOQA pylint: disable=W0611