diff --git a/Tools/autotest/apmrover2.py b/Tools/autotest/apmrover2.py index cb65d0c9f931c1f84095fcbb38e80328bd9a49b9..5a430a55087cae88fd95e574689e0454fd8f4cd6 100644 --- a/Tools/autotest/apmrover2.py +++ b/Tools/autotest/apmrover2.py @@ -1,5 +1,5 @@ # drive APMrover2 in SITL - +from __future__ import print_function import os import shutil @@ -188,7 +188,7 @@ def drive_APMrover2(binary, viewerip=None, use_map=False, valgrind=False, gdb=Fa valgrind_log = util.valgrind_log_filepath(binary=binary, model='rover') if os.path.exists(valgrind_log): - os.chmod(valgrind_log, 0644) + os.chmod(valgrind_log, 0o644) shutil.copy(valgrind_log, util.reltopdir("../buildlogs/APMrover2-valgrind.log")) if failed: diff --git a/Tools/autotest/arducopter.py b/Tools/autotest/arducopter.py index ce1910d0562b0d69d0fd3ec15b6b45e6b68f540c..b45e59012de407089b09b95dbb4f65ef3ec2e729 100644 --- a/Tools/autotest/arducopter.py +++ b/Tools/autotest/arducopter.py @@ -6,7 +6,7 @@ # switch 4 = Auto # switch 5 = Loiter # switch 6 = Stabilize - +from __future__ import print_function import math import os import shutil @@ -1291,7 +1291,7 @@ def fly_ArduCopter(binary, viewerip=None, use_map=False, valgrind=False, gdb=Fal valgrind_log = util.valgrind_log_filepath(binary=binary, model='+') if os.path.exists(valgrind_log): - os.chmod(valgrind_log, 0644) + os.chmod(valgrind_log, 0o644) shutil.copy(valgrind_log, util.reltopdir("../buildlogs/ArduCopter-valgrind.log")) # [2014/05/07] FC Because I'm doing a cross machine build (source is on host, build is on guest VM) I cannot hard link @@ -1418,7 +1418,7 @@ def fly_CopterAVC(binary, viewerip=None, use_map=False, valgrind=False, gdb=Fals valgrind_log = util.valgrind_log_filepath(binary=binary, model='heli') if os.path.exists(valgrind_log): - os.chmod(valgrind_log, 0644) + os.chmod(valgrind_log, 0o644) shutil.copy(valgrind_log, util.reltopdir("../buildlogs/Helicopter-valgrind.log")) if failed: diff --git a/Tools/autotest/arduplane.py b/Tools/autotest/arduplane.py index bdc76c1df03fef62ce95a1a5730c9c47cab83774..1c454ee2699d368b5fad618c035f332130872aea 100644 --- a/Tools/autotest/arduplane.py +++ b/Tools/autotest/arduplane.py @@ -1,5 +1,5 @@ # Fly ArduPlane in SITL - +from __future__ import print_function import math import os import shutil @@ -565,7 +565,7 @@ def fly_ArduPlane(binary, viewerip=None, use_map=False, valgrind=False, gdb=Fals valgrind_log = util.valgrind_log_filepath(binary=binary, model='plane-elevrev') if os.path.exists(valgrind_log): - os.chmod(valgrind_log, 0644) + os.chmod(valgrind_log, 0o644) shutil.copy(valgrind_log, util.reltopdir("../buildlogs/ArduPlane-valgrind.log")) if failed: diff --git a/Tools/autotest/autotest.py b/Tools/autotest/autotest.py index 66cebdf45e0a9806a31b471e17c70efd996764fc..6fce9aaac1427c59fbab2b5fff67259c91d2bfb4 100755 --- a/Tools/autotest/autotest.py +++ b/Tools/autotest/autotest.py @@ -3,7 +3,7 @@ APM automatic test suite Andrew Tridgell, October 2011 """ - +from __future__ import print_function import atexit import fnmatch import glob diff --git a/Tools/autotest/common.py b/Tools/autotest/common.py index ec87bea9785929e3a5dfc27be61985d3ae8ad97e..ba9a40fccd080340c1912aa0f42947ce40d3c663 100644 --- a/Tools/autotest/common.py +++ b/Tools/autotest/common.py @@ -1,3 +1,4 @@ +from __future__ import print_function import math import time diff --git a/Tools/autotest/dump_logs.py b/Tools/autotest/dump_logs.py index 44c75d99a28448044cd495ae6cbad4195fcf04b6..b3c8528824943ba9c717d7b13712b768f93bacf6 100755 --- a/Tools/autotest/dump_logs.py +++ b/Tools/autotest/dump_logs.py @@ -3,7 +3,7 @@ dump flash logs from SITL Andrew Tridgell, April 2013 """ - +from __future__ import print_function import optparse import os import sys diff --git a/Tools/autotest/fakepos.py b/Tools/autotest/fakepos.py index 9e62661d9b4627c813556c5650509d94b925e840..c6a2846a2e770191dfd62ab72a9d4560d2b868c4 100755 --- a/Tools/autotest/fakepos.py +++ b/Tools/autotest/fakepos.py @@ -1,5 +1,5 @@ #!/usr/bin/env python - +from __future__ import print_function import errno import socket import struct diff --git a/Tools/autotest/jsb_sim/runsim.py b/Tools/autotest/jsb_sim/runsim.py index cf4f12ece0188e00b0bc99959eca4ff917b61278..439dee334f1eb7491f06a1183ccb7cf6690b726a 100755 --- a/Tools/autotest/jsb_sim/runsim.py +++ b/Tools/autotest/jsb_sim/runsim.py @@ -2,7 +2,7 @@ """ Run a jsbsim model as a child process. """ - +from __future__ import print_function import atexit import errno import fdpexpect diff --git a/Tools/autotest/param_metadata/param_parse.py b/Tools/autotest/param_metadata/param_parse.py index 315c7d4638b3202562fac0c7d8343640d30ec8b4..927ddb50b326b62247e1420946cd397be8b1a52e 100755 --- a/Tools/autotest/param_metadata/param_parse.py +++ b/Tools/autotest/param_metadata/param_parse.py @@ -1,5 +1,5 @@ #!/usr/bin/env python - +from __future__ import print_function import glob import os import re diff --git a/Tools/autotest/param_metadata/rstemit.py b/Tools/autotest/param_metadata/rstemit.py index 403aa9081a37c8567c5774e23c85c04cf8a6773f..da5b7f8db8f17a8ef507e8a90cbaa9bb527374bc 100644 --- a/Tools/autotest/param_metadata/rstemit.py +++ b/Tools/autotest/param_metadata/rstemit.py @@ -1,5 +1,5 @@ #!/usr/bin/env python - +from __future__ import print_function import re from param import known_param_fields from emit import Emit @@ -254,7 +254,7 @@ def table_test(): print(e.tablify([["A", "B"], ["C", "D"]])) print("Test 2") - print e.tablify([["A", "B"], ["CD\nE", "FG"]]) + print(e.tablify([["A", "B"], ["CD\nE", "FG"]])) print("Test 3") print(e.tablify([["A", "B"], ["CD\nEF", "GH"]], rowheadings=["r1", "row2"])) diff --git a/Tools/autotest/pysim/fdpexpect.py b/Tools/autotest/pysim/fdpexpect.py index c1f5059077e3396fb9c0eae39b75f81198611e14..4ffd94688d6ade7c3a73f1e6c0923959d958679d 100644 --- a/Tools/autotest/pysim/fdpexpect.py +++ b/Tools/autotest/pysim/fdpexpect.py @@ -3,7 +3,7 @@ So you are responsible for opening and close the file descriptor. $Id: fdpexpect.py 505 2007-12-26 21:33:50Z noah $ """ - +from __future__ import print_function import os from pexpect import ExceptionPexpect, spawn diff --git a/Tools/autotest/pysim/rotmat.py b/Tools/autotest/pysim/rotmat.py index 0e042208da36ff71a52b530ad8f3529931606b9d..ef3eaa71040021dfbc278eef1c31c88a8f717480 100644 --- a/Tools/autotest/pysim/rotmat.py +++ b/Tools/autotest/pysim/rotmat.py @@ -21,7 +21,7 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA """ - +from __future__ import print_function from math import acos, asin, atan2, cos, pi, radians, sin, sqrt diff --git a/Tools/autotest/pysim/testwind.py b/Tools/autotest/pysim/testwind.py index a4b0ba98a63aad6aad05ac0e4350d0405c782509..92934bff8bfe78a6a87917495ed4e2eac6c27c35 100755 --- a/Tools/autotest/pysim/testwind.py +++ b/Tools/autotest/pysim/testwind.py @@ -2,7 +2,7 @@ """ simple test of wind generation code """ - +from __future__ import print_function import time import util from rotmat import Vector3 diff --git a/Tools/autotest/pysim/util.py b/Tools/autotest/pysim/util.py index bac35c28d55f0a220dc13b583b266ef0c426f1e5..746846779c575cc0b26cd858310578194fadd514 100644 --- a/Tools/autotest/pysim/util.py +++ b/Tools/autotest/pysim/util.py @@ -1,3 +1,4 @@ +from __future__ import print_function import math import os import random @@ -9,8 +10,12 @@ from subprocess import PIPE, Popen, call, check_call import pexpect -from rotmat import Matrix3, Vector3 +from . rotmat import Matrix3, Vector3 +if (sys.version_info[0] >= 3): + ENCODING = 'ascii' +else: + ENCODING = None def m2ft(x): """Meters to feet.""" @@ -211,7 +216,7 @@ def start_SITL(binary, valgrind=False, gdb=False, wipe=False, synthetic_clock=Tr print("Running: %s" % cmd_as_shell(cmd)) first = cmd[0] rest = cmd[1:] - child = pexpect.spawn(first, rest, logfile=sys.stdout, timeout=5) + child = pexpect.spawn(first, rest, logfile=sys.stdout, encoding=ENCODING, timeout=5) delaybeforesend = 0 pexpect_autoclose(child) # give time for parameters to properly setup @@ -224,7 +229,7 @@ def start_SITL(binary, valgrind=False, gdb=False, wipe=False, synthetic_clock=Tr # TODO: have a SITL-compiled ardupilot able to have its # console on an output fd. else: - child.expect(u'Waiting for connection', timeout=300) + child.expect('Waiting for connection', timeout=300) return child @@ -242,7 +247,7 @@ def start_MAVProxy_SITL(atype, aircraft=None, setup=False, master='tcp:127.0.0.1 cmd += ' --aircraft=%s' % aircraft if options is not None: cmd += ' ' + options - ret = pexpect.spawn(cmd, logfile=logfile, timeout=60) + ret = pexpect.spawn(cmd, logfile=logfile, encoding=ENCODING, timeout=60) ret.delaybeforesend = 0 pexpect_autoclose(ret) return ret diff --git a/Tools/autotest/quadplane.py b/Tools/autotest/quadplane.py index 1a69ee222df5068259532982edb8ed92eb471663..cf5cddfaf410b6542ac443d1040532b088f97601 100644 --- a/Tools/autotest/quadplane.py +++ b/Tools/autotest/quadplane.py @@ -1,5 +1,5 @@ # fly ArduPlane QuadPlane in SITL - +from __future__ import print_function import os import pexpect import shutil @@ -126,7 +126,7 @@ def fly_QuadPlane(binary, viewerip=None, use_map=False, valgrind=False, gdb=Fals valgrind_log = util.valgrind_log_filepath(binary=binary, model='quadplane') if os.path.exists(valgrind_log): - os.chmod(valgrind_log, 0644) + os.chmod(valgrind_log, 0o644) shutil.copy(valgrind_log, util.reltopdir("../buildlogs/QuadPlane-valgrind.log")) if failed: