From 57c498b5702ab49a80508b27e4917b6dfbff174e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 26 Mar 2013 08:12:57 +1100 Subject: [PATCH] autotest: remove dependency on pexpect for rover/copter sim this makes it easier to run on windows --- Tools/autotest/pysim/util.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Tools/autotest/pysim/util.py b/Tools/autotest/pysim/util.py index 3036999b48..4daab0bd12 100644 --- a/Tools/autotest/pysim/util.py +++ b/Tools/autotest/pysim/util.py @@ -1,6 +1,6 @@ import math from math import sqrt, acos, cos, pi, sin, atan2 -import os, pexpect, sys, time, random +import os, sys, time, random from rotmat import Vector3, Matrix3 from subprocess import call, check_call,Popen, PIPE @@ -110,6 +110,7 @@ def pexpect_close_all(): def pexpect_drain(p): '''drain any pending input''' + import pexpect try: p.read_nonblocking(1000, timeout=0) except pexpect.TIMEOUT: @@ -117,6 +118,7 @@ def pexpect_drain(p): def start_SIL(atype, valgrind=False, wipe=False, height=None): '''launch a SIL instance''' + import pexpect cmd="" if valgrind and os.path.exists('/usr/bin/valgrind'): cmd += 'valgrind -q --log-file=%s-valgrind.log ' % atype @@ -134,6 +136,7 @@ def start_SIL(atype, valgrind=False, wipe=False, height=None): def start_MAVProxy_SIL(atype, aircraft=None, setup=False, master='tcp:127.0.0.1:5760', options=None, logfile=sys.stdout): '''launch mavproxy connected to a SIL instance''' + import pexpect global close_list MAVPROXY = os.getenv('MAVPROXY_CMD', reltopdir('../MAVProxy/mavproxy.py')) cmd = MAVPROXY + ' --master=%s --out=127.0.0.1:14550' % master @@ -153,6 +156,7 @@ def start_MAVProxy_SIL(atype, aircraft=None, setup=False, master='tcp:127.0.0.1: def expect_setup_callback(e, callback): '''setup a callback that is called once a second while waiting for patterns''' + import pexpect def _expect_callback(pattern, timeout=e.timeout): tstart = time.time() while time.time() < tstart + timeout: