From e0e84880b2d2ace6c3102c3b4dea302f841bdc42 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Wed, 23 Feb 2022 10:33:30 +1100 Subject: [PATCH] Tools: add facility to print stack traces --- Tools/scripts/build_binaries.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Tools/scripts/build_binaries.py b/Tools/scripts/build_binaries.py index 6b71885a21..e2092d425b 100755 --- a/Tools/scripts/build_binaries.py +++ b/Tools/scripts/build_binaries.py @@ -19,6 +19,7 @@ import time import string import subprocess import sys +import traceback import gzip # local imports @@ -508,6 +509,7 @@ is bob we will attempt to checkout bob-AVR''' try: self.copyit(path, ddir, tag, vehicle) except Exception as e: + self.print_exception_caught(e) self.progress("Failed to copy %s to %s: %s" % (path, ddir, str(e))) # why is touching this important? -pb20170816 self.touch_filepath(os.path.join(self.binaries, @@ -518,6 +520,19 @@ is bob we will attempt to checkout bob-AVR''' self.checkout(vehicle, "latest") + def get_exception_stacktrace(self, e): + if sys.version_info[0] >= 3: + ret = "%s\n" % e + ret += ''.join(traceback.format_exception(etype=type(e), + value=e, + tb=e.__traceback__)) + return ret + return traceback.format_exc(e) + + def print_exception_caught(self, e, send_statustext=True): + self.progress("Exception caught: %s" % + self.get_exception_stacktrace(e)) + def common_boards(self): '''returns list of boards common to all vehicles''' return AUTOBUILD_BOARDS