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


Java ProcessOutput类代码示例

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


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

示例1: getProcessOutput

import com.intellij.execution.process.ProcessOutput; //导入依赖的package包/类
@NotNull
public static ProcessOutput getProcessOutput(final int timeout, @NotNull final String workDir,
                                             @NotNull final String exePath,
                                             @NotNull final String... arguments) throws ExecutionException {
    if (!new File(workDir).isDirectory()
            || (!new File(exePath).canExecute()
                && !exePath.equals("java"))) {
        return new ProcessOutput();
    }

    final GeneralCommandLine cmd = new GeneralCommandLine();
    cmd.setWorkDirectory(workDir);
    cmd.setExePath(exePath);
    cmd.addParameters(arguments);

    return execute(cmd, timeout);
}
 
开发者ID:internetisalie,项目名称:lua-for-idea,代码行数:18,代码来源:LuaSystemUtil.java

示例2: getExecutableVersionOutput

import com.intellij.execution.process.ProcessOutput; //导入依赖的package包/类
private String[] getExecutableVersionOutput(String sdkHome) {
    final String exePath = getTopLevelExecutable(sdkHome).getAbsolutePath();
    final ProcessOutput processOutput;
    try {
        processOutput = LuaSystemUtil.getProcessOutput(sdkHome, exePath, "-v");
    } catch (final ExecutionException e) {
        return null;
    }
    if (processOutput.getExitCode() != 0) {
        return null;
    }
    //Backwards compatibility - probably for Windows and OSX
    final String stderr = processOutput.getStderr().trim();
    if (!stderr.isEmpty()) {
        return stderr.split(" ");
    }
    //linux
    final String stdout = processOutput.getStdout().trim();
    if (!stdout.isEmpty()) {
        return stdout.split(" ");
    }
    return null;
}
 
开发者ID:internetisalie,项目名称:lua-for-idea,代码行数:24,代码来源:LuaSdkType.java

示例3: lint

import com.intellij.execution.process.ProcessOutput; //导入依赖的package包/类
@NotNull
public static ProcessOutput lint(@NotNull String cwd, @NotNull String file, @NotNull String stylintExe, @Nullable String config) throws ExecutionException {
    GeneralCommandLine commandLine = new GeneralCommandLine();
    commandLine.setWorkDirectory(cwd);
    commandLine.setExePath(stylintExe);

    commandLine.addParameter(file);
    commandLine.addParameter("--reporter");
    commandLine.addParameter("stylint-json-reporter");
    if (StringUtils.isNotEmpty(config)) {
        commandLine.addParameter("--config");
        commandLine.addParameter(config);
    }

    return NodeRunner.execute(commandLine, TIME_OUT);
}
 
开发者ID:sertae,项目名称:stylint-plugin,代码行数:17,代码来源:StylintRunner.java

示例4: 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

示例5: getOutputForException

