@Override
    public void run() {
      try {
        String line = reader.readLine();
        while (line != null) {
          output.append(line);
          output.append("\n");
          line = reader.readLine();
        }
        reader.close();
      } catch (IOException e) {
        LOG.warn(e.getMessage());
      }
    }
Class to collect output and error stream of python subprocess
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProvider.java