Search in sources :

Example 1 with Output

use of com.intellij.execution.Output in project intellij-community by JetBrains.

the class PythonTask method runNoConsole.

/**
   * Runs task with out console
   * @return stdout
   * @throws ExecutionException in case of error. Consider using {@link com.intellij.execution.util.ExecutionErrorDialog}
   */
@NotNull
public final String runNoConsole() throws ExecutionException {
    final ProcessHandler process = createProcess(new HashMap<>());
    final OutputListener listener = new OutputListener();
    process.addProcessListener(listener);
    process.startNotify();
    process.waitFor(TIMEOUT_TO_WAIT_FOR_TASK);
    final Output output = listener.getOutput();
    final int exitCode = output.getExitCode();
    if (exitCode == 0) {
        return output.getStdout();
    }
    throw new ExecutionException(String.format("Error on python side. " + "Exit code: %s, err: %s out: %s", exitCode, output.getStderr(), output.getStdout()));
}
Also used : Output(com.intellij.execution.Output) ProcessHandler(com.intellij.execution.process.ProcessHandler) ExecutionException(com.intellij.execution.ExecutionException) OutputListener(com.intellij.execution.OutputListener) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ExecutionException (com.intellij.execution.ExecutionException)1 Output (com.intellij.execution.Output)1 OutputListener (com.intellij.execution.OutputListener)1 ProcessHandler (com.intellij.execution.process.ProcessHandler)1 NotNull (org.jetbrains.annotations.NotNull)1