We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 36ee72c commit 666c004Copy full SHA for 666c004
testinfra/host.py
@@ -29,7 +29,11 @@ def __repr__(self):
29
30
def exists(self, command):
31
"""Return True if given command exist in $PATH"""
32
- return self.run_expect([0, 1, 127], "command -v %s", command).rc == 0
+ rc = self.run_expect([0, 1, 127], "command -v %s", command).rc
33
+ if rc == 127:
34
+ return self.run_expect([0, 1], "which %s", command).rc == 0
35
+ else:
36
+ return rc == 0
37
38
def find_command(self, command, extrapaths=("/sbin", "/usr/sbin")):
39
"""Return path of given command
@@ -39,6 +43,10 @@ def find_command(self, command, extrapaths=("/sbin", "/usr/sbin")):
43
out = self.run_expect([0, 1, 127], "command -v %s", command)
40
44
if out.rc == 0:
41
45
return out.stdout.rstrip("\r\n")
46
+ if out.rc == 127:
47
+ out = self.run_expect([0, 1], "which %s", self.path)
48
+ if out.rc == 0:
49
+ return out.stdout.rstrip("\r\n")
42
50
for basedir in extrapaths:
51
path = os.path.join(basedir, command)
52
if self.exists(path):
0 commit comments