Skip to content
Snippets Groups Projects
Commit 34c2513d authored by Timo Koch's avatar Timo Koch Committed by Dennis Gläser
Browse files

[ci][getpiplineinfo] improve traceback handling

parent 90dd0156
No related branches found
No related tags found
1 merge request!2644Feature/continuous master pipeline status
Pipeline #4729 waiting for manual action
...@@ -2,6 +2,7 @@ import os ...@@ -2,6 +2,7 @@ import os
import sys import sys
import functools import functools
import subprocess import subprocess
import traceback
def getCommandErrorHints(command): def getCommandErrorHints(command):
...@@ -19,19 +20,19 @@ def runCommand(command, suppressTraceBack=False, errorMessage=''): ...@@ -19,19 +20,19 @@ def runCommand(command, suppressTraceBack=False, errorMessage=''):
shell=True, check=True, shell=True, check=True,
text=True, capture_output=True).stdout text=True, capture_output=True).stdout
except Exception: except Exception:
eType, eValue, eTraceback = sys.exc_info()
if suppressTraceBack: if suppressTraceBack:
sys.excepthook(Exception, Exception(errorMessage), None) traceback.print_exception(eType, eType(errorMessage), None)
elif not errorMessage: elif errorMessage:
traceback.print_exception(eType, eType(errorMessage), eTraceback)
else:
print("An error occurred during subprocess run:") print("An error occurred during subprocess run:")
print("-- command: {}".format(command)) print("-- command: {}".format(command))
print("-- folder: {}".format(os.getcwd())) print("-- folder: {}".format(os.getcwd()))
print("-- error: {}".format(sys.exc_info()[1])) traceback.print_exception(eType, eValue, eTraceback)
hints = getCommandErrorHints(command) hints = getCommandErrorHints(command)
if hints is not None: if hints is not None:
print(hints) print(hints)
raise
else:
raise Exception(errorMessage)
# decorator to call function from within the given path # decorator to call function from within the given path
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment