mirror of
https://github.com/yavook/kiwi-scp.git
synced 2024-11-24 13:43:01 +00:00
Service.has_executable
This commit is contained in:
parent
0fc55154f2
commit
d9f66f069c
1 changed files with 13 additions and 0 deletions
|
@ -33,6 +33,19 @@ class Service:
|
|||
if cd_match:
|
||||
yield Path(cd_match.group(1))
|
||||
|
||||
def has_executable(self, exe_name: str) -> bool:
|
||||
try:
|
||||
# test if desired executable exists
|
||||
COMPOSE_EXE.run(
|
||||
["exec", "-T", self.name, "/bin/sh", "-c", f"command -v {exe_name}"],
|
||||
check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
||||
**self.parent.process_kwargs,
|
||||
)
|
||||
return True
|
||||
|
||||
except subprocess.CalledProcessError:
|
||||
return False
|
||||
|
||||
|
||||
@attr.s
|
||||
class Services:
|
||||
|
|
Loading…
Reference in a new issue