def runCommandInForegroundAsRoot(cmd, ExceptionClass):
     """
     Runs a command in foreground and as the super-user.
     Args:
         cmd: a string with the command's name and its arguments
         ExceptionClass: the exception that will be raised if something goes wrong
     Returns:
         The run command's output
     Raises:
         ExceptionClass: this exception will be raised if something goes
         wrong when running the command.
     """ 
     password = RootPasswordHandler.getInstance().getRootsPassword()
     header = "echo " + password + " | sudo -S "
     return ChildProcessManager.runCommandInForeground(header + cmd, ExceptionClass)
示例#2
0
 def runCommandInForegroundAsRoot(cmd, ExceptionClass):
     """
     Runs a command in foreground and as the super-user.
     Args:
         cmd: a string with the command's name and its arguments
         ExceptionClass: the exception that will be raised if something goes wrong
     Returns:
         The run command's output
     Raises:
         ExceptionClass: this exception will be raised if something goes
         wrong when running the command.
     """
     password = RootPasswordHandler.getInstance().getRootsPassword()
     header = "echo " + password + " | sudo -S "
     return ChildProcessManager.runCommandInForeground(
         header + cmd, ExceptionClass)
示例#3
0
def runCommandAsRoot(cmd, ExceptionClass):
    """
    Runs a command in foreground and as root
    Args:
        cmd: the command to run
    Returns:
        The run command's output
    Raises:
        ExceptionClass: this exception will be raised if something goes
        wrong when running the command.
    """
    # Get root's password
    password = RootPasswordHandler.getInstance().getRootsPassword()
    # Generate the command's header
    header = "echo " + password + " | sudo -S "
    # Run the command
    return runCommand(header + cmd, ExceptionClass)