mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
use os.expanduser with $PATH, it may contain a tilde
This commit is contained in:
parent
d1715b13df
commit
233e25d98c
@ -193,6 +193,29 @@ def exit(msg = ""):
|
|||||||
print msg
|
print msg
|
||||||
raise "initiate-exit"
|
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.
|
## Run a command.
|
||||||
@ -299,28 +322,6 @@ def GetDirectorySize(dir):
|
|||||||
except: pass
|
except: pass
|
||||||
return size
|
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
|
## The Timestamp Cache
|
||||||
|
Loading…
x
Reference in New Issue
Block a user