# HG changeset patch # User trinity_ctat # Date 1506440057 14400 # Node ID 9e5c3f162ecadd26d575ebe29293e460de10138c # Parent b33e9252e6b4a4d6461edf1df30348656909bce9 Needed to dereference links when searching for TRINITY_BASE_DIR. diff -r b33e9252e6b4 -r 9e5c3f162eca trinityToolWrapper.py --- a/trinityToolWrapper.py Mon Sep 25 15:51:40 2017 -0400 +++ b/trinityToolWrapper.py Tue Sep 26 11:34:17 2017 -0400 @@ -17,18 +17,25 @@ if os.environ.has_key('TRINITY_HOME'): TRINITY_BASE_DIR = os.environ['TRINITY_HOME']; else: - # Cicada Dennis added looking for the location of the Trinity program using the unix "which" utility. + # 2017-09-26 + # Cicada Dennis added looking for the location of the Trinity program using the Unix "which" utility. # I tried using "command -v Trinity" but for some reason, I was getting a OS permission error with that. + # I just found distutils.spawn.find_executable() which might work, but already implemented the below. try: pipe1 = subprocess.Popen(["which", "Trinity"], stdout=subprocess.PIPE) except: t, v, tb = sys.exc_info() - sys.stderr.write("You must set the environmental variable TRINITY_HOME to the base installation directory of Trinity before running this"); + sys.stderr.write("You must set the environmental variable TRINITY_HOME to the base installation directory of Trinity before running {:s}.".format(sys.argv[0]); raise t, v, tb else: - output1, err1 = pipe1.communicate() + TrinityPath, err_info = pipe1.communicate() + # FIX - probably should be checking err_info for errors... + # Determine the TRINITY_BASE_DIR from output1. + # If TrinityPath is a link, we need to dereference the link. + while os.path.islink(TrinityPath) + TrinityPath = os.path.join(os.path.dirname(TrinityPath),os.readlink(TrinityPath)) # Take off the last part of the path (which is the Trinity command) - TRINITY_BASE_DIR = "/".join(output1.split("/")[0:-1]) + TRINITY_BASE_DIR = "/".join(TrinityPath.split("/")[0:-1]) # get bindir bindir = sys.argv[0]