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


Java ProcessOutput.isCancelled方法代码示例

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


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

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

示例2: getCondaOutput

import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
private ProcessOutput getCondaOutput(@NotNull final String command, List<String> arguments) throws ExecutionException {
  final String condaExecutable = PyCondaPackageService.getCondaExecutable();
  if (condaExecutable == null) throw new PyExecutionException("Cannot find conda", "Conda", Collections.<String>emptyList(), new ProcessOutput());

  final String path = getCondaDirectory();
  if (path == null) throw new PyExecutionException("Empty conda name for " + mySdk, command, arguments);

  final ArrayList<String> parameters = Lists.newArrayList(condaExecutable, command, "-p", path);
  parameters.addAll(arguments);

  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;
  if (indicator != null) {
    result = handler.runProcessWithProgressIndicator(indicator);
  }
  else {
    result = handler.runProcess();
  }
  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);
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:PyCondaPackageManagerImpl.java

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

示例4: checkShellPath

import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
public ProcessOutput checkShellPath(DatabaseVendor databaseVendor, String shellPath) throws ExecutionException, TimeoutException {
    if (isBlank(shellPath)) {
        return null;
    }

    GeneralCommandLine commandLine = new GeneralCommandLine();
    commandLine.setExePath(shellPath);
    if (testParameter != null) {
        commandLine.addParameter(testParameter);
    }
    CapturingProcessHandler handler = new CapturingProcessHandler(commandLine.createProcess(), CharsetToolkit.getDefaultSystemCharset());
    ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
    ProcessOutput result = indicator == null ?
            handler.runProcess(TIMEOUT_MS) :
            handler.runProcessWithProgressIndicator(indicator);
    if (result.isTimeout()) {
        throw new TimeoutException("Couldn't check " + databaseVendor.name + " CLI executable - stopped by timeout.");
    } else if (result.isCancelled()) {
        throw new ProcessCanceledException();
    } else if (result.getExitCode() != 0 || !result.getStderr().isEmpty()) {
        throw new ExecutionException(String.format("Errors while executing %s. exitCode=%s errors: %s",
                commandLine.toString(),
                result.getExitCode(),
                result.getStderr()));
    }
    return result;
}
 
开发者ID:dboissier,项目名称:nosql4idea,代码行数:28,代码来源:NoSqlConfigurable.java


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