diff options
author | Matthew Krafczyk <krafczyk.matthew@gmail.com> | 2016-11-16 12:14:25 -0500 |
---|---|---|
committer | Matthew Krafczyk <krafczyk.matthew@gmail.com> | 2016-11-16 12:14:25 -0500 |
commit | de7171db8a14660e7789349b1ed9c68f27692f48 (patch) | |
tree | 4579212f56c43451f36d31f25706a409e580d3d2 /lib | |
parent | 6c854246aaa0b2b62195617c5bbd906f20f82595 (diff) | |
download | spack-de7171db8a14660e7789349b1ed9c68f27692f48.tar.gz spack-de7171db8a14660e7789349b1ed9c68f27692f48.tar.bz2 spack-de7171db8a14660e7789349b1ed9c68f27692f48.tar.xz spack-de7171db8a14660e7789349b1ed9c68f27692f48.zip |
Use better scheme for getting root directory
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/llnl/util/tty/__init__.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/spack/llnl/util/tty/__init__.py b/lib/spack/llnl/util/tty/__init__.py index 03188ce592..3743137daa 100644 --- a/lib/spack/llnl/util/tty/__init__.py +++ b/lib/spack/llnl/util/tty/__init__.py @@ -69,9 +69,13 @@ def set_stacktrace(flag): def process_stacktrace(countback): """Gives file and line frame 'countback' frames from the bottom""" st = traceback.extract_stack() - # First entry should be bin/spack. Use this to get spack 'root'. - # bin/spack is 9 characters, the length of the 'root' is then len-9. - root_len = len(st[0][0]) - 9 + # All entries will be spack files based on how this function is called. + # We use commonprefix to find what the spack 'root' directory is. + file_list = [] + for frame in st: + file_list.append(frame[0]) + root_dir = os.path.commonprefix(file_list) + root_len = len(root_dir) st_idx = len(st) - countback - 1 st_text = "%s:%i " % (st[st_idx][0][root_len:], st[st_idx][1]) return st_text |