Java Code Examples for com.intellij.execution.process.ProcessOutput#getStderr()
The following examples show how to use
com.intellij.execution.process.ProcessOutput#getStderr() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Result.java From eslint-plugin with MIT License | 5 votes |
public static Result processResults(ProcessOutput output) { Result result = new Result(); result.errorOutput = output.getStderr(); try { List<FileResult> fileResults = parseInternal(output.getStdout()); if (fileResults != null && !fileResults.isEmpty()) { result.warns = fileResults.get(0).messages; } } catch (Exception e) { result.errorOutput = output.getStdout(); // result.errorOutput = e.toString(); } return result; }
Example 2
Source File: ExecutableValidator.java From consulo with Apache License 2.0 | 5 votes |
protected static boolean doCheckExecutable(@Nonnull String executable, @Nonnull List<String> processParameters) { try { GeneralCommandLine commandLine = new GeneralCommandLine(); commandLine.setExePath(executable); commandLine.addParameters(processParameters); commandLine.setCharset(CharsetToolkit.getDefaultSystemCharset()); CapturingProcessHandler handler = new CapturingProcessHandler(commandLine); ProcessOutput result = handler.runProcess(TIMEOUT_MS); boolean timeout = result.isTimeout(); int exitCode = result.getExitCode(); String stderr = result.getStderr(); if (timeout) { LOG.warn("Validation of " + executable + " failed with a timeout"); } if (exitCode != 0) { LOG.warn("Validation of " + executable + " failed with a non-zero exit code: " + exitCode); } if (!stderr.isEmpty()) { LOG.warn("Validation of " + executable + " failed with a non-empty error output: " + stderr); } return !timeout && exitCode == 0 && stderr.isEmpty(); } catch (Throwable t) { LOG.warn(t); return false; } }
Example 3
Source File: HaxeSdkUtil.java From intellij-haxe with Apache License 2.0 | 4 votes |
@Nullable public static HaxeSdkData testHaxeSdk(String path) { final String exePath = getCompilerPathByFolderPath(path); if (exePath == null) { return null; } final GeneralCommandLine command = new GeneralCommandLine(); command.setExePath(exePath); command.addParameter("-help"); command.setWorkDirectory(path); try { final ProcessOutput output = new CapturingProcessHandler( command.createProcess(), Charset.defaultCharset(), command.getCommandLineString()).runProcess(); if (output.getExitCode() != 0) { LOG.error("Haxe compiler exited with invalid exit code: " + output.getExitCode()); return null; } final String outputString = output.getStderr(); String haxeVersion = "NA"; final Matcher matcher = VERSION_MATCHER.matcher(outputString); if (matcher.find()) { haxeVersion = matcher.group(1); } final HaxeSdkData haxeSdkData = new HaxeSdkData(path, haxeVersion); haxeSdkData.setHaxelibPath(getHaxelibPathByFolderPath(path)); haxeSdkData.setNekoBinPath(suggestNekoBinPath(path)); return haxeSdkData; } catch (ExecutionException e) { LOG.info("Exception while executing the process:", e); return null; } }
Example 4
Source File: ExecutionHelper.java From consulo with Apache License 2.0 | 4 votes |
public static void showOutput(@Nonnull final Project myProject, @Nonnull final ProcessOutput output, @Nonnull final String tabDisplayName, @Nullable final VirtualFile file, final boolean activateWindow) { final String stdout = output.getStdout(); final String stderr = output.getStderr(); if (ApplicationManager.getApplication().isUnitTestMode() && !(stdout.isEmpty() || stderr.isEmpty())) { throw new RuntimeException("STDOUT:\n" + stdout + "\nSTDERR:\n" + stderr); } ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { if (myProject.isDisposed()) return; final String stdOutTitle = "[Stdout]:"; final String stderrTitle = "[Stderr]:"; final ErrorViewPanel errorTreeView = new ErrorViewPanel(myProject); try { openMessagesView(errorTreeView, myProject, tabDisplayName); } catch (NullPointerException e) { final StringBuilder builder = new StringBuilder(); builder.append(stdOutTitle).append("\n").append(stdout != null ? stdout : "<empty>").append("\n"); builder.append(stderrTitle).append("\n").append(stderr != null ? stderr : "<empty>"); Messages.showErrorDialog(builder.toString(), "Process Output"); return; } if (!StringUtil.isEmpty(stdout)) { final String[] stdoutLines = StringUtil.splitByLines(stdout); if (stdoutLines.length > 0) { if (StringUtil.isEmpty(stderr)) { // Only stdout available errorTreeView.addMessage(MessageCategory.SIMPLE, stdoutLines, file, -1, -1, null); } else { // both stdout and stderr available, show as groups if (file == null) { errorTreeView.addMessage(MessageCategory.SIMPLE, stdoutLines, stdOutTitle, new FakeNavigatable(), null, null, null); } else { errorTreeView.addMessage(MessageCategory.SIMPLE, new String[]{stdOutTitle}, file, -1, -1, null); errorTreeView.addMessage(MessageCategory.SIMPLE, new String[]{""}, file, -1, -1, null); errorTreeView.addMessage(MessageCategory.SIMPLE, stdoutLines, file, -1, -1, null); } } } } if (!StringUtil.isEmpty(stderr)) { final String[] stderrLines = StringUtil.splitByLines(stderr); if (stderrLines.length > 0) { if (file == null) { errorTreeView.addMessage(MessageCategory.SIMPLE, stderrLines, stderrTitle, new FakeNavigatable(), null, null, null); } else { errorTreeView.addMessage(MessageCategory.SIMPLE, new String[]{stderrTitle}, file, -1, -1, null); errorTreeView.addMessage(MessageCategory.SIMPLE, ArrayUtil.EMPTY_STRING_ARRAY, file, -1, -1, null); errorTreeView.addMessage(MessageCategory.SIMPLE, stderrLines, file, -1, -1, null); } } } errorTreeView.addMessage(MessageCategory.SIMPLE, new String[]{"Process finished with exit code " + output.getExitCode()}, null, -1, -1, null); if (activateWindow) { ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.MESSAGES_WINDOW).activate(null); } } }); }