Skip to content
Snippets Groups Projects
Commit f1b26cb7 authored by Matthew Krafczyk's avatar Matthew Krafczyk
Browse files

Improve stacktrace printing

Sometimes files in the stacktrace are not from spack. Remove these
files before finding the spack root.
parent de7171db
No related branches found
No related tags found
No related merge requests found
...@@ -69,11 +69,13 @@ def set_stacktrace(flag): ...@@ -69,11 +69,13 @@ def set_stacktrace(flag):
def process_stacktrace(countback): def process_stacktrace(countback):
"""Gives file and line frame 'countback' frames from the bottom""" """Gives file and line frame 'countback' frames from the bottom"""
st = traceback.extract_stack() st = traceback.extract_stack()
# All entries will be spack files based on how this function is called. # Not all entries may be spack files, we have to remove those that aren't.
# We use commonprefix to find what the spack 'root' directory is.
file_list = [] file_list = []
for frame in st: for frame in st:
file_list.append(frame[0]) # Check that the file is a spack file
if frame[0].find("/spack") >= 0:
file_list.append(frame[0])
# We use commonprefix to find what the spack 'root' directory is.
root_dir = os.path.commonprefix(file_list) root_dir = os.path.commonprefix(file_list)
root_len = len(root_dir) root_len = len(root_dir)
st_idx = len(st) - countback - 1 st_idx = len(st) - countback - 1
......
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