@@ -328,13 +328,18 @@ def get_by_id(self, id):
328
328
return None
329
329
330
330
331
- def which (exe = None ):
331
+ def which (exe = None ,
332
+ default_paths = [
333
+ '/bin' , '/sbin' , '/usr/bin' , '/usr/sbin' , '/usr/local/bin' ]
334
+ ):
332
335
"""Return path of bin. Python clone of /usr/bin/which.
333
336
334
337
from salt.util - https://www.github.com/saltstack/salt - license apache
335
338
336
339
:param exe: Application to search PATHs for.
337
340
:type exe: string
341
+ :param default_path: Application to search PATHs for.
342
+ :type default_path: list
338
343
:rtype: string
339
344
340
345
"""
@@ -352,17 +357,15 @@ def _is_executable_file_or_link(exe):
352
357
# win' for cases to find optional alternatives
353
358
search_path = os .environ .get ('PATH' ) and \
354
359
os .environ ['PATH' ].split (os .pathsep ) or list ()
355
- for default_path in [
356
- '/bin' , '/sbin' , '/usr/bin' , '/usr/sbin' , '/usr/local/bin'
357
- ]:
360
+ for default_path in default_paths :
358
361
if default_path not in search_path :
359
362
search_path .append (default_path )
360
363
os .environ ['PATH' ] = os .pathsep .join (search_path )
361
364
for path in search_path :
362
365
full_path = os .path .join (path , exe )
363
366
if _is_executable_file_or_link (full_path ):
364
367
return full_path
365
- logger .trace (
368
+ logger .info (
366
369
'\' {0}\' could not be found in the following search path: '
367
370
'\' {1}\' ' .format (exe , search_path ))
368
371
0 commit comments