/** * Return the command line as a string. * @return the command line. */ @Override public String toString() { return toString(getCommandline()); }
/** * Get a string description. * @return the command line as a string. */ @Override public String toString() { return Commandline.toString(getCommandline()); }
/** * Changes the password to '***' so it isn't displayed on screen if the build fails * * @param cmd The command line to clean * @return The command line as a string with out the password */ private String formatCommandLine(Commandline cmd) { StringBuffer sBuff = new StringBuffer(cmd.toString()); int indexUser = sBuff.substring(0).indexOf(FLAG_LOGIN); if (indexUser > 0) { int indexPass = sBuff.substring(0).indexOf(",", indexUser); int indexAfterPass = sBuff.substring(0).indexOf(" ", indexPass); for (int i = indexPass + 1; i < indexAfterPass; i++) { sBuff.setCharAt(i, '*'); } } return sBuff.toString(); }
/** * Execute the created command line. * * @throws BuildException on error. */ @Override public void execute() throws BuildException { int result = 0; buildCmdLine(); result = run(commandLine); if (result == ERROR_EXIT_STATUS) { // This is the exit status String msg = "Failed executing: " + commandLine.toString(); throw new BuildException(msg, getLocation()); } }
if (Commandline.toString(args).length() > COMMAND_LINE_LIMIT && firstFileName >= 0) { try {
/** * Run the command. * @param cmd the command line to use. * @param out the output stream handler to use. * @return the exit code of the command. */ protected int runCmd(Commandline cmd, ExecuteStreamHandler out) { try { Project aProj = getProject(); Execute exe = new Execute(out); exe.setAntRun(aProj); exe.setWorkingDirectory(aProj.getBaseDir()); exe.setCommandline(cmd.getCommandline()); return exe.execute(); } catch (IOException e) { String msg = "Failed executing: " + cmd.toString() + ". Exception: " + e.getMessage(); throw new BuildException(msg, getLocation()); } }
/** * Execute the given command, and return it's output * @param cmdline command line to execute * @return output of the command line */ protected String runS(Commandline cmdline) { String outV = "opts.cc.runS.output" + pcnt++; ExecTask exe = new ExecTask(this); Commandline.Argument arg = exe.createArg(); exe.setExecutable(cmdline.getExecutable()); arg.setLine(Commandline.toString(cmdline.getArguments())); exe.setOutputproperty(outV); exe.execute(); return getProject().getProperty(outV); }
String msg = "Failed executing: " + commandLine.toString(); throw new BuildException(msg, getLocation()); log("Executing " + commandLine.toString(), Project.MSG_VERBOSE); result = runCmd(commandLine, new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN)); if (result != 0 && !ignorerc) { String msg = "Failed executing: " + commandLine.toString() + ". Return code was " + result; throw new BuildException(msg, getLocation()); String msg = "Failed executing: " + commandLine.toString() + ". Exception: " + e.getMessage(); throw new BuildException(msg, getLocation());
getProject().log(commandLine.toString(), Project.MSG_DEBUG);
public Command(String[] cmdArray, Map<String, String> environment) { this.cmdArray = cmdArray; this.commandLine = Commandline.toString(cmdArray); this.environment = environment; }
public Command(String[] cmdArray, List<String> environment) { this.cmdArray = cmdArray; this.commandLine = Commandline.toString(cmdArray); this.environment = parseEnvironment(environment); }
int run(String executable, String args);
default <T extends Tool> int run(Class<T> execClass, String[] args, ObjectMap options) throws StorageEngineException { String hadoopRoute = options.getString(HadoopVariantStorageEngine.HADOOP_BIN, "hadoop"); String jar = HadoopVariantStorageEngine.getJarWithDependencies(options); String executable = hadoopRoute + " jar " + jar + ' ' + execClass.getName(); Logger logger = LoggerFactory.getLogger(MRExecutor.class); if (logger.isDebugEnabled()) { logger.debug(executable + ' ' + Arrays.toString(args)); } return run(executable, Commandline.toString(args)); }
@Deprecated public static void queueJob(String toolName, String wumJobName, int wumUserId, String outdir, String commandLine, String queue, String logFileId) throws Exception { logFileId = logFileId == null || logFileId.isEmpty() ? "" : "." + logFileId; queue = queue == null || queue.isEmpty() ? getQueueName(toolName) : queue; String outFile = Paths.get(outdir, "sge_out" + logFileId + ".log").toString(); String errFile = Paths.get(outdir, "sge_err" + logFileId + ".log").toString(); // init sge job String outScript = outdir + "/command_line.sh"; Files.write(Paths.get(outScript), commandLine.getBytes()); ArrayList<String> args = new ArrayList<>(Arrays.asList( "qsub", "-V", "-N", getSgeJobName(toolName, wumJobName), "-o", outFile, "-e", errFile, "-q", queue, outScript)); String[] cmdArray = args.toArray(new String[args.size()]); logger.info("SgeManager: Enqueuing job: " + Commandline.toString(cmdArray)); // thrown command to shell Command sgeCommand = new Command(cmdArray, Collections.EMPTY_LIST); SingleProcess sp = new SingleProcess(sgeCommand); sp.getRunnableProcess().run(); if (sgeCommand.getExitValue() != 0 || sgeCommand.getException() != null) { throw new Exception("Can't queue job " + getSgeJobName(toolName, wumJobName) + ". qsub returned " + sgeCommand.getExitValue() + " and message:" + sgeCommand.getException()); } }
logger.info("SgeManager: Enqueuing job: " + Commandline.toString(cmdArray));
/** * Executes the task in a separate VM */ private void executeOutOfProcess() throws BuildException { try { // Without this, the tool class won't be found by executeJava(). Class<?> toolClass = resolveClass(toolClassName); super.setClassname(toolClassName); // convert arguments into a string for use by executeJava() // also auto-quotes arguments with spaces String line = Commandline.toString(cmdline.getArguments()); super.createArg().setLine(line); int exitCode = super.executeJava(); // Check exit code. if (isFatalFailure(toolClass, exitCode)) throw new BuildException(taskName + " task failed."); } finally { if (originalContextClassLoader != null) Thread.currentThread().setContextClassLoader(originalContextClassLoader); } }
final boolean newEnvironment, final Environment env) throws BuildException { try { task.log(Commandline.toString(cmdline), task.getCommandLogLevel());
log("Command invoked: " + command.getJavaCommand().toString());
log("Command invoked: " + command.getJavaCommand().toString());