diff --git a/Tools/autotest/autotest.py b/Tools/autotest/autotest.py index e917941145..6a9aed6bc6 100755 --- a/Tools/autotest/autotest.py +++ b/Tools/autotest/autotest.py @@ -10,6 +10,11 @@ from __future__ import print_function import atexit import fnmatch import copy +try: + import distutils.dir_util +except ImportError: + # we copy with this with try/except in copy_tree, below + pass import glob import optparse import os @@ -20,7 +25,6 @@ import subprocess import sys import time import traceback -from distutils.dir_util import copy_tree import rover import arducopter @@ -661,6 +665,13 @@ class TestResults(object): f.write(badge) +def copy_tree(f, t, dirs_exist_ok=False): + try: + distutils.dir_util.copy_tree(f, t) + except Exception: + shutil.copytree(f, t, dirs_exist_ok=dirs_exist_ok) + + def write_webresults(results_to_write): """Write webpage results.""" t = mavtemplate.MAVTemplate() @@ -671,7 +682,7 @@ def write_webresults(results_to_write): f.close() for f in glob.glob(util.reltopdir('Tools/autotest/web/*.png')): shutil.copy(f, buildlogs_path(os.path.basename(f))) - copy_tree(util.reltopdir("Tools/autotest/web/css"), buildlogs_path("css")) + copy_tree(util.reltopdir("Tools/autotest/web/css"), buildlogs_path("css"), dirs_exist_ok=True) results_to_write.generate_badge()