autotest: make pysim/util.py AP_FLAKE8_CLEAN
This commit is contained in:
parent
3127af1af6
commit
e182675bc8
@ -1,5 +1,9 @@
|
||||
from __future__ import print_function
|
||||
|
||||
'''
|
||||
AP_FLAKE8_CLEAN
|
||||
'''
|
||||
|
||||
import atexit
|
||||
import math
|
||||
import os
|
||||
@ -24,10 +28,10 @@ else:
|
||||
|
||||
RADIUS_OF_EARTH = 6378100.0 # in meters
|
||||
|
||||
|
||||
# List of open terminal windows for macosx
|
||||
windowID = []
|
||||
|
||||
|
||||
def m2ft(x):
|
||||
"""Meters to feet."""
|
||||
return float(x) / 0.3048
|
||||
@ -57,10 +61,12 @@ def topdir():
|
||||
d = os.path.dirname(d)
|
||||
return d
|
||||
|
||||
|
||||
def relcurdir(path):
|
||||
"""Return a path relative to current dir"""
|
||||
return os.path.relpath(path, os.getcwd())
|
||||
|
||||
|
||||
def reltopdir(path):
|
||||
"""Returns the normalized ABSOLUTE path for 'path', where path is a path relative to topdir"""
|
||||
return os.path.normpath(os.path.join(topdir(), path))
|
||||
@ -99,7 +105,19 @@ def relwaf():
|
||||
return "./modules/waf/waf-light"
|
||||
|
||||
|
||||
def waf_configure(board, j=None, debug=False, math_check_indexes=False, coverage=False, ekf_single=False, postype_single=False, sitl_32bit=False, extra_args=[], extra_hwdef=None, ubsan=False, ubsan_abort=False, extra_defines={}):
|
||||
def waf_configure(board,
|
||||
j=None,
|
||||
debug=False,
|
||||
math_check_indexes=False,
|
||||
coverage=False,
|
||||
ekf_single=False,
|
||||
postype_single=False,
|
||||
sitl_32bit=False,
|
||||
extra_args=[],
|
||||
extra_hwdef=None,
|
||||
ubsan=False,
|
||||
ubsan_abort=False,
|
||||
extra_defines={}):
|
||||
cmd_configure = [relwaf(), "configure", "--board", board]
|
||||
if debug:
|
||||
cmd_configure.append('--debug')
|
||||
@ -139,6 +157,7 @@ def waf_build(target=None):
|
||||
cmd.append(target)
|
||||
run_cmd(cmd, directory=topdir(), checkfail=True)
|
||||
|
||||
|
||||
def build_SITL(
|
||||
build_target,
|
||||
board='sitl',
|
||||
@ -210,6 +229,7 @@ def build_examples(board, j=None, debug=False, clean=False, configure=True, math
|
||||
run_cmd(cmd_make, directory=topdir(), checkfail=True, show=True)
|
||||
return True
|
||||
|
||||
|
||||
def build_replay(board, j=None, debug=False, clean=False):
|
||||
# first configure
|
||||
waf_configure(board, j=j, debug=debug)
|
||||
@ -223,8 +243,20 @@ def build_replay(board, j=None, debug=False, clean=False):
|
||||
run_cmd(cmd_make, directory=topdir(), checkfail=True, show=True)
|
||||
return True
|
||||
|
||||
def build_tests(board, j=None, debug=False, clean=False, configure=True, math_check_indexes=False, coverage=False,
|
||||
ekf_single=False, postype_single=False, sitl_32bit=False, ubsan=False, ubsan_abort=False, extra_configure_args=[]):
|
||||
|
||||
def build_tests(board,
|
||||
j=None,
|
||||
debug=False,
|
||||
clean=False,
|
||||
configure=True,
|
||||
math_check_indexes=False,
|
||||
coverage=False,
|
||||
ekf_single=False,
|
||||
postype_single=False,
|
||||
sitl_32bit=False,
|
||||
ubsan=False,
|
||||
ubsan_abort=False,
|
||||
extra_configure_args=[]):
|
||||
|
||||
# first configure
|
||||
if configure:
|
||||
@ -248,6 +280,7 @@ def build_tests(board, j=None, debug=False, clean=False, configure=True, math_ch
|
||||
run_cmd([relwaf(), "tests"], directory=topdir(), checkfail=True, show=True)
|
||||
return True
|
||||
|
||||
|
||||
# list of pexpect children to close on exit
|
||||
close_list = []
|
||||
|
||||
@ -299,7 +332,6 @@ def pexpect_close_all():
|
||||
|
||||
def pexpect_drain(p):
|
||||
"""Drain any pending input."""
|
||||
import pexpect
|
||||
try:
|
||||
p.read_nonblocking(1000, timeout=0)
|
||||
except Exception:
|
||||
@ -326,13 +358,15 @@ def kill_screen_gdb():
|
||||
cmd = ["screen", "-X", "-S", "ardupilot-gdb", "quit"]
|
||||
subprocess.Popen(cmd)
|
||||
|
||||
|
||||
def kill_mac_terminal():
|
||||
global windowID
|
||||
for window in windowID:
|
||||
cmd = ("osascript -e \'tell application \"Terminal\" to close "
|
||||
"(window(get index of window id %s))\'" % window)
|
||||
"(window(get index of window id %s))\'" % window)
|
||||
os.system(cmd)
|
||||
|
||||
|
||||
def start_SITL(binary,
|
||||
valgrind=False,
|
||||
callgrind=False,
|
||||
@ -422,7 +456,7 @@ def start_SITL(binary,
|
||||
if sys.platform == "darwin" and os.getenv('DISPLAY'):
|
||||
cmd.extend(['lldb', '-s', '/tmp/x.lldb', '--'])
|
||||
elif os.environ.get('DISPLAY'):
|
||||
cmd.extend(['xterm', '-e', 'lldb', '-s','/tmp/x.lldb', '--'])
|
||||
cmd.extend(['xterm', '-e', 'lldb', '-s', '/tmp/x.lldb', '--'])
|
||||
else:
|
||||
raise RuntimeError("DISPLAY was not set")
|
||||
|
||||
@ -449,7 +483,7 @@ def start_SITL(binary,
|
||||
# somewhere for MAVProxy to connect to:
|
||||
cmd.append('--uartC=tcp:2')
|
||||
if not enable_fgview_output:
|
||||
cmd.append("--disable-fgview");
|
||||
cmd.append("--disable-fgview")
|
||||
|
||||
cmd.extend(customisations)
|
||||
|
||||
@ -461,7 +495,7 @@ def start_SITL(binary,
|
||||
mydir = os.path.dirname(os.path.realpath(__file__))
|
||||
autotest_dir = os.path.realpath(os.path.join(mydir, '..'))
|
||||
runme = [os.path.join(autotest_dir, "run_in_terminal_window.sh"), 'mactest']
|
||||
runme.extend(cmd)
|
||||
runme.extend(cmd)
|
||||
print(runme)
|
||||
print(cmd)
|
||||
out = subprocess.Popen(runme, stdout=subprocess.PIPE).communicate()[0]
|
||||
@ -496,7 +530,6 @@ def start_SITL(binary,
|
||||
else:
|
||||
print("Running: %s" % cmd_as_shell(cmd))
|
||||
|
||||
|
||||
first = cmd[0]
|
||||
rest = cmd[1:]
|
||||
child = pexpect.spawn(first, rest, logfile=sys.stdout, encoding=ENCODING, timeout=5)
|
||||
@ -519,6 +552,7 @@ def mavproxy_cmd():
|
||||
'''return path to which mavproxy to use'''
|
||||
return os.getenv('MAVPROXY_CMD', 'mavproxy.py')
|
||||
|
||||
|
||||
def MAVProxy_version():
|
||||
'''return the current version of mavproxy as a tuple e.g. (1,8,8)'''
|
||||
command = "%s --version" % mavproxy_cmd()
|
||||
@ -529,6 +563,7 @@ def MAVProxy_version():
|
||||
raise ValueError("Unable to determine MAVProxy version from (%s)" % output)
|
||||
return (int(match.group(1)), int(match.group(2)), int(match.group(3)))
|
||||
|
||||
|
||||
def start_MAVProxy_SITL(atype,
|
||||
aircraft=None,
|
||||
setup=False,
|
||||
@ -865,6 +900,7 @@ def constrain(value, minv, maxv):
|
||||
value = maxv
|
||||
return value
|
||||
|
||||
|
||||
def load_local_module(fname):
|
||||
'''load a python module from within the ardupilot tree'''
|
||||
fname = os.path.join(topdir(), fname)
|
||||
|
Loading…
Reference in New Issue
Block a user