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


Java ProcessOutput.isTimeout方法代码示例

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


在下文中一共展示了ProcessOutput.isTimeout方法的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: 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

示例3: isValid

import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
public static boolean isValid(@Nullable String executable) {
  try {
    if (StringUtil.isEmptyOrSpaces(executable)) {
      return false;
    }
    GeneralCommandLine commandLine = new GeneralCommandLine();
    //noinspection ConstantConditions
    commandLine.setExePath(executable);
    commandLine.addParameter("--version");
    commandLine.addParameter("-q");
    CapturingProcessHandler handler = new CapturingProcessHandler(commandLine.createProcess(), CharsetToolkit.getDefaultSystemCharset());
    ProcessOutput result = handler.runProcess(30 * 1000);
    return !result.isTimeout() && result.getStderr().isEmpty();
  }
  catch (Throwable e) {
    return false;
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:HgUtil.java

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

示例5: run

import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
@NotNull
protected static String run(@NotNull File workingDir, @NotNull List<String> params, boolean ignoreNonZeroExitCode)
  throws ExecutionException
{
  final ProcessBuilder builder = new ProcessBuilder().command(params);
  builder.directory(workingDir);
  builder.redirectErrorStream(true);
  Process clientProcess;
  try {
    clientProcess = builder.start();
  }
  catch (IOException e) {
    throw new RuntimeException(e);
  }

  CapturingProcessHandler handler = new CapturingProcessHandler(clientProcess, CharsetToolkit.getDefaultSystemCharset());
  ProcessOutput result = handler.runProcess(30 * 1000);
  if (result.isTimeout()) {
    throw new RuntimeException("Timeout waiting for the command execution. Command: " + StringUtil.join(params, " "));
  }

  String stdout = result.getStdout().trim();
  if (result.getExitCode() != 0) {
    if (ignoreNonZeroExitCode) {
      debug("{" + result.getExitCode() + "}");
    }
    debug(stdout);
    if (!ignoreNonZeroExitCode) {
      throw new ExecutionException(result.getExitCode(), stdout);
    }
  }
  else {
    debug(stdout);
  }
  return stdout;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:Executor.java

示例6: doAnnotate

import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
@Nullable
@Override
public Results doAnnotate(State collectedInfo) {
  if (collectedInfo == null) return null;
  ArrayList<String> options = Lists.newArrayList();

  if (collectedInfo.ignoredErrors.size() > 0) {
    options.add("--ignore=" + StringUtil.join(collectedInfo.ignoredErrors, ","));
  }
  options.add("--max-line-length=" + collectedInfo.margin);
  options.add("-");

  GeneralCommandLine cmd = PythonHelper.PEP8.newCommandLine(collectedInfo.interpreterPath, options);

  ProcessOutput output = PySdkUtil.getProcessOutput(cmd, new File(collectedInfo.interpreterPath).getParent(),
                                                    ImmutableMap.of("PYTHONBUFFERED", "1"),
                                                    10000,
                                                    collectedInfo.fileText.getBytes(), false);

  Results results = new Results(collectedInfo.level);
  if (output.isTimeout()) {
    LOG.info("Timeout running pep8.py");
  }
  else if (output.getStderrLines().isEmpty()) {
    for (String line : output.getStdoutLines()) {
      final Problem problem = parseProblem(line);
      if (problem != null) {
        results.problems.add(problem);
      }
    }
  }
  else if (((ApplicationInfoImpl) ApplicationInfo.getInstance()).isEAP()) {
    LOG.info("Error running pep8.py: " + output.getStderr());
  }
  return results;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:Pep8ExternalAnnotator.java

示例7: generateSkeletonsForList

import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
private boolean generateSkeletonsForList(@NotNull final PySkeletonRefresher refresher,
                                         ProgressIndicator indicator,
                                         @Nullable final String currentBinaryFilesPath) throws InvalidSdkException {
  final PySkeletonGenerator generator = new PySkeletonGenerator(refresher.getSkeletonsPath(), mySdk, currentBinaryFilesPath);
  indicator.setIndeterminate(false);
  final String homePath = mySdk.getHomePath();
  if (homePath == null) return false;
  GeneralCommandLine cmd = PythonHelper.EXTRA_SYSPATH.newCommandLine(homePath, Lists.newArrayList(myQualifiedName));
  final ProcessOutput runResult = PySdkUtil.getProcessOutput(cmd,
                                                             new File(homePath).getParent(),
                                                             PythonSdkType.getVirtualEnvExtraEnv(homePath), 5000
  );
  if (runResult.getExitCode() == 0 && !runResult.isTimeout()) {
    final String extraPath = runResult.getStdout();
    final PySkeletonGenerator.ListBinariesResult binaries = generator.listBinaries(mySdk, extraPath);
    final List<String> names = Lists.newArrayList(binaries.modules.keySet());
    Collections.sort(names);
    final int size = names.size();
    for (int i = 0; i != size; ++i) {
      final String name = names.get(i);
      indicator.setFraction((double)i / size);
      if (needBinaryList(name)) {
        indicator.setText2(name);
        final PySkeletonRefresher.PyBinaryItem item = binaries.modules.get(name);
        final String modulePath = item != null ? item.getPath() : "";
        //noinspection unchecked
        refresher.generateSkeleton(name, modulePath, new ArrayList<String>(), Consumer.EMPTY_CONSUMER);
      }
    }
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:GenerateBinaryStubsFix.java

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

示例9: runs

import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
/**
 * Checks if it is possible to run the specified program.
 * Made protected for tests not to start a process there.
 */
protected boolean runs(@NotNull String exec) {
  GeneralCommandLine commandLine = new GeneralCommandLine();
  commandLine.setExePath(exec);
  try {
    CapturingProcessHandler handler = new CapturingProcessHandler(commandLine.createProcess(), CharsetToolkit.getDefaultSystemCharset());
    ProcessOutput result = handler.runProcess((int)TimeUnit.SECONDS.toMillis(5));
    return !result.isTimeout();
  }
  catch (ExecutionException e) {
    return false;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:GitExecutableDetector.java

示例10: parseVersion

import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
@NotNull
private static Version parseVersion(@NotNull ProcessOutput output) throws SvnBindException {
  // TODO: This or similar check should likely go to CommandRuntime - to be applied for all commands
  if (output.isTimeout()) {
    throw new SvnBindException(String.format("Exit code: %d, Error: %s", output.getExitCode(), output.getStderr()));
  }

  return parseVersion(output.getStdout());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:CmdVersionClient.java

示例11: run

import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
@NotNull
protected static String run(@NotNull File workingDir, @NotNull List<String> params, boolean ignoreNonZeroExitCode)
        throws ExecutionException
{
    final ProcessBuilder builder = new ProcessBuilder().command(params);
    builder.directory(workingDir);
    builder.redirectErrorStream(true);
    Process clientProcess;
    try {
        clientProcess = builder.start();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    String commandLine = StringUtil.join(params, " ");
    CapturingProcessHandler handler = new CapturingProcessHandler(clientProcess, CharsetToolkit.getDefaultSystemCharset(), commandLine);
    ProcessOutput result = handler.runProcess(30 * 1000);
    if (result.isTimeout()) {
        throw new RuntimeException("Timeout waiting for the command execution. Command: " + commandLine);
    }

    String stdout = result.getStdout().trim();
    if (result.getExitCode() != 0) {
        if (ignoreNonZeroExitCode) {
            debug("{" + result.getExitCode() + "}");
        }
        debug(stdout);
        if (!ignoreNonZeroExitCode) {
            throw new ExecutionException(result.getExitCode(), stdout);
        }
    } else {
        debug(stdout);
    }
    return stdout;
}
 
开发者ID:JChrist,项目名称:gitextender,代码行数:36,代码来源:GitExecutor.java

示例12: getSuccessProcessOutput

import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
@Nullable
public static ProcessOutput getSuccessProcessOutput(@NotNull final String scriptText, @Nullable final String path) {
  final ProcessOutput output = getProcessOutput(scriptText, path);
  if (output == null) return null;

  if (output.getExitCode() != 0) {
    LOG.info("Failed because of: " + output.getStderr());
    return null;
  }
  if (output.isTimeout()) {
    LOG.info("Failed because of timeout.");
    return null;
  }
  return output;
}
 
开发者ID:ktisha,项目名称:TheRPlugin,代码行数:16,代码来源:TheRUtils.java

示例13: isExecutableValid

import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
/**
 * Returns true if the supplied executable is valid.
 * Default implementation: try to execute the given executable and test if output returned errors.
 * This can take a long time since it spawns external process.
 * @param executable Path to executable.
 * @return true if process with the supplied executable completed without errors and with exit code 0.
 */
protected boolean isExecutableValid(@NotNull String executable) {
  try {
    GeneralCommandLine commandLine = new GeneralCommandLine();
    commandLine.setExePath(executable);
    CapturingProcessHandler handler = new CapturingProcessHandler(commandLine.createProcess(), CharsetToolkit.getDefaultSystemCharset());
    ProcessOutput result = handler.runProcess(60 * 1000);
    return !result.isTimeout() && (result.getExitCode() == 0) && result.getStderr().isEmpty();
  } catch (Throwable e) {
    return false;
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:ExecutableValidator.java

示例14: run

import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
protected static String run(List<String> params) {
  final ProcessBuilder builder = new ProcessBuilder().command(params);
  builder.directory(ourCurrentDir());
  builder.redirectErrorStream(true);
  Process clientProcess;
  try {
    clientProcess = builder.start();
  }
  catch (IOException e) {
    throw new RuntimeException(e);
  }

  CapturingProcessHandler handler = new CapturingProcessHandler(clientProcess, CharsetToolkit.getDefaultSystemCharset());
  ProcessOutput result = handler.runProcess(30*1000);
  if (result.isTimeout()) {
    throw new RuntimeException("Timeout waiting for the command execution. Command: " + StringUtil.join(params, " "));
  }

  if (result.getExitCode() != 0) {
    log("{" + result.getExitCode() + "}");
  }
  String stdout = result.getStdout().trim();
  if (!StringUtil.isEmptyOrSpaces(stdout)) {
    log(stdout.trim());
  }
  return stdout;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:28,代码来源:Executor.java

示例15: isExecutableValid

import com.intellij.execution.process.ProcessOutput; //导入方法依赖的package包/类
@Override
public boolean isExecutableValid(@NotNull String executable) {
  try {
    GeneralCommandLine commandLine = new GeneralCommandLine();
    commandLine.setExePath(executable);
    commandLine.addParameter("--version");
    CapturingProcessHandler handler = new CapturingProcessHandler(commandLine.createProcess(), CharsetToolkit.getDefaultSystemCharset());
    ProcessOutput result = handler.runProcess(30 * 1000);
    return !result.isTimeout() && (result.getExitCode() == 0) && result.getStderr().isEmpty();
  } catch (Throwable e) {
    return false;
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:14,代码来源:GitExecutableValidator.java


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