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, None is returned Note: This is probably not working on plain win32 systems
(cls, name, checker=None, paths=None)
| 1191 | |
| 1192 | @classmethod |
| 1193 | def sysfind(cls, name, checker=None, paths=None): |
| 1194 | """Return a path object found by looking at the systems |
| 1195 | underlying PATH specification. If the checker is not None |
| 1196 | it will be invoked to filter matching paths. If a binary |
| 1197 | cannot be found, None is returned |
| 1198 | Note: This is probably not working on plain win32 systems |
| 1199 | but may work on cygwin. |
| 1200 | """ |
| 1201 | if isabs(name): |
| 1202 | p = local(name) |
| 1203 | if p.check(file=1): |
| 1204 | return p |
| 1205 | else: |
| 1206 | if paths is None: |
| 1207 | if iswin32: |
| 1208 | paths = os.environ["Path"].split(";") |
| 1209 | if "" not in paths and "." not in paths: |
| 1210 | paths.append(".") |
| 1211 | try: |
| 1212 | systemroot = os.environ["SYSTEMROOT"] |
| 1213 | except KeyError: |
| 1214 | pass |
| 1215 | else: |
| 1216 | paths = [ |
| 1217 | path.replace("%SystemRoot%", systemroot) for path in paths |
| 1218 | ] |
| 1219 | else: |
| 1220 | paths = os.environ["PATH"].split(":") |
| 1221 | tryadd = [] |
| 1222 | if iswin32: |
| 1223 | tryadd += os.environ["PATHEXT"].split(os.pathsep) |
| 1224 | tryadd.append("") |
| 1225 | |
| 1226 | for x in paths: |
| 1227 | for addext in tryadd: |
| 1228 | p = local(x).join(name, abs=True) + addext |
| 1229 | try: |
| 1230 | if p.check(file=1): |
| 1231 | if checker: |
| 1232 | if not checker(p): |
| 1233 | continue |
| 1234 | return p |
| 1235 | except error.EACCES: |
| 1236 | pass |
| 1237 | return None |
| 1238 | |
| 1239 | @classmethod |
| 1240 | def _gethomedir(cls): |