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


Java ProcessResult.getExitValue方法代码示例

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


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

示例1: doesNeedOneMoreAttempt

import org.zeroturnaround.exec.ProcessResult; //导入方法依赖的package包/类
@Override
protected boolean doesNeedOneMoreAttempt(@Nonnull final ProcessResult processResult, @Nonnull final String consoleOut, @Nonnull final String consoleErr) throws IOException, MojoExecutionException {
  boolean result = false;
  if (processResult.getExitValue() != 0) {
    final Matcher matcher = PATTERN_NO_SUBMODULE_MAPPING_FOUND_IN_GIT.matcher(consoleErr);

    if (matcher.find()) {
      final List<String> packagesWithDetectedGitCacheErrors = extractProblemPackagesFromErrorLog(consoleErr);
      if (!packagesWithDetectedGitCacheErrors.isEmpty()) {
        if (this.autofixGitCache) {

          getLog().warn("Trying to fix the detected git cache errors automatically..");

          result = tryToFixGitCacheErrorsForPackages(packagesWithDetectedGitCacheErrors);
        } else {

          for (final String s : packagesWithDetectedGitCacheErrors) {
            getLog().error(String.format("Detected Git cache error for package '%s', can be fixed with 'git rm -r --cached .'", s));
          }

        }
      }
    }
  }
  return result;
}
 
开发者ID:raydac,项目名称:mvn-golang,代码行数:27,代码来源:GolangGetMojo.java

示例2: confirmShutdown

import org.zeroturnaround.exec.ProcessResult; //导入方法依赖的package包/类
private void confirmShutdown() throws ShutDownException {
  int exitValue;
  try {
    ProcessResult rabbitMqProcessResult = rabbitMqProcess.get(timeoutDuration, TimeUnit.MILLISECONDS);
    exitValue = rabbitMqProcessResult.getExitValue();
  } catch (InterruptedException | ExecutionException | TimeoutException e) {
    throw new ShutDownException("Error while waiting " + timeoutDuration + " " + timeoutUnit + "for "
        + "RabbitMQ Server to shut down", e);
  }

  if (exitValue == 0) {
    LOGGER.debug("RabbitMQ Server stopped successfully.");
  } else {
    LOGGER.warn("RabbitMQ Server stopped with exit value: " + exitValue);
  }
}
 
开发者ID:AlejandroRivera,项目名称:embedded-rabbitmq,代码行数:17,代码来源:ShutdownHelper.java

示例3: parse

import org.zeroturnaround.exec.ProcessResult; //导入方法依赖的package包/类
default S parse(final ProcessResult processResult) throws RktException {
  if (processResult.getExitValue() == 0) {
    return parse(processResult.outputUTF8());
  } else {
    throw new RktException(processResult.getExitValue(), processResult.outputUTF8());
  }
}
 
开发者ID:honnix,项目名称:rkt-launcher,代码行数:8,代码来源:Command.java

示例4: execute

import org.zeroturnaround.exec.ProcessResult; //导入方法依赖的package包/类
public int execute(@Nullable String customCommand, @Nonnull final Log logger, @Nonnull final File cvsFolder, @Nonnull @MustNotContainNull final String... args) {
    final List<String> cli = new ArrayList<>();
    cli.add(GetUtils.findFirstNonNull(customCommand, this.command));
    for (final String s : args) {
        cli.add(s);
    }

    if (logger.isDebugEnabled()) {
        logger.debug("Executing repo command : " + cli);
    }

    final ByteArrayOutputStream errorStream = new ByteArrayOutputStream();
    final ByteArrayOutputStream outStream = new ByteArrayOutputStream();

    final ProcessExecutor executor = new ProcessExecutor(cli);

    int result = -1;

    try {
        final ProcessResult processResult = executor.directory(cvsFolder).redirectError(errorStream).redirectOutput(outStream).executeNoTimeout();
        result = processResult.getExitValue();

        if (logger.isDebugEnabled()) {
            logger.debug("Exec.out.........................................");
            logger.debug(new String(errorStream.toByteArray(), Charset.defaultCharset()));
            logger.debug(".................................................");
        }

        if (result != 0) {
            logger.error(new String(errorStream.toByteArray(), Charset.defaultCharset()));
        }

    } catch (Exception ex) {
        logger.error("Unexpected error", ex);
    }

    return result;
}
 
开发者ID:raydac,项目名称:mvn-golang,代码行数:39,代码来源:AbstractRepo.java

示例5: getErlangVersion

import org.zeroturnaround.exec.ProcessResult; //导入方法依赖的package包/类
/**
 * @return a String representing the Erlang version, such as {@code "18.2.1"}
 * @throws ErlangShellException if the Erlang command can't be executed or if it exits unexpectedly.
 */
public String getErlangVersion() throws ErlangShellException {
  String erlangShell = UNIX_ERL_COMMAND;

  Logger processOutputLogger = LoggerFactory.getLogger(
      String.format(LOGGER_TEMPLATE, this.getClass().getName(), erlangShell));

  Slf4jStream stream = Slf4jStream.of(processOutputLogger);

  final ProcessExecutor processExecutor = config.getProcessExecutorFactory().createInstance()
      .command(erlangShell, "-noshell", "-eval", "erlang:display(erlang:system_info(otp_release)), halt().")
      .timeout(config.getErlangCheckTimeoutInMillis(), TimeUnit.MILLISECONDS)
      .redirectError(stream.as(Level.WARN))
      .destroyOnExit()
      .readOutput(true);

  try {
    ProcessResult processResult = processExecutor.execute();
    int exitValue = processResult.getExitValue();
    if (exitValue == 0) {
      return processResult.outputUTF8().trim().replaceAll("[\"\\\\n]", ""); // "18.2.1\n" -> "18.2.1"
    } else {
      throw new ErlangShellException("Erlang exited with status " + exitValue);
    }
  } catch (IOException | InterruptedException | TimeoutException e) {
    throw new ErlangShellException("Exception executing Erlang shell command", e);
  }
}
 
开发者ID:AlejandroRivera,项目名称:embedded-rabbitmq,代码行数:32,代码来源:ErlangShell.java

示例6: getProcessResult

import org.zeroturnaround.exec.ProcessResult; //导入方法依赖的package包/类
private ProcessResult getProcessResult(String[] args, String executionErrorMessage, String unexpectedExitCodeMessage) {
  ProcessResult processResult;
  try {
    Future<ProcessResult> startedProcess = execute(args);
    processResult = startedProcess.get(config.getDefaultRabbitMqCtlTimeoutInMillis(), TimeUnit.MILLISECONDS);
  } catch (InterruptedException | ExecutionException | TimeoutException e) {
    throw new RabbitMqCommandException(executionErrorMessage, e);
  }

  int exitValue = processResult.getExitValue();
  if (exitValue != 0) {
    throw new RabbitMqCommandException(unexpectedExitCodeMessage + exitValue);
  }
  return processResult;
}
 
开发者ID:AlejandroRivera,项目名称:embedded-rabbitmq,代码行数:16,代码来源:RabbitMqPlugins.java

示例7: testJavaVersion

import org.zeroturnaround.exec.ProcessResult; //导入方法依赖的package包/类
@Test
public void testJavaVersion() throws Exception {
  ProcessListenerImpl listener = new ProcessListenerImpl();
  ProcessResult result = new ProcessExecutor("java", "-version").addListener(listener).execute();
  int exit = result.getExitValue();
  Assert.assertEquals(0, exit);
  Assert.assertNotNull(listener.executor);
  Assert.assertNotNull(listener.process);
  Assert.assertNotNull(listener.result);
  Assert.assertEquals(result,  listener.result);
}
 
开发者ID:zeroturnaround,项目名称:zt-exec,代码行数:12,代码来源:ProcessListenerSuccessTest.java

示例8: doMainBusiness

import org.zeroturnaround.exec.ProcessResult; //导入方法依赖的package包/类
protected boolean doMainBusiness(@Nullable final ProxySettings proxySettings, final int maxAttempts) throws InterruptedException, MojoFailureException, MojoExecutionException, IOException {
  int iterations = 0;

  boolean error = false;

  while (true) {
    final ProcessExecutor executor = prepareExecutor(proxySettings);
    if (executor == null) {
      logOptionally("The Mojo should not be executed");
      break;
    }
    final ProcessResult result = executor.executeNoTimeout();
    final int resultCode = result.getExitValue();
    error = resultCode != 0 && !isIgnoreErrorExitCode();
    iterations++;

    final String outLog = extractOutAsString();
    final String errLog = extractErrorOutAsString();

    if (getLog().isDebugEnabled()) {
      getLog().debug("OUT_LOG: " + outLog);
      getLog().debug("ERR_LOG: " + errLog);
    }

    if (error || this.processConsoleOut(resultCode, outLog, errLog)) {
      printLogs(error || enforcePrintOutput(), outLog, errLog);
    }

    if (doesNeedOneMoreAttempt(result, outLog, errLog)) {
      if (iterations > maxAttempts) {
        throw new MojoExecutionException("Too many iterations detected, may be some loop and bug at mojo " + this.getClass().getName());
      }
      getLog().warn("Make one more attempt...");
    } else {
      if (!isIgnoreErrorExitCode()) {
        assertProcessResult(result);
      }
      break;
    }
  }

  return error;
}
 
开发者ID:raydac,项目名称:mvn-golang,代码行数:44,代码来源:AbstractGolangMojo.java

示例9: assertProcessResult

import org.zeroturnaround.exec.ProcessResult; //导入方法依赖的package包/类
private void assertProcessResult(@Nonnull final ProcessResult result) throws MojoFailureException {
  final int code = result.getExitValue();
  if (code != 0) {
    throw new MojoFailureException("Process exit code : " + code);
  }
}
 
开发者ID:raydac,项目名称:mvn-golang,代码行数:7,代码来源:AbstractGolangMojo.java

示例10: execute

import org.zeroturnaround.exec.ProcessResult; //导入方法依赖的package包/类
/**
 * Method description
 *
 *
 * @throws MojoExecutionException
 * @throws MojoFailureException
 */
@Override
public void execute() throws MojoExecutionException, MojoFailureException
{
  if (!skipTests)
  {
    NodeExecutor node = createNodeExecutor();

    node.install(MODULE, karmaVersion);

    List<String> cmd = Lists.newArrayList(KARMA, "start", karmaConfig);

    if (singleRun)
    {
      cmd.add("--single-run");
    }

    NodeExecutor.CommandExecutor executor = node.cmd(cmd);

    if (ignoreResult)
    {
      try
      {
        ProcessResult result = executor.process().exitValueAny().execute();
        int ev = result.getExitValue();

        if (ev > 0)
        {
          logger.warn("karma ended with status code {}", ev);
        }
      }
      catch (Exception ex)
      {
        logger.error("karma test ended with an exception", ex);
      }
    }
    else
    {
      executor.execute();
    }
  }
  else
  {
    logger.warn("karma tests are skipped by skipTests parameter");
  }
}
 
开发者ID:sdorra,项目名称:buildfrontend-maven-plugin,代码行数:53,代码来源:KarmaMojo.java


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