import com.intellij.execution.process.ProcessOutput; //导入依赖的package包/类
private static ProcessOutput getOutputForException(final Exception e) {
  LOG.warn(e);
  return new ProcessOutput() {
    @NotNull
    @Override
    public String getStderr() {
      String err = super.getStderr();
      if (!StringUtil.isEmpty(err)) {
        err += "\n" + e.getMessage();
      }
      else {
        err = e.getMessage();
      }
      return err;
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:PySdkUtil.java

示例6: generateBuiltinSkeletons

import com.intellij.execution.process.ProcessOutput; //导入依赖的package包/类
public void generateBuiltinSkeletons(@NotNull Sdk sdk) throws InvalidSdkException {
  //noinspection ResultOfMethodCallIgnored
  new File(mySkeletonsPath).mkdirs();
  String binaryPath = sdk.getHomePath();
  if (binaryPath == null) throw new InvalidSdkException("Broken home path for " + sdk.getName());

  long startTime = System.currentTimeMillis();
  final ProcessOutput runResult = getProcessOutput(
    new File(binaryPath).getParent(),
    new String[]{
      binaryPath,
      PythonHelpersLocator.getHelperPath(GENERATOR3),
      "-d", mySkeletonsPath, // output dir
      "-b", // for builtins
    },
    PythonSdkType.getVirtualEnvExtraEnv(binaryPath), MINUTE * 5
  );
  runResult.checkSuccess(LOG);
  LOG.info("Rebuilding builtin skeletons took " + (System.currentTimeMillis() - startTime) + " ms");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:PySkeletonGenerator.java

示例7: 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

示例8: createVirtualEnv

import com.intellij.execution.process.ProcessOutput; //导入依赖的package包/类
@NotNull
public static String createVirtualEnv(@NotNull String destinationDir, String version) throws ExecutionException {
  final String condaExecutable = PyCondaPackageService.getCondaExecutable();
  if (condaExecutable == null) throw new PyExecutionException("Cannot find conda", "Conda", Collections.<String>emptyList(), new ProcessOutput());

  final ArrayList<String> parameters = Lists.newArrayList(condaExecutable, "create", "-p", destinationDir,
                                                          "python=" + version, "-y");

  final GeneralCommandLine commandLine = new GeneralCommandLine(parameters);
  final Process process = commandLine.createProcess();
  final CapturingProcessHandler handler = new CapturingProcessHandler(process);
  final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
  final ProcessOutput result = handler.runProcessWithProgressIndicator(indicator);
  if (result.isCancelled()) {
    throw new RunCanceledByUserException();
  }
  final int exitCode = result.getExitCode();
  if (exitCode != 0) {
    final String message = StringUtil.isEmptyOrSpaces(result.getStdout()) && StringUtil.isEmptyOrSpaces(result.getStderr()) ?
                           "Permission denied" : "Non-zero exit code";
    throw new PyExecutionException(message, "Conda", parameters, result);
  }
  final String binary = PythonSdkType.getPythonExecutable(destinationDir);
  final String binaryFallback = destinationDir + File.separator + "bin" + File.separator + "python";
  return (binary != null) ? binary : binaryFallback;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:PyCondaPackageManagerImpl.java

示例9: addRepository

import com.intellij.execution.process.ProcessOutput; //导入依赖的package包/类
@Override
public void addRepository(String repositoryUrl) {
  final String conda = PyCondaPackageService.getCondaExecutable();
  final ArrayList<String> parameters = Lists.newArrayList(conda, "config", "--add", "channels",  repositoryUrl, "--force");
  final GeneralCommandLine commandLine = new GeneralCommandLine(parameters);

  try {
    final Process process = commandLine.createProcess();
    final CapturingProcessHandler handler = new CapturingProcessHandler(process);
    final ProcessOutput result = handler.runProcess();
    final int exitCode = result.getExitCode();
    if (exitCode != 0) {
      final String message = StringUtil.isEmptyOrSpaces(result.getStdout()) && StringUtil.isEmptyOrSpaces(result.getStderr()) ?
                             "Permission denied" : "Non-zero exit code";
      LOG.warn("Failed to add repository " + message);
    }
    PyCondaPackageService.getInstance().addChannel(repositoryUrl);
  }
  catch (ExecutionException e) {
    LOG.warn("Failed to add repository");
  }

}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:PyCondaManagementService.java

示例10: removeRepository

import com.intellij.execution.process.ProcessOutput; //导入依赖的package包/类
@Override
public void removeRepository(String repositoryUrl) {
  final String conda = PyCondaPackageService.getCondaExecutable();
  final ArrayList<String> parameters = Lists.newArrayList(conda, "config", "--remove", "channels", repositoryUrl, "--force");
  final GeneralCommandLine commandLine = new GeneralCommandLine(parameters);

  try {
    final Process process = commandLine.createProcess();
    final CapturingProcessHandler handler = new CapturingProcessHandler(process);
    final ProcessOutput result = handler.runProcess();
    final int exitCode = result.getExitCode();
    if (exitCode != 0) {
      final String message = StringUtil.isEmptyOrSpaces(result.getStdout()) && StringUtil.isEmptyOrSpaces(result.getStderr()) ?
                             "Permission denied" : "Non-zero exit code";
      LOG.warn("Failed to remove repository " + message);
    }
    PyCondaPackageService.getInstance().removeChannel(repositoryUrl);
  }
  catch (ExecutionException e) {
    LOG.warn("Failed to remove repository");
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:PyCondaManagementService.java

示例11: runJython

import com.intellij.execution.process.ProcessOutput; //导入依赖的package包/类
public static ProcessOutput runJython(String workDir, String pythonPath, String... args) throws ExecutionException {
  final SimpleJavaSdkType sdkType = new SimpleJavaSdkType();
  final Sdk ideaJdk = sdkType.createJdk("tmp", SystemProperties.getJavaHome());
  SimpleJavaParameters parameters = new SimpleJavaParameters();
  parameters.setJdk(ideaJdk);
  parameters.setMainClass("org.python.util.jython");

  File jythonJar = new File(PythonHelpersLocator.getPythonCommunityPath(), "lib/jython.jar");
  parameters.getClassPath().add(jythonJar.getPath());

  parameters.getProgramParametersList().add("-Dpython.path=" + pythonPath + File.pathSeparator + workDir);
  parameters.getProgramParametersList().addAll(args);
  parameters.setWorkingDirectory(workDir);

  final GeneralCommandLine commandLine = JdkUtil.setupJVMCommandLine(sdkType.getVMExecutablePath(ideaJdk), parameters, false);
  final CapturingProcessHandler processHandler = new CapturingProcessHandler(commandLine.createProcess());
  return processHandler.runProcess();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:JythonUnitTestUtil.java

示例12: getTestsOutput

import com.intellij.execution.process.ProcessOutput; //导入依赖的package包/类
@NotNull
public TestsOutput getTestsOutput(@NotNull final ProcessOutput processOutput) {
  String congratulations = "Congratulations!";
  for (String line : processOutput.getStdoutLines()) {
    if (line.startsWith(ourStudyPrefix)) {
      if (line.contains(TEST_OK)) {
        continue;
      }

      if (line.contains(CONGRATS_MESSAGE)) {
        congratulations = line.substring(line.indexOf(CONGRATS_MESSAGE) + CONGRATS_MESSAGE.length());
      }

      if (line.contains(TEST_FAILED)) {
        return new TestsOutput(false, line.substring(line.indexOf(TEST_FAILED) + TEST_FAILED.length()));
      }
    }
  }

  return new TestsOutput(true, congratulations);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:StudyTestRunner.java

示例13: validateLocale

import com.intellij.execution.process.ProcessOutput; //导入依赖的package包/类
@Nullable
private Notification validateLocale() throws SvnBindException {
  ProcessOutput versionOutput = getVersionClient().runCommand(false);
  Notification result = null;

  Matcher matcher = INVALID_LOCALE_WARNING_PATTERN.matcher(versionOutput.getStderr());
  if (matcher.find()) {
    LOG.info(matcher.group());

    result = new ExecutableNotValidNotification(prepareDescription(UIUtil.getHtmlBody(matcher.group()), false), NotificationType.WARNING);
  }
  else if (!isEnglishOutput(versionOutput.getStdout())) {
    LOG.info("\"svn --version\" command contains non-English output " + versionOutput.getStdout());

    result = new ExecutableNotValidNotification(prepareDescription(SvnBundle.message("non.english.locale.detected.warning"), false),
                                                NotificationType.WARNING);
  }

  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:SvnExecutableChecker.java

示例14: testCommitAfterRenameDir

import com.intellij.execution.process.ProcessOutput; //导入依赖的package包/类
@Test
public void testCommitAfterRenameDir() throws Exception {
  final VirtualFile child = prepareDirectoriesForRename();

  renameFileInCommand(child, "newchild");
  checkin();

  final ProcessOutput runResult = runSvn("log", "-q", "newchild/a.txt");
  verify(runResult);
  final List<String> lines = StringUtil.split(runResult.getStdout(), "\n");
  for (Iterator<String> iterator = lines.iterator(); iterator.hasNext();) {
    final String next = iterator.next();
    if (next.startsWith(LOG_SEPARATOR_START)) {
      iterator.remove();
    }
  }
  Assert.assertEquals(2, lines.size());
  Assert.assertTrue(lines.get(0).startsWith("r2 |"));
  Assert.assertTrue(lines.get(1).startsWith("r1 |"));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:SvnRenameTest.java

示例15: testRenamePackageWithChildren

import com.intellij.execution.process.ProcessOutput; //导入依赖的package包/类
@Test
public void testRenamePackageWithChildren() throws Exception {
  final VirtualFile child = prepareDirectoriesForRename();

  renameFileInCommand(child, "childnew");
  final ProcessOutput result = runSvn("status");
  verifySorted(result, "A + childnew",
               "D child",
               "D child" + File.separatorChar + "a.txt",
               "D child" + File.separatorChar + "grandChild",
               "D child" + File.separatorChar + "grandChild" + File.separatorChar + "b.txt");

  refreshVfs();   // wait for end of refresh operations initiated from SvnFileSystemListener
  final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
  changeListManager.ensureUpToDate(false);
  List<Change> changes = new ArrayList<Change>(changeListManager.getDefaultChangeList().getChanges());
  Assert.assertEquals(4, changes.size());
  sortChanges(changes);
  verifyChange(changes.get(0), "child", "childnew");
  verifyChange(changes.get(1), "child" + File.separatorChar + "a.txt", "childnew" + File.separatorChar + "a.txt");
  verifyChange(changes.get(2), "child" + File.separatorChar + "grandChild", "childnew" + File.separatorChar + "grandChild");
  verifyChange(changes.get(3), "child" + File.separatorChar + "grandChild" + File.separatorChar + "b.txt", "childnew" + File.separatorChar + "grandChild" + File.separatorChar + "b.txt");

  VirtualFile oldChild = myWorkingCopyDir.findChild("child");
  Assert.assertEquals(FileStatus.DELETED, changeListManager.getStatus(oldChild));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:SvnRenameTest.java


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