Ver código fonte

use os.expanduser with $PATH, it may contain a tilde

rdb 15 anos atrás
pai
commit
233e25d98c
1 arquivos alterados com 23 adições e 22 exclusões
  1. 23 22
      makepanda/makepandacore.py

+ 23 - 22
makepanda/makepandacore.py

@@ -193,6 +193,29 @@ def exit(msg = ""):
         print msg
         raise "initiate-exit"
 
+########################################################################
+##
+## LocateBinary
+##
+## This function searches the system PATH for the binary. Returns its
+## full path when it is found, or None when it was not found.
+##
+########################################################################
+
+def LocateBinary(binary):
+    if os.path.isfile(binary):
+        return binary
+    if "PATH" not in os.environ or os.environ["PATH"] == "":
+        p = os.defpath
+    else:
+        p = os.environ["PATH"]
+
+    for path in p.split(os.pathsep):
+        binpath = os.path.join(os.path.expanduser(path), binary)
+        if os.access(binpath, os.X_OK):
+            return os.path.abspath(os.path.realpath(binpath))
+    return None
+
 ########################################################################
 ##
 ## Run a command.
@@ -299,28 +322,6 @@ def GetDirectorySize(dir):
             except: pass
     return size
 
-########################################################################
-##
-## LocateBinary
-##
-## This function searches the system PATH for the binary. Returns its
-## full path when it is found, or None when it was not found.
-##
-########################################################################
-
-def LocateBinary(binary):
-    if os.path.isfile(binary):
-        return binary
-    if "PATH" not in os.environ or os.environ["PATH"] == "":
-        p = os.defpath
-    else:
-        p = os.environ["PATH"]
-
-    for path in p.split(os.pathsep):
-        if os.access(os.path.join(path, binary), os.X_OK):
-            return os.path.abspath(os.path.realpath(os.path.join(path, binary)))
-    return None
-
 ########################################################################
 ##
 ## The Timestamp Cache