(self, cmd, ignore_error=False)
return content.strip()
Execute a shell command and get its output
Execute a shell command and get its output
Execute a shell command and get its output
def get_output(self, cmd, ignore_error=False):
        """Execute a shell command and get its output"""
        if not cmd[0].startswith("/"):
            path = Config.conf["root_path"] + ":" + os.getenv("PATH", "")
            cmd_path = self.find_inpath(cmd[0], path)
            if cmd_path:
                cmd[0] = cmd_path
        content = ""
        try:
            content = self.check_output(cmd, shell=False, stderr=Msg.chlderr,
                                        close_fds=True)
        except subprocess.CalledProcessError:
            if not ignore_error:
                return None
        return content.strip()
def get_output ( self , cmd , ignore_error = False ) : if not cmd [ 0 ] . startswith ( "/" ) : path = Config . conf [ "root_path" ] + ":" + os . getenv ( "PATH" , "" ) cmd_path = self . find_inpath ( cmd [ 0 ] , path ) if cmd_path : cmd [ 0 ] = cmd_path content = "" try : content = self . check_output ( cmd , shell = False , stderr = Msg . chlderr , close_fds = True ) except subprocess . CalledProcessError : if not ignore_error : return None return content . strip ( )