Tools: autotest.py: Moved all imports to top of file.

This commit is contained in:
Daniel Orbach 2017-08-09 15:06:50 +02:00 committed by Peter Barker
parent e951df7d50
commit befd8b028b

View File

@ -21,12 +21,13 @@ import arduplane
import quadplane import quadplane
import ardusub import ardusub
from pysim import util from pysim import util
from pymavlink import mavutil
from pymavlink.generator import mavtemplate
def get_default_params(atype, binary): def get_default_params(atype, binary):
"""Get default parameters.""" """Get default parameters."""
# use rover simulator so SITL is not starved of input # use rover simulator so SITL is not starved of input
from pymavlink import mavutil
HOME = mavutil.location(40.071374969556928, -105.22978898137808, 1583.702759, 246) HOME = mavutil.location(40.071374969556928, -105.22978898137808, 1583.702759, 246)
if "plane" in binary or "rover" in binary: if "plane" in binary or "rover" in binary:
frame = "rover" frame = "rover"
@ -66,7 +67,6 @@ def build_all():
def build_binaries(): def build_binaries():
"""Run the build_binaries.sh script.""" """Run the build_binaries.sh script."""
print("Running build_binaries.sh") print("Running build_binaries.sh")
import shutil
# copy the script as it changes git branch, which can change the script while running # copy the script as it changes git branch, which can change the script while running
orig = util.reltopdir('Tools/scripts/build_binaries.sh') orig = util.reltopdir('Tools/scripts/build_binaries.sh')
copy = util.reltopdir('./build_binaries.sh') copy = util.reltopdir('./build_binaries.sh')
@ -81,7 +81,6 @@ def build_binaries():
def build_devrelease(): def build_devrelease():
"""Run the build_devrelease.sh script.""" """Run the build_devrelease.sh script."""
print("Running build_devrelease.sh") print("Running build_devrelease.sh")
import shutil
# copy the script as it changes git branch, which can change the script while running # copy the script as it changes git branch, which can change the script while running
orig = util.reltopdir('Tools/scripts/build_devrelease.sh') orig = util.reltopdir('Tools/scripts/build_devrelease.sh')
copy = util.reltopdir('./build_devrelease.sh') copy = util.reltopdir('./build_devrelease.sh')
@ -118,7 +117,6 @@ def build_parameters():
def convert_gpx(): def convert_gpx():
"""Convert any tlog files to GPX and KML.""" """Convert any tlog files to GPX and KML."""
import glob
mavlog = glob.glob(util.reltopdir("../buildlogs/*.tlog")) mavlog = glob.glob(util.reltopdir("../buildlogs/*.tlog"))
for m in mavlog: for m in mavlog:
util.run_cmd(util.reltopdir("modules/mavlink/pymavlink/tools/mavtogpx.py") + " --nofixcheck " + m) util.run_cmd(util.reltopdir("modules/mavlink/pymavlink/tools/mavtogpx.py") + " --nofixcheck " + m)
@ -309,20 +307,17 @@ class TestResults(object):
def addglob(self, name, pattern): def addglob(self, name, pattern):
"""Add a set of files.""" """Add a set of files."""
import glob
for f in glob.glob(util.reltopdir('../buildlogs/%s' % pattern)): for f in glob.glob(util.reltopdir('../buildlogs/%s' % pattern)):
self.addfile(name, os.path.basename(f)) self.addfile(name, os.path.basename(f))
def addglobimage(self, name, pattern): def addglobimage(self, name, pattern):
"""Add a set of images.""" """Add a set of images."""
import glob
for f in glob.glob(util.reltopdir('../buildlogs/%s' % pattern)): for f in glob.glob(util.reltopdir('../buildlogs/%s' % pattern)):
self.addimage(name, os.path.basename(f)) self.addimage(name, os.path.basename(f))
def write_webresults(results_to_write): def write_webresults(results_to_write):
"""Write webpage results.""" """Write webpage results."""
from pymavlink.generator import mavtemplate
t = mavtemplate.MAVTemplate() t = mavtemplate.MAVTemplate()
for h in glob.glob(util.reltopdir('Tools/autotest/web/*.html')): for h in glob.glob(util.reltopdir('Tools/autotest/web/*.html')):
html = util.loadfile(h) html = util.loadfile(h)