From a5706a18af4f75c6db2ea7383771d67751b5b522 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Fri, 12 Feb 2021 15:13:47 +1100 Subject: [PATCH] autotest: handle Py2 not having ConnectionResetError built in --- Tools/autotest/ardusub.py | 5 +++++ Tools/autotest/common.py | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/Tools/autotest/ardusub.py b/Tools/autotest/ardusub.py index d011228e68..6afb614656 100644 --- a/Tools/autotest/ardusub.py +++ b/Tools/autotest/ardusub.py @@ -3,12 +3,17 @@ # Dive ArduSub in SITL from __future__ import print_function import os +import sys import time from pymavlink import mavutil from common import AutoTest from common import NotAchievedException +from common import AutoTestTimeoutException + +if sys.version_info[0] < 3: + ConnectionResetError = AutoTestTimeoutException # get location of scripts testdir = os.path.dirname(os.path.realpath(__file__)) diff --git a/Tools/autotest/common.py b/Tools/autotest/common.py index b997b98b0b..0905af33b8 100644 --- a/Tools/autotest/common.py +++ b/Tools/autotest/common.py @@ -91,6 +91,10 @@ class AutoTestTimeoutException(ErrorException): pass +if sys.version_info[0] < 3: + ConnectionResetError = AutoTestTimeoutException + + class WaitModeTimeout(AutoTestTimeoutException): """Thrown when fails to achieve given mode change.""" pass @@ -1559,6 +1563,11 @@ class AutoTest(ABC): pass except ConnectionResetError: pass + except socket.error: + pass + except Exception as e: + self.progress("Got unexpected exception (%s)" % str(type(e))) + pass # empty mav to avoid getting old timestamps: self.do_timesync_roundtrip(timeout_in_wallclock=True)