Message105867
New data point: in some contexts on Windows (not sure of the exact cause but I was dealing with multiple drives), even this workaround isn't enough. I ended up having to do something like this (i.e. manually search the path) on win32:
def full_executable_path(invoked, environ):
if os.path.splitext(invoked)[1]:
return invoked
explicit_dir = os.path.dirname(invoked)
if explicit_dir:
path = [ explicit_dir ]
else:
path = environ.get('PATH').split(os.path.pathsep)
extensions = environ.get(
'PATHEXT',
# Use *something* in case the environment variable is
# empty. These come from my machine's defaults
'.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.PSC1'
).split(os.path.pathsep)
for dir in path:
for ext in extensions:
full_path = os.path.join(dir, invoked+ext)
if os.path.exists( full_path ):
return full_path
return invoked # Not found; invoking it will likely fail
class Popen(subprocess.Popen):
def __init__(
self, args, bufsize=0, executable=None,
stdin=None, stdout=None, stderr=None,
preexec_fn=None, close_fds=False, shell=False,
cwd=None, env=None,
*args_, **kw):
if executable is None and not shell:
executable = full_executable_path(args[0], env or os.environ)
super(Popen,self).__init__(
args, bufsize, executable, stdin, stdout, stderr,
preexec_fn, close_fds, shell, cwd, env, *args_, **kw) |
|
Date |
User |
Action |
Args |
2010-05-16 14:16:30 | dabrahams | set | recipients:
+ dabrahams, mark, r.david.murray, brian.curtin, docs@python |
2010-05-16 14:16:30 | dabrahams | set | messageid: <1274019390.25.0.838979515547.issue8557@psf.upfronthosting.co.za> |
2010-05-16 14:16:28 | dabrahams | link | issue8557 messages |
2010-05-16 14:16:28 | dabrahams | create | |
|