Moved to os.access from sub_process for command.exists() diff --git a/func/minion/modules/command.py b/func/minion/modules/command.py index c849d42..3329927 100644 --- a/func/minion/modules/command.py +++ b/func/minion/modules/command.py @@ -22,7 +22,7 @@ class Command(func_module.FuncModule): def __init__(self): self.methods = { "run" : self.run, - "exists" : self.exists, + "exists" : self.exists, } func_module.FuncModule.__init__(self) @@ -32,7 +32,8 @@ class Command(func_module.FuncModule): NOT FOR USE WITH INTERACTIVE COMMANDS. """ - cmdref = sub_process.Popen(command.split(),stdout=sub_process.PIPE,stderr=sub_process.PIPE, shell=False) + cmdref = sub_process.Popen(command.split(), stdout=sub_process.PIPE, + stderr=sub_process.PIPE, shell=False) data = cmdref.communicate() return (cmdref.returncode, data[0], data[1]) @@ -40,12 +41,12 @@ class Command(func_module.FuncModule): """ 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: + import os + + if os.access(command, os.X_OK): return True return False -- "An organisation that treats its programmers as morons will soon have programmers that are willing and able to act like morons only." -Bjarne Stroustrup _______________________________________________ Func-list mailing list Func-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/func-list