Tools: add facility to print stack traces

This commit is contained in:
Peter Barker 2022-02-23 10:33:30 +11:00 committed by Peter Barker
parent 8723ec3b2a
commit e0e84880b2

View File

@ -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