changeset 5:98d99fed9d35 draft

Strip eol off of TrinityPath, so os.path.islink() works correctly.
author trinity_ctat
date Tue, 26 Sep 2017 13:33:20 -0400
parents cb71c6b0bf66
children 12bc09b4a26d
files trinityToolWrapper.py
diffstat 1 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/trinityToolWrapper.py	Tue Sep 26 11:48:19 2017 -0400
+++ b/trinityToolWrapper.py	Tue Sep 26 13:33:20 2017 -0400
@@ -16,7 +16,7 @@
 TRINITY_BASE_DIR = ""
 if os.environ.has_key('TRINITY_HOME'):
     TRINITY_BASE_DIR = os.environ['TRINITY_HOME'];
-else:
+elif hasattr(os, 'symlink'): # symlink was implemented to always return false when it was not implemented in earlier versions.
     # 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.
@@ -32,8 +32,16 @@
         # 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.
+        TrinityPath = TrinityPath.rstrip() # Need to strip off a newline.
+        # print "Trinity that was found is: {:s}".format(repr(TrinityPath))
+        # print os.path.islink(TrinityPath)
+        TrinityPath = os.path.abspath(TrinityPath)
+        print "The Absolute Trinity path that was found is: {:s}".format(TrinityPath)
+        # print os.path.islink(TrinityPath)
         while os.path.islink(TrinityPath):
+            print "That path is a link."
             TrinityPath = os.path.join(os.path.dirname(TrinityPath),os.readlink(TrinityPath))
+            print "The new path is: {:s}".format(TrinityPath)
         # Take off the last part of the path (which is the Trinity command)
         TRINITY_BASE_DIR = "/".join(TrinityPath.split("/")[0:-1])
 
@@ -70,11 +78,13 @@
     # If one needs to silence stdout 
     #args.append( ">" )
     #args.append( "/dev/null" )
+    print "The TRINITY_BASE_DIR is:\n\t{:s}".format(TRINITY_BASE_DIR)
 
     args[0] = "".join([TRINITY_BASE_DIR, '/', args[0]]);
 
     cmdline = " ".join(args)
 
+    print "The command being invoked is:\n\t{:s}".format(cmdline)
     
 
     try: