当前位置: 首页>>代码示例>>Java>>正文


Java ProcessOutput.getStderr方法代码示例

本文整理汇总了Java中com.intellij.execution.process.ProcessOutput.getStderr方法的典型用法代码示例。如果您正苦于以下问题:Java ProcessOutput.getStderr方法的具体用法?Java ProcessOutput.getStderr怎么用?Java ProcessOutput.getStderr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.execution.process.ProcessOutput的用法示例。


在下文中一共展示了ProcessOutput.getStderr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doCheckExecutable

import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
protected static boolean doCheckExecutable(@NotNull String executable, @NotNull List<String> processParameters) {
  try {
    GeneralCommandLine commandLine = new GeneralCommandLine();
    commandLine.setExePath(executable);
    commandLine.addParameters(processParameters);
    CapturingProcessHandler handler = new CapturingProcessHandler(commandLine.createProcess(), CharsetToolkit.getDefaultSystemCharset());
    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;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:ExecutableValidator.java

示例2: getVersionStringFromOutput

import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
@Nullable
public String getVersionStringFromOutput(@NotNull ProcessOutput processOutput) {
  if (processOutput.getExitCode() != 0) {
    String errors = processOutput.getStderr();
    if (StringUtil.isEmpty(errors)) {
      errors = processOutput.getStdout();
    }
    LOG.warn("Couldn't get interpreter version: process exited with code " + processOutput.getExitCode() + "\n" + errors);
    return null;
  }
  final String result = getVersionStringFromOutput(processOutput.getStderr());
  if (result != null) {
    return result;
  }
  return getVersionStringFromOutput(processOutput.getStdout());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:PythonSdkFlavor.java

示例3: uninstallPackage

import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
public static void uninstallPackage(List<InstalledPackage> repoPackage) throws ExecutionException {
  final String path = TheRInterpreterService.getInstance().getInterpreterPath();
  if (StringUtil.isEmptyOrSpaces(path)) {
    throw new ExecutionException("Please, specify path to the R executable.");
  }
  final ArrayList<String> arguments = Lists.newArrayList(path, "CMD", "REMOVE");
  for (InstalledPackage aRepoPackage : repoPackage) {
    arguments.add(aRepoPackage.getName());
  }
  final Process process = new GeneralCommandLine(arguments).createProcess();

  final CapturingProcessHandler processHandler = new CapturingProcessHandler(process);
  final ProcessOutput output = processHandler.runProcess(5 * TheRPsiUtils.MINUTE);
  if (output.getExitCode() != 0) {
    throw new TheRExecutionException("Can't remove package", StringUtil.join(arguments, " "), output.getStdout(),
                                     output.getStderr(), output.getExitCode());
  }
}
 
开发者ID:ktisha,项目名称:TheRPlugin,代码行数:19,代码来源:TheRPackagesUtil.java

示例4: identifyVersion

import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
@NotNull
public static GitVersion identifyVersion(String gitExecutable) throws TimeoutException, ExecutionException, ParseException {
  GeneralCommandLine commandLine = new GeneralCommandLine();
  commandLine.setExePath(gitExecutable);
  commandLine.addParameter("--version");
  CapturingProcessHandler handler = new CapturingProcessHandler(commandLine.createProcess(), CharsetToolkit.getDefaultSystemCharset());
  ProcessOutput result = handler.runProcess(30 * 1000);
  if (result.isTimeout()) {
    throw new TimeoutException("Couldn't identify the version of Git - stopped by timeout.");
  }
  if (result.getExitCode() != 0 || !result.getStderr().isEmpty()) {
    LOG.info("getVersion exitCode=" + result.getExitCode() + " errors: " + result.getStderr());
    // anyway trying to parse
    try {
      parse(result.getStdout());
    } catch (ParseException pe) {
      throw new ExecutionException("Errors while executing git --version. exitCode=" + result.getExitCode() +
                                   " errors: " + result.getStderr());
    }
  }
  return parse(result.getStdout());
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:GitVersion.java

示例5: runProcess

import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
private static ProcessOutput runProcess(@NotNull final GeneralCommandLine cl) throws ExecutionException {
  final CapturingProcessHandler handler = new CapturingProcessHandler(cl.createProcess(), Charset.forName("UTF-8"));
  final ProcessOutput result = handler.runProcess(20000);
  if (result.isTimeout()) {
    throw new ExecutionException("Process execution of [" + cl.getCommandLineString() + "] has timed out");
  }
  final String errorOutput = result.getStderr();
  if (!StringUtil.isEmptyOrSpaces(errorOutput)) {
    throw new ExecutionException(errorOutput);
  }
  return result;
}
 
开发者ID:JetBrains,项目名称:teamcity-powershell,代码行数:13,代码来源:DetectionRunner.java

示例6: getTestOutput

import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
public static StudyTestsOutputParser.TestsOutput getTestOutput(@NotNull Process testProcess,
                                                               @NotNull String commandLine,
                                                               boolean isAdaptive) {
  final CapturingProcessHandler handler = new CapturingProcessHandler(testProcess, null, commandLine);
  final ProcessOutput output = ProgressManager.getInstance().hasProgressIndicator() ? handler
    .runProcessWithProgressIndicator(ProgressManager.getInstance().getProgressIndicator()) :
                               handler.runProcess();
  final StudyTestsOutputParser.TestsOutput testsOutput = StudyTestsOutputParser.getTestsOutput(output, isAdaptive);
  String stderr = output.getStderr();
  if (!stderr.isEmpty() && output.getStdout().isEmpty()) {
    LOG.info("#educational " + stderr);
    return new StudyTestsOutputParser.TestsOutput(false, stderr);
  }
  return testsOutput;
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:16,代码来源:StudyCheckUtils.java

示例7: identifyVersion

import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
@NotNull
public static GitVersion identifyVersion(String gitExecutable) throws TimeoutException, ExecutionException, ParseException {
  GeneralCommandLine commandLine = new GeneralCommandLine();
  commandLine.setExePath(gitExecutable);
  commandLine.addParameter("--version");
  CapturingProcessHandler handler = new CapturingProcessHandler(commandLine.createProcess(), CharsetToolkit.getDefaultSystemCharset());
  ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
  ProcessOutput result = indicator == null ?
                         handler.runProcess(ExecutableValidator.TIMEOUT_MS) :
                         handler.runProcessWithProgressIndicator(indicator);
  if (result.isTimeout()) {
    throw new TimeoutException("Couldn't identify the version of Git - stopped by timeout.");
  }
  else if (result.isCancelled()) {
    LOG.info("Cancelled by user. exitCode=" + result.getExitCode());
    throw new ProcessCanceledException();
  }
  else if (result.getExitCode() != 0 || !result.getStderr().isEmpty()) {
    LOG.info("getVersion exitCode=" + result.getExitCode() + " errors: " + result.getStderr());
    // anyway trying to parse
    try {
      parse(result.getStdout());
    } catch (ParseException pe) {
      throw new ExecutionException("Errors while executing git --version. exitCode=" + result.getExitCode() +
                                   " errors: " + result.getStderr());
    }
  }
  return parse(result.getStdout());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:GitVersion.java

示例8: runCommand

import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
@Nullable
private APIResourceListModel runCommand(String resource, String action, List<String> params) {
    APIResourceListModel resourceList = new APIResourceListModel();

    GeneralCommandLine gcl = new GeneralCommandLine(clientPath,
            resource);
    gcl.addParameter(action);


    if (params != null) {
        gcl.addParameters(params);
    }

    gcl.addParameter("--access-token");
    gcl.addParameter(accessToken);
    gcl.withWorkDirectory(workingDir);

    try {
        final CapturingProcessHandler processHandler = new CapturingProcessHandler(gcl.createProcess(), Charset.defaultCharset(), gcl.getCommandLineString());

        ProcessOutput output = processHandler.runProcess();

        if (output.getExitCode() != 0) {
            String error = output.getStderr();
            resourceList.addError(error);
            return resourceList;
        }

        final String response = output.getStdout();
        APIResourceListModel resources = null;
        if (!response.isEmpty()) {
            resources = handleResponse(response);
        }

        return resources;
    } catch (ExecutionException e) {
        e.printStackTrace();
    }
    return resourceList;
}
 
开发者ID:phrase,项目名称:phraseapp-AndroidStudio,代码行数:41,代码来源:API.java

示例9: processResults

import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
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;
    }
 
开发者ID:idok,项目名称:eslint-plugin,代码行数:15,代码来源:Result.java

示例10: doCheckExecutable

import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
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;
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:28,代码来源:ExecutableValidator.java

示例11: showOutput

import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
public static void showOutput(@NotNull final Project myProject,
                              @NotNull final ProcessOutput output,
                              @NotNull 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) {
        Messages.showErrorDialog(stdOutTitle + "\n" + (stdout != null ? stdout : "<empty>") + "\n" + stderrTitle + "\n"
                                 + (stderr != null ? stderr : "<empty>"), "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, NonNavigatable.INSTANCE, 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, NonNavigatable.INSTANCE, 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);
      }
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:71,代码来源:ExecutionHelper.java

示例12: PyExecutionException

import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
public PyExecutionException(@NotNull String message, @NotNull String command, @NotNull List<String> args, @NotNull ProcessOutput output) {
  this(message, command, args, output.getStdout(), output.getStderr(), output.getExitCode(), Collections.<PyExecutionFix>emptyList());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:PyExecutionException.java

示例13: TheRRunResult

import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
public TheRRunResult(@NotNull String command, @NotNull ProcessOutput output) {
  this.myCommand = command;
  this.myExitCode = output.getExitCode();
  this.myStdOut = output.getStdout();
  this.myStdErr = output.getStderr();
}
 
开发者ID:ktisha,项目名称:TheRPlugin,代码行数:7,代码来源:TheRPackagesUtil.java

示例14: showOutput

import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
public static void showOutput(@NotNull final Project myProject,
                              @NotNull final ProcessOutput output,
                              @NotNull 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);
      }
    }
  });
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:73,代码来源:ExecutionHelper.java

示例15: testHaxeSdk

import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
@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;
  }
}
 
开发者ID:HaxeFoundation,项目名称:intellij-haxe,代码行数:42,代码来源:HaxeSdkUtil.java


注:本文中的com.intellij.execution.process.ProcessOutput.getStderr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。