return a path object found by looking at the systems
underlying PATH specification. If the checker is not None
it will be invoked to filter matching paths. If a binary
cannot be found, py.error.ENOENT is raised.
Note: This is probably not working on plain win32 systems
but may work on cygwin.
def sysfind(cls, name, checker=None):
origin: type
where:
exceptions that might appear during execution:
function source:
def sysfind(cls, name, checker=None):
""" return a path object found by looking at the systems
underlying PATH specification. If the checker is not None
it will be invoked to filter matching paths. If a binary
cannot be found, py.error.ENOENT is raised.
Note: This is probably not working on plain win32 systems
but may work on cygwin.
"""
if os.path.isabs(name):
p = py.path.local(name)
if p.check(file=1):
return p
else:
if py.std.sys.platform == 'win32':
paths = py.std.os.environ['Path'].split(';')
try:
systemroot = os.environ['SYSTEMROOT']
except KeyError:
pass
else:
paths = [re.sub('%SystemRoot%', systemroot, path)
for path in paths]
tryadd = '', '.exe', '.com', '.bat' # XXX add more?
else:
paths = py.std.os.environ['PATH'].split(':')
tryadd = ('',)
for x in paths:
for addext in tryadd:
p = py.path.local(x).join(name, abs=True) + addext
try:
if p.check(file=1):
if checker:
if not checker(p):
continue
return p
except py.error.EACCES:
pass
raise py.error.ENOENT(name)
called in /home/johnny/projects/merlinux/py/dist/py/rest/testing/shared_helpers.py
traceback path.local.sysfind.0
called in /home/johnny/projects/merlinux/py/dist/py/misc/testing/test_initpkg.py
traceback path.local.sysfind.1
called in /home/johnny/projects/merlinux/py/dist/py/path/local/testing/test_local.py
traceback path.local.sysfind.2
called in /home/johnny/projects/merlinux/py/dist/py/path/local/testing/test_local.py
traceback path.local.sysfind.3
called in /home/johnny/projects/merlinux/py/dist/py/misc/testing/test_svnlook.py
traceback path.local.sysfind.4
called in /home/johnny/projects/merlinux/py/dist/py/rest/testing/shared_helpers.py
traceback path.local.sysfind.5
called in /home/johnny/projects/merlinux/py/dist/py/misc/testing/test_svnlook.py
traceback path.local.sysfind.6
called in /home/johnny/projects/merlinux/py/dist/py/path/svn/testing/test_wccommand.py
traceback path.local.sysfind.7
called in /home/johnny/projects/merlinux/py/dist/py/rest/testing/shared_helpers.py
traceback path.local.sysfind.8
called in /home/johnny/projects/merlinux/py/dist/py/path/local/testing/test_local.py
traceback path.local.sysfind.9
called in /home/johnny/projects/merlinux/py/dist/py/path/local/testing/test_local.py
traceback path.local.sysfind.10
called in None</home/johnny/projects/merlinux/py/dist/py/test/raises.py:20>
traceback path.local.sysfind.11
called in /home/johnny/projects/merlinux/py/dist/py/path/local/testing/test_local.py
traceback path.local.sysfind.12
called in /home/johnny/projects/merlinux/py/dist/py/rest/testing/shared_helpers.py
traceback path.local.sysfind.13
called in /home/johnny/projects/merlinux/py/dist/py/rest/testing/shared_helpers.py
traceback path.local.sysfind.14
called in /home/johnny/projects/merlinux/py/dist/py/path/svn/testing/test_urlcommand.py
traceback path.local.sysfind.15
called in /home/johnny/projects/merlinux/py/dist/py/path/local/testing/test_local.py
traceback path.local.sysfind.16
called in /home/johnny/projects/merlinux/py/dist/py/rest/testing/shared_helpers.py
traceback path.local.sysfind.17
called in None</home/johnny/projects/merlinux/py/dist/py/test/raises.py:20>
traceback path.local.sysfind.18
called in /home/johnny/projects/merlinux/py/dist/py/path/svn/testing/test_test_repo.py
traceback path.local.sysfind.19
called in None</home/johnny/projects/merlinux/py/dist/py/test/raises.py:20>