我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用sh.which()。
def new(cls, filename): if hasattr(settings, 'LEDGER_BIN'): ledger_bin = settings.LEDGER_BIN else: ledger_bin = sh.which('ledger') return Ledger(sh.Command(ledger_bin).bake(_tty_out=False, no_color=True, file=filename), filename=filename)
def get_executable_path(executable): path = sh.which(executable) if path is None: raise Exception("Can't find '{}' executable, is it in your $PATH?".format(executable)) return str(path)