private void executeScript(final ShardingContext shardingContext, final String scriptCommandLine) { CommandLine commandLine = CommandLine.parse(scriptCommandLine); commandLine.addArgument(GsonFactory.getGson().toJson(shardingContext), false); try { new DefaultExecutor().execute(commandLine); } catch (final IOException ex) { throw new JobConfigurationException("Execute script failure.", ex); } } }
cmdLine = CommandLine.parse(commandLine);
/** * Create a command line from a string. * * @param line the first element becomes the executable, the rest the arguments * @return the parsed command line * @throws IllegalArgumentException If line is null or all whitespace */ public static CommandLine parse(final String line) { return parse(line, null); }
public static int executeCommand(String command, String... envVars) throws IOException { CommandLine cmdLine = CommandLine.parse(command); DefaultExecutor executor = new DefaultExecutor(); Map<String, String> env = addEnvProperties(envVars); ExecuteWatchdog watchDog = new ExecuteWatchdog(TIMEOUT); executor.setWatchdog(watchDog); executor.setStreamHandler(new PumpStreamHandler()); int result = executor.execute(cmdLine, env); if (executor.isFailure(result)) { if (watchDog.killedProcess()) { throw new RuntimeException("Reached timeout while running: " + cmdLine); } throw new RuntimeException("Process failed with return code [" + result + "]: " + cmdLine); } return result; }
try { logger.trace("Executing: " + fullCommand); CommandLine cli = CommandLine.parse(fullCommand); Executor executor = new DefaultExecutor(); LogOutputStream outStream =
/** * Extracted for testing... */ private static CommandLine getCommandLine(String line) { return CommandLine.parse(line); }
public void execute(String cmd) throws ExecuteException, IOException, InterruptedException { execute(CommandLine.parse(cmd)); }
/** * Creates a new IPhoneSimulatorBinary that will run the given application on the iPhone * Simulator. The simulator will be run using the SDK specified by the * {@code webdriver.iphone.sdk} system property. * * @param iWebDriverApp Path to the executable to run on the simulator. This file should specify * the executable that is an immediate child of the {@code iwebDriver.app} directory. * @throws IOException If an I/O error occurs. */ public IPhoneSimulatorBinary(File iWebDriverApp) { System.out.println(String.format( "%s launch %s --exit", getIphoneSimPath(), iWebDriverApp.getParentFile().getAbsoluteFile())); this.commandLine = CommandLine.parse(String.format( "%s launch %s --exit", getIphoneSimPath(), iWebDriverApp.getParentFile().getAbsoluteFile())); }
public static int[] queryVersion() throws IOException { SenchaVersionParser senchaVersionParser = new SenchaVersionParser(); internalExecute(CommandLine.parse("sencha switch -l"), senchaVersionParser, null); return senchaVersionParser.versions; }
/** * @VisibleForTesting */ void doProcess(final InputStream in, final OutputStream out) throws IOException { final ByteArrayOutputStream errorStream = new ByteArrayOutputStream(); final Executor executor = new DefaultExecutor(); executor.setStreamHandler(new PumpStreamHandler(out, errorStream, in)); final int result = executor.execute(CommandLine.parse(NGANN_COMMAND)); LOG.debug("result={}", result); if (result != 0) { throw new ExecuteException("Processing failed: " + new String(errorStream.toByteArray()), result); } }
public static String runProcess(String command) throws Exception { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); CommandLine commandline = CommandLine.parse(command); DefaultExecutor exec = new DefaultExecutor(); PumpStreamHandler streamHandler = new PumpStreamHandler(outputStream); exec.setStreamHandler(streamHandler); exec.execute(commandline); return(outputStream.toString()); } }
private void executeScript(final ShardingContext shardingContext, final String scriptCommandLine) { CommandLine commandLine = CommandLine.parse(scriptCommandLine); commandLine.addArgument(GsonFactory.getGson().toJson(shardingContext), false); try { new DefaultExecutor().execute(commandLine); } catch (final IOException ex) { throw new JobConfigurationException("Execute script failure.", ex); } } }
private void executeScript(final ShardingContext shardingContext, final String scriptCommandLine) { CommandLine commandLine = CommandLine.parse(scriptCommandLine); commandLine.addArgument(GsonFactory.getGson().toJson(shardingContext), false); try { new DefaultExecutor().execute(commandLine); } catch (final IOException ex) { throw new JobConfigurationException("Execute script failure.", ex); } } }
private void executeScript(final ShardingContext shardingContext, final String scriptCommandLine) { CommandLine commandLine = CommandLine.parse(scriptCommandLine); commandLine.addArgument(GsonFactory.getGson().toJson(shardingContext), false); try { new DefaultExecutor().execute(commandLine); } catch (final IOException ex) { throw new JobConfigurationException("Execute script failure.", ex); } } }
private Protos.CommandInfo buildCommand(final Protos.CommandInfo.URI uri, final String script, final ShardingContexts shardingContexts, final boolean isCommandExecutor) { Protos.CommandInfo.Builder result = Protos.CommandInfo.newBuilder().addUris(uri).setShell(true); if (isCommandExecutor) { CommandLine commandLine = CommandLine.parse(script); commandLine.addArgument(GsonFactory.getGson().toJson(shardingContexts), false); result.setValue(Joiner.on(" ").join(commandLine.getExecutable(), Joiner.on(" ").join(commandLine.getArguments()))); } else { result.setValue(script); } return result.build(); }
public boolean run(String args) { String cli = executable.getAbsolutePath() + " " + args; System.out.println(">> " + cli); CommandLine parse = CommandLine.parse(cli); DefaultExecutor executor = new DefaultExecutor(); executor.setExitValue(0); try { return executor.execute(parse) == 0; } catch (IOException e) { e.printStackTrace(); return false; } }
public boolean run(String args) { String cli = executable.getAbsolutePath() + " " + args; System.out.println(">> " + cli); CommandLine parse = CommandLine.parse(cli); DefaultExecutor executor = new DefaultExecutor(); executor.setExitValue(0); try { return executor.execute(parse) == 0; } catch (IOException e) { e.printStackTrace(); return false; } }
/** * Executes the given command with KRB5_CONFIG environment variable pointing to the specialized * config file for the embedded KDC server. */ public static void executeCommand(String command, EmbeddedADS adsServer) throws IOException { Map<String, String> environmentMap = ImmutableMap.<String, String>builder() .put("KRB5_CONFIG", adsServer.getKrb5Conf().getAbsolutePath()) .build(); CommandLine cli = CommandLine.parse(command); Executor executor = new DefaultExecutor(); int retValue = executor.execute(cli, environmentMap); assertThat(retValue).isZero(); }
/** * This method loads the default arguments required to spawn appium * * @return {@link CommandLine} * @throws IOException */ private CommandLine createCommandForChildProcess() throws IOException { LOGGER.entering(); CommandLine cmdLine = CommandLine.parse("appium"); // add the program argument / dash options cmdLine.addArguments(getProgramArguments()); LOGGER.exiting(cmdLine.toString()); return cmdLine; }
public void executeWorkItem(WorkItem workItem, WorkItemManager manager) { String command = (String) workItem.getParameter("Command"); CommandLine commandLine = CommandLine.parse(command); DefaultExecutor executor = new DefaultExecutor(); try { executor.execute(commandLine); manager.completeWorkItem(workItem.getId(), null); } catch (Throwable t) { handleException(t); } }