File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3232import threading
3333import msg
3434
35+ try :
36+ PATH = os .getenv ('PATH' ).split (':' )
37+ except NameError :
38+ PATH = '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' .split (':' )
39+
3540
3641# class BaseService(threading.Thread):
3742class SimpleService (threading .Thread ):
@@ -431,6 +436,18 @@ def update(self, interval):
431436
432437 return updated
433438
439+ def find_binary (self , binary ):
440+ try :
441+ if isinstance (binary , str ):
442+ binary = os .path .basename (binary )
443+ return next (('/' .join ([p , binary ]) for p in PATH
444+ if os .path .isfile ('/' .join ([p , binary ]))
445+ and os .access ('/' .join ([p , binary ]), os .X_OK )))
446+ else :
447+ return None
448+ except StopIteration :
449+ return None
450+
434451
435452class UrlService (SimpleService ):
436453 # TODO add support for https connections
You can’t perform that action at this time.
0 commit comments