diff options
| author | Michael DeHaan <mdehaan@redhat.com> | 2008-01-13 10:22:07 -0500 |
|---|---|---|
| committer | Michael DeHaan <mdehaan@redhat.com> | 2008-01-13 10:22:07 -0500 |
| commit | 4ff11f4a5e883bcba11f021ae3d42dd318cc6396 (patch) | |
| tree | 8505071cf94c875ddd536eb3c962a830c2481ea3 | |
| parent | 5bbf8f07bcdd2ca52e53b2f5e601a8a55f03ac68 (diff) | |
Add Steve's match to check if a command exists.
| -rw-r--r-- | func/minion/modules/command.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/func/minion/modules/command.py b/func/minion/modules/command.py index 06adaaa..c849d42 100644 --- a/func/minion/modules/command.py +++ b/func/minion/modules/command.py @@ -1,5 +1,6 @@ # Copyright 2007, Red Hat, Inc # James Bowes <jbowes@redhat.com> +# Steve 'Ashcrow' Milner <smilner@redhat.com> # # This software may be freely redistributed under the terms of the GNU # general public license. @@ -20,7 +21,8 @@ class Command(func_module.FuncModule): def __init__(self): self.methods = { - "run" : self.run + "run" : self.run, + "exists" : self.exists, } func_module.FuncModule.__init__(self) @@ -34,5 +36,16 @@ class Command(func_module.FuncModule): data = cmdref.communicate() return (cmdref.returncode, data[0], data[1]) + def exists(self, command): + """ + Checks to see if a command exists on the target system(s). + """ + cmdref = sub_process.Popen(['/usr/bin/which', command], stdout=sub_process.PIPE) + data = cmdref.communicate() + if cmdref.returncode == 0: + return True + return False + + methods = Command() register_rpc = methods.register_rpc |
