1 # Copyright 2007, Red Hat, Inc
2 # James Bowes <jbowes@redhat.com>
3 # Steve 'Ashcrow' Milner <smilner@redhat.com>
5 # This software may be freely redistributed under the terms of the GNU
6 # general public license.
8 # You should have received a copy of the GNU General Public License
9 # along with this program; if not, write to the Free Software
10 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
13 Abitrary command execution module for func.
19 class Command(func_module
.FuncModule
):
23 description
= "Works with shell commands."
25 def run(self
, command
):
27 Runs a command, returning the return code, stdout, and stderr as a tuple.
28 NOT FOR USE WITH INTERACTIVE COMMANDS.
31 cmdref
= sub_process
.Popen(command
.split(), stdout
=sub_process
.PIPE
,
32 stderr
=sub_process
.PIPE
, shell
=False)
33 data
= cmdref
.communicate()
34 return (cmdref
.returncode
, data
[0], data
[1])
36 def exists(self
, command
):
38 Checks to see if a command exists on the target system(s).
42 if os
.access(command
, os
.X_OK
):