commandline = new Commandline(); if ( customShell != null ) commandline.setShell( customShell ); commandline.setExecutable( executable ); result = CommandLineUtils.executeCommandLine( commandline, stdOut, stdErr ); if ( logger != null ) + commandline.toString() + ", Error message = " + e.getMessage() ); setPid( commandline.getPid() );
public Properties getSystemEnvVars() throws Exception { return CommandLineUtils.getSystemEnvVars(); }
/** * Create a new command line object, given a command following POSIX sh quoting rules * * @param toProcess */ public Commandline( String toProcess ) { setDefaultShell(); String[] tmp = new String[0]; try { tmp = CommandLineUtils.translateCommandline( toProcess ); } catch ( Exception e ) { System.err.println( "Error translating Commandline." ); } if ( ( tmp != null ) && ( tmp.length > 0 ) ) { setExecutable( tmp[0] ); for ( int i = 1; i < tmp.length; i++ ) { createArgument().setValue( tmp[i] ); } } }
throws ScmException Commandline shell = new Commandline(); shell.setWorkingDirectory( workingDirectory.getBasedir() ); shell.setExecutable( "si" ); shell.createArg().setValue( "connect" ); shell.createArg().setValue( "--hostname=" + iRepo.getHost() ); shell.createArg().setValue( "--batch" ); shell.createArg().setValue( "--password=" + iRepo.getPassword() ); CommandLineUtils.StringStreamConsumer shellConsumer = new CommandLineUtils.StringStreamConsumer(); getLogger().debug( "Executing: " + CommandLineUtils.toString( shell.getCommandline() ) ); int exitCode = CommandLineUtils.executeCommandLine( shell, shellConsumer, shellConsumer ); if ( exitCode != 0 ) throw new ScmException( "Can't login to integrity. Message : " + shellConsumer.toString() ); getLogger().error( "Command Line Connect Exception: " + cle.getMessage() ); throw new ScmException( "Can't login to integrity. Message : " + cle.getMessage() );
private void syncLabel( ScmProviderRepository repo, ScmFileSet files, String tag, PerforceTagConsumer consumer ) { Commandline cl = createLabelsyncCommandLine( (PerforceScmProviderRepository) repo, files.getBasedir(), files, tag ); try { if ( getLogger().isDebugEnabled() ) { getLogger().debug( PerforceScmProvider.clean( "Executing: " + cl.toString() ) ); } CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer(); int exitCode = CommandLineUtils.executeCommandLine( cl, consumer, err ); if ( exitCode != 0 ) { String cmdLine = CommandLineUtils.toString( cl.getCommandline() ); StringBuilder msg = new StringBuilder( "Exit code: " + exitCode + " - " + err.getOutput() ); msg.append( '\n' ); msg.append( "Command line was:" + cmdLine ); throw new CommandLineException( msg.toString() ); } } catch ( CommandLineException e ) { if ( getLogger().isErrorEnabled() ) { getLogger().error( "CommandLineException " + e.getMessage(), e ); } } }
public BlameScmResult executeBlameCommand( ScmProviderRepository repo, ScmFileSet workingDirectory, String filename ) throws ScmException { if ( getLogger().isDebugEnabled() ) { getLogger().debug( "executing blame command..." ); } Commandline cl = createCommandLine( workingDirectory.getBasedir(), filename ); ClearCaseBlameConsumer consumer = new ClearCaseBlameConsumer( getLogger() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); int exitCode; try { if ( getLogger().isDebugEnabled() ) { getLogger().debug( "Executing: " + cl.getWorkingDirectory().getAbsolutePath() + ">>" + cl.toString() ); } exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); } catch ( CommandLineException ex ) { throw new ScmException( "Error while executing cvs command.", ex ); } if ( exitCode != 0 ) { return new BlameScmResult( cl.toString(), "The cleartool command failed.", stderr.getOutput(), false ); } return new BlameScmResult( cl.toString(), consumer.getLines() ); }
/** * {@inheritDoc} */ protected ScmResult executeRemoveCommand( ScmProviderRepository repo, ScmFileSet files, String message ) throws ScmException { Commandline cl = createCommandLine( (PerforceScmProviderRepository) repo, files.getBasedir(), files ); PerforceRemoveConsumer consumer = new PerforceRemoveConsumer(); try { CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer(); int exitCode = CommandLineUtils.executeCommandLine( cl, consumer, err ); if ( exitCode != 0 ) { String cmdLine = CommandLineUtils.toString( cl.getCommandline() ); StringBuilder msg = new StringBuilder( "Exit code: " + exitCode + " - " + err.getOutput() ); msg.append( '\n' ); msg.append( "Command line was:" + cmdLine ); throw new CommandLineException( msg.toString() ); } } catch ( CommandLineException e ) { throw new ScmException( "CommandLineException " + e.getMessage(), e ); } return new RemoveScmResult( cl.toString(), consumer.getRemovals() ); }
public static int executeCleanUp( File workinDirectory, StreamConsumer stdout, StreamConsumer stderr, ScmLogger logger ) throws CommandLineException { Commandline cl = new Commandline(); cl.setExecutable( "svn" ); cl.setWorkingDirectory( workinDirectory.getAbsolutePath() ); if ( logger != null ) { if ( logger.isInfoEnabled() ) { logger.info( "Executing: " + SvnCommandLineUtils.cryptPassword( cl ) ); if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) { logger.info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); } } } return CommandLineUtils.executeCommandLine( cl, stdout, stderr ); }
public static boolean isCvsNT() throws ScmException { Commandline cl = new Commandline(); cl.setExecutable( "cvs" ); cl.createArg().setValue( "-v" ); CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer(); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); try { CommandLineUtils.executeCommandLine( cl, stdout, stderr ); } catch ( CommandLineException e ) { throw new ScmException( "Error while executing command.", e ); } return stdout.getOutput().indexOf( "CVSNT" ) >= 0; }
public static int execute( Commandline cl, CommandLineUtils.StringStreamConsumer stdout, CommandLineUtils.StringStreamConsumer stderr, ScmLogger logger ) throws ScmException { if ( logger.isInfoEnabled() ) { logger.info( "Executing: " + cl ); logger.info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); } int exitCode; try { exitCode = CommandLineUtils.executeCommandLine( cl, stdout, stderr ); } catch ( CommandLineException ex ) { throw new ScmException( "Error while executing command.", ex ); } return exitCode; }
Commandline cli = new Commandline(); cli.setWorkingDirectory( workingDirectory.getAbsolutePath() ); cli.setExecutable( executable ); cli.addArguments( args ); returnCode = CommandLineUtils.executeCommandLine( cli, out, err );
/** {@inheritDoc} */ protected RemoveScmResult executeCvsCommand( Commandline cl, List<ScmFile> removedFiles ) throws ScmException { CommandLineUtils.StringStreamConsumer consumer = new CommandLineUtils.StringStreamConsumer(); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); int exitCode; try { exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); } catch ( CommandLineException ex ) { throw new ScmException( "Error while executing command.", ex ); } // TODO: actually it may have partially succeeded - should we cvs update the files and parse "A " responses? if ( exitCode != 0 ) { return new RemoveScmResult( cl.toString(), "The cvs command failed.", stderr.getOutput(), false ); } return new RemoveScmResult( cl.toString(), removedFiles ); } }
protected StatusScmResult executeStatusCommand( ScmProviderRepository repo, ScmFileSet fileSet ) throws ScmException { Commandline cl = createCommandLine( fileSet ); CvsStatusConsumer consumer = new CvsStatusConsumer( getLogger(), fileSet.getBasedir() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); getLogger().info( "Executing: " + cl ); getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); int exitCode; getLogger().debug( "Working directory: " + fileSet.getBasedir().getAbsolutePath() ); getLogger().debug( "Command line: " + cl ); try { exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); } catch ( CommandLineException ex ) { throw new ScmException( "Error while executing command.", ex ); } if ( exitCode != 0 ) { return new StatusScmResult( cl.toString(), "The cvs command failed.", stderr.getOutput(), false ); } return new StatusScmResult( cl.toString(), consumer.getChangedFiles() ); }
public BlameScmResult executeBlameCommand( ScmProviderRepository repo, ScmFileSet workingDirectory, String filename ) throws ScmException { Commandline cl = createCommandLine( workingDirectory.getBasedir(), filename ); TfsBlameConsumer consumer = new TfsBlameConsumer( getLogger() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); int exitCode; try { exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); } catch ( CommandLineException ex ) { throw new ScmException( "Error while executing command.", ex ); } if ( exitCode != 0 ) { return new BlameScmResult( cl.toString(), "The tfs command failed.", stderr.getOutput(), false ); } return new BlameScmResult( cl.toString(), consumer.getLines() ); }
&& ( getLogger().isWarnEnabled() ) ) getLogger().warn( "This provider doesn't support changelog with on a given branch." ); new StarteamChangeLogConsumer( fileSet.getBasedir(), getLogger(), startDate, endDate, datePattern ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); throw new ScmException( "Error while executing command.", ex ); return new ChangeLogScmResult( cl.toString(), "The 'stcmd' command failed.", stderr.getOutput(), false ); return new ChangeLogScmResult( cl.toString(), new ChangeLogSet( consumer.getModifications(), startDate, endDate ) );
public static int executeCommandline( Commandline cl, StreamConsumer consumer, CommandLineUtils.StringStreamConsumer stderr, ScmLogger logger ) throws ScmException { try { if ( logger.isInfoEnabled() ) { logger.info( "Executing: " + cl ); logger.info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); } int exitcode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); if ( logger.isDebugEnabled() ) { logger.debug( "VSS Command Exit_Code: " + exitcode ); } return exitcode; } catch ( CommandLineException ex ) { throw new ScmException( "Error while executing command.", ex ); } }
public static int executeCommandLine( Commandline cl, InputStream systemIn, StreamConsumer systemOut, StreamConsumer systemErr ) throws CommandLineException { return executeCommandLine( cl, systemIn, systemOut, systemErr, 0 ); }
static int executeCmd( HgConsumer consumer, Commandline cmd ) throws ScmException { final int exitCode; try { exitCode = CommandLineUtils.executeCommandLine( cmd, consumer, consumer ); } catch ( CommandLineException ex ) { throw new ScmException( "Command could not be executed: " + cmd, ex ); } return exitCode; }
/** {@inheritDoc} */ protected StatusScmResult executeCvsCommand( Commandline cl ) throws ScmException { CvsStatusConsumer consumer = new CvsStatusConsumer( getLogger(), cl.getWorkingDirectory() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); int exitCode; try { exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); } catch ( CommandLineException ex ) { throw new ScmException( "Error while executing command.", ex ); } if ( exitCode != 0 ) { return new StatusScmResult( cl.toString(), "The cvs command failed.", stderr.getOutput(), false ); } return new StatusScmResult( cl.toString(), consumer.getChangedFiles() ); } }
public static int execute( Commandline cl, StreamConsumer consumer, CommandLineUtils.StringStreamConsumer stderr, ScmLogger logger ) throws CommandLineException { // SCM-482: force English resource bundle cl.addEnvironment( "LC_MESSAGES", "en" ); int exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); exitCode = checkIfCleanUpIsNeeded( exitCode, cl, consumer, stderr, logger ); return exitCode; }