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


Java DefaultExecuteResultHandler.waitFor方法代码示例

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


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

示例1: testExecutable

import org.apache.commons.exec.DefaultExecuteResultHandler; //导入方法依赖的package包/类
private static boolean testExecutable() {
    CommandLine commandLine = CommandLine.parse(RCLIProcessor.rExecutable + " " + VERSION_CALL);

    DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
    Executor executor = new DefaultExecutor();

    // put a watchdog with a timeout
    ExecuteWatchdog watchdog = new ExecuteWatchdog(new Long(TIMEOUT_SECONDS) * 1000);
    executor.setWatchdog(watchdog);

    try {
        executor.execute(commandLine, resultHandler);
        resultHandler.waitFor();
        int exitVal = resultHandler.getExitValue();
        if (exitVal != 0) {
            return false;
        }
            return true;
    }
    catch (Exception e) {
        return false;
    }
}
 
开发者ID:52North,项目名称:movingcode,代码行数:24,代码来源:RCLIProbe.java

示例2: testExecutable

import org.apache.commons.exec.DefaultExecuteResultHandler; //导入方法依赖的package包/类
public static boolean testExecutable() {
	CommandLine commandLine = CommandLine.parse(PythonCLIProcessor.pythonExecutable + " --version");

	DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
	Executor executor = new DefaultExecutor();

	// put a watchdog with a timeout
	ExecuteWatchdog watchdog = new ExecuteWatchdog(new Long(timeout_seconds) * 1000);
	executor.setWatchdog(watchdog);

	try {
		executor.execute(commandLine, resultHandler);
		resultHandler.waitFor();
		int exitVal = resultHandler.getExitValue();
		if (exitVal != 0) {
			return false;
		}
		return true;
	}
	catch (Exception e) {
		return false;
	}
}
 
开发者ID:52North,项目名称:movingcode,代码行数:24,代码来源:PythonCLIProbe.java

示例3: getVersion

import org.apache.commons.exec.DefaultExecuteResultHandler; //导入方法依赖的package包/类
public static String getVersion() {

		try {
			URL scriptURL = PythonCLIProbe.class.getResource(versionScriptFile);
			File sf = new File(scriptURL.toURI());
			String scriptPath = sf.getAbsolutePath();

			CommandLine commandLine = CommandLine.parse(PythonCLIProcessor.pythonExecutable + " " + scriptPath);

			DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
			Executor executor = new DefaultExecutor();

			// put a watchdog with a timeout
			ExecuteWatchdog watchdog = new ExecuteWatchdog(new Long(timeout_seconds) * 1000);
			executor.setWatchdog(watchdog);

			ByteArrayOutputStream os = new ByteArrayOutputStream();
			PumpStreamHandler psh = new PumpStreamHandler(os);
			executor.setStreamHandler(psh);

			executor.execute(commandLine, resultHandler);
			resultHandler.waitFor();
			int exitVal = resultHandler.getExitValue();
			if (exitVal != 0) {
				return null;
			}

			return (os.toString());

		}
		catch (Exception e) {
			return null;
		}
	}
 
开发者ID:52North,项目名称:movingcode,代码行数:35,代码来源:PythonCLIProbe.java

示例4: learn

import org.apache.commons.exec.DefaultExecuteResultHandler; //导入方法依赖的package包/类
public static void learn(String path, String factsForLearningFile,
		String rulesDefinitionFile, String learnedWeightsFile)
		throws Exception {
	CommandLine cmdLine = new CommandLine(path + "/learnwts");
	cmdLine.addArgument("-i");
	cmdLine.addArgument(factsForLearningFile);
	cmdLine.addArgument("-o");
	cmdLine.addArgument(rulesDefinitionFile);
	cmdLine.addArgument("-t");
	cmdLine.addArgument(learnedWeightsFile);
	cmdLine.addArgument("-g -multipleDatabases");
	
	DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
	ExecuteWatchdog watchdog = new ExecuteWatchdog(60 * 1000);
	Executor executor = new DefaultExecutor();
	executor.setExitValue(1);
	executor.setWatchdog(watchdog);
	executor.execute(cmdLine, resultHandler);
	resultHandler.waitFor();
}
 
开发者ID:SmartSearch,项目名称:Edge-Node,代码行数:21,代码来源:AlchemyEngine.java

示例5: executeCommand

import org.apache.commons.exec.DefaultExecuteResultHandler; //导入方法依赖的package包/类
private Future<CommandResult> executeCommand(String command, File executionDirectory, boolean silent)
		throws IOException {

	StringWriter writer = new StringWriter();
	DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();

	try (WriterOutputStream outputStream = new WriterOutputStream(writer)) {

		String outerCommand = "/bin/bash -lc";

		CommandLine outer = CommandLine.parse(outerCommand);
		outer.addArgument(command, false);

		DefaultExecutor executor = new DefaultExecutor();
		executor.setWorkingDirectory(executionDirectory);
		executor.setStreamHandler(new PumpStreamHandler(silent ? outputStream : System.out, null));
		executor.execute(outer, ENVIRONMENT, resultHandler);

		resultHandler.waitFor();

	} catch (InterruptedException e) {
		throw new IllegalStateException(e);
	}

	return new AsyncResult<CommandResult>(
			new CommandResult(resultHandler.getExitValue(), writer.toString(), resultHandler.getException()));
}
 
开发者ID:spring-projects,项目名称:spring-data-dev-tools,代码行数:28,代码来源:CommonsExecOsCommandOperations.java

示例6: getVersion

import org.apache.commons.exec.DefaultExecuteResultHandler; //导入方法依赖的package包/类
private static String getVersion() {
    try {
        CommandLine commandLine = CommandLine.parse(RCLIProcessor.rExecutable + " " + VERSION_CALL);

        DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
        Executor executor = new DefaultExecutor();

        // put a watchdog with a timeout
        ExecuteWatchdog watchdog = new ExecuteWatchdog(new Long(TIMEOUT_SECONDS) * 1000);
        executor.setWatchdog(watchdog);

        ByteArrayOutputStream os = new ByteArrayOutputStream();
        PumpStreamHandler psh = new PumpStreamHandler(os);
        executor.setStreamHandler(psh);

        executor.execute(commandLine, resultHandler);
        resultHandler.waitFor();
        int exitVal = resultHandler.getExitValue();
        if (exitVal != 0) {
            return null;
        }

        String osString = os.toString();

        String versionString = osString.substring(osString.lastIndexOf(": ") + 2);
        versionString = versionString.substring(0, versionString.indexOf('\n'));

        return (versionString);
    }
    catch (Exception e) {
        LOGGER.error("Could not get version string.", e);
        return null;
    }
}
 
开发者ID:52North,项目名称:movingcode,代码行数:35,代码来源:RCLIProbe.java


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