Example #1
0
    def __run_cmd(self, action, user, arguments=[], elevate=True):
        """
        Shortcut for running commands.

        Accepts the following parameters:
          * action: determines the command line utility to execute.
          * user: the user to perform the operation upon.
        """

        cmd = []
        cmd.append(where_is(self.ACTIONS[action]))
        cmd += arguments
        cmd.append(user)

        if elevate:
            cmd = elevate_cmd(cmd)

        proc = subprocess.Popen(cmd, stdin=subprocess.PIPE,
                                stdout=subprocess.PIPE,
                                stderr=subprocess.PIPE)

        status = proc.wait()
        (stdout, stderr) = proc.communicate()

        return (status, stdout, stderr)
Example #2
0
 def __init__(self):
     self.__yum_path = where_is('yum')