The callback `succeed` is called if all the provided command were executed successfully otherwise the callback `skip` is called.
763889
function({options}, succeed, skip) {
    return each(options.if_exec).call((cmd, next) => {
      this.log({
        message: `Nikita \`if_exec\`: ${cmd}`,
        level: 'DEBUG',
        module: 'nikita/misc/conditions'
      });
      return this.system.execute({
        cmd: cmd,
        relax: true,
        stderr_log: false,
        stdin_log: false,
        stdout_log: false
      }, function(err, {code}) {
        this.log({
          message: `Nikita \`if_exec\`: code is "${code}"`,
          level: 'INFO',
          module: 'nikita/misc/conditions'
        });
        if (code === 0) {
          return next();
        } else {
          return skip();
        }
      });
    }).next(succeed);
  }
747849
private boolean tryExecutingCommand(Command cmd)
        throws IOException,
               FTPReplyParseException,
               ServerException {
        Reply reply = controlChannel.exchange(cmd);
        return Reply.isPositiveCompletion(reply);
    }
379647
def check_call(self, cmd):
        
        ret, _ = self._call(cmd, False)
        if ret != 0:  # pragma: no cover
            raise RemoteCommandFailure(command=cmd, ret=ret)
1283826
function doExec(callback, command) {
    let args = Array.prototype.slice.call(arguments);
    args.splice(0, 2);  //remove the first cb and command
    if (!this.isConnected()) {
      return callback(thorin.error('REDIS.NOT_CONNECTED', 'The connection is not active yet.'));
    }
    command = command.toLowerCase();
    if (typeof this[connections].default.connection[command] !== 'function') {
      return callback(thorin.error('REDIS.COMMAND_NOT_FOUND', 'Invalid command issued: ' + command, 500));
    }
    args.push((err, res) => {
      if (err) {
        return callback(thorin.error('REDIS.EXEC', 'Redis command failed to execute.', err));
      }
      if (command === 'hgetall' && typeof res === 'object' && res) {
        // backward compatibility
        if (Object.keys(res).length === 0) {
          res = null;
        }
      }
      callback(null, res);
    });
    this[connections].default.emit('command', command, args);
    this[connections].default.connection[command].apply(this[connections].default.connection, args);
  }
1263946
def run(self, context=None, stdout=None, stderr=None):
        ""
        if self.should_skip():
            self._record_skipped_example(self.formatter)
            self.num_skipped += 1
        else:
            self.execute(context, stdout, stderr)
        return self.num_successes, self.num_failures, self.num_skipped
189234
function execCommand(command, options, callback) {
		var args = [],
			extraArgs = (options.args || []).slice(0),
			preferGlobal = options.preferGlobal || false,
			srcSuccess = options.success,
			srcFailure = options.failure,
			success, failure;

		// remove processed options
		delete options.args;
		delete options.command;
		delete options.failure;
		delete options.preferGlobal;
		delete options.success;

		// must have output to satisfy success/failure conditions
		if (srcSuccess || srcFailure) {
			delete options.quiet;
		}

		// determine succes and failure types
		if (_.isRegExp(srcSuccess)) {
			success = function(data) { return srcSuccess.test(data); };
		} else if (_.isString(srcSuccess)) {
			success = function(data) { return data.toString().indexOf(srcSuccess) !== -1; };
		} else if (_.isFunction(srcSuccess)) {
			success = srcSuccess;
		} else if (!!success) {
			success = undefined;
			grunt.fail.warn('invalid type for success option, must be string, regexp, or function');
		}

		if (_.isRegExp(srcFailure)) {
			failure = function(data) { return srcFailure.test(data); };
		} else if (_.isString(srcFailure)) {
			failure = function(data) { return data.toString().indexOf(srcFailure) !== -1; };
		} else if (_.isFunction(srcFailure)) {
			failure = srcFailure;
		} else if (!!failure) {
			failure = undefined;
			grunt.fail.warn('invalid type for failure option, must be string, regexp, or function');
		}

		// create the list of command arguments
		Object.keys(options).forEach(function(key) {
			var value = options[key],
				isBool = _.isBoolean(value);
			if (!isBool || (isBool && !!value)) {
				args.push(camelCaseToDash(key));
			}
			if (!isBool) { args.push(value); }
		});
		args.unshift(command);

		// add non-option, non-flag arguments
		args = args.concat(extraArgs);

		// spawn command and output
		grunt.log.writeln('titanium ' + args.join(' '));
		var tiOpts = process.env.GRUNT_TITANIUM_TEST || success || failure ?
				{} : {stdio: 'inherit'},
			ti = spawn(getTitaniumPath(preferGlobal), args, tiOpts);

		// prepare functions for killing this process
		function killer(data) {
			grunt.log.write(data);
			if (ti.killed) {
				return;
			} else if (success && success(data)) {
				ti.kill();
				grunt.log.ok('titanium run successful');
			} else if (failure && failure(data)) {
				ti.kill();
				grunt.fail.warn('titanium run failed');
			}
		}

		// listen for success or failure conditions
		if (success || failure) {
			ti.stdout.on('data', killer);
			ti.stderr.on('data', killer);
		}

		// handle titanium's exit
		ti.on('close', function(code) {
			if (command !== 'build' || options.buildOnly) {
				if (code) {
					grunt.fail.fatal('titanium ' + command + ' failed.');
				} else {
					grunt.log.ok('titanium ' + command + ' complete.');
				}
			}
			return callback(ti.killed ? null : code);
		});

		// write output to a file for analysis in test specs
		if (process.env.GRUNT_TITANIUM_TEST) {
			var testFile = path.resolve('tmp', preferGlobal ? 'tmp_global.txt' : 'tmp.txt');
			grunt.file.mkdir(path.dirname(testFile));
			fs.writeFileSync(testFile, '');
			ti.stdout.on('data', function(data) {
				fs.appendFileSync(testFile, data);
			});
		}
	}
265058
function({options}, succeed, skip) {
    // Default to `options.target` if "true"
    if (typeof options.unless_exists === 'boolean' && options.target) {
      options.unless_exists = options.unless_exists ? [options.target] : null;
    }
    return each(options.unless_exists).call((unless_exists, next) => {
      return this.fs.exists({
        target: unless_exists
      }, (err, {exists}) => {
        if (exists) {
          this.log({
            message: `File exists ${unless_exists}, skipping`,
            level: 'INFO',
            module: 'nikita/misc/conditions'
          });
          return skip();
        } else {
          this.log({
            message: `File doesnt exists ${unless_exists}, continuing`,
            level: 'DEBUG',
            module: 'nikita/misc/conditions'
          });
          return next();
        }
      });
    }).next(succeed);
  }
943855
def join(self, ignore_errors=False):
    """"""
    assert self._status_fn, "Asked to join a task which hasn't had any commands executed on it"
    check_interval = 0.2
    status_fn = self._status_fn
    if not self.wait_for_file(status_fn, max_wait_sec=30):
      self.log(f"Retrying waiting for {status_fn}")
    while not self.exists(status_fn):
      self.log(f"Still waiting for {self._cmd}")
      self.wait_for_file(status_fn, max_wait_sec=30)
    contents = self.read(status_fn)

    # if empty wait a bit to allow for race condition
    if len(contents) == 0:
      time.sleep(check_interval)
      contents = self.read(status_fn)
    status = int(contents.strip())
    self.last_status = status

    if status != 0:
      extra_msg = '(ignoring error)' if ignore_errors else '(failing)'
      if util.is_set('NCLUSTER_RUN_WITH_OUTPUT_ON_FAILURE') or True:
        self.log(
          f"Start failing output {extra_msg}: \n{'*'*80}\n\n '{self.read(self._out_fn)}'")
        self.log(f"\n{'*'*80}\nEnd failing output")
      if not ignore_errors:
        raise RuntimeError(f"Command {self._cmd} returned status {status}")
      else:
        self.log(f"Warning: command {self._cmd} returned status {status}")

    return status
993173
function run(cmd) {
        return function (callback, options) {
            grunt.verbose.or.ok("Executing " + cmd);
            exec(cmd, options || {}, function (error, stdout, stderr) {
                if (error) {
                    grunt.fatal("'" + cmd + "' failed with :" + stderr);
                } else {
                    grunt.verbose.writeln("Result of " + cmd + ':\n' + stdout);
                    callback();
                }
            });
        };
    }
279425
function(commands) {
		if (!commands || (commands.length === 0)) {
			return true;
		}
		if (typeof commands === 'string') {
			commands = [commands];
		}
		return commands.every(function(command) {
			logger.info('Starting command "%s"...', command);
			var result = exec(
				command,
				{cwd: path.resolve('.')}
			);
			if (result.status !== 0) { // error
				logger.error('Error: "%s" - "%s"', result.stdout, result.stderr.trim());
				return false;
			}
			logger.success('Command successfully finished');
			logger.log('Command result: "%s"', result.stdout);
			return true;
		});
	}
114715
function (cmd, callback) {
    if (!cmd || !_.isObject(cmd)) {
      debug(err);
      return callback(new Error('Please pass a valid command!'), null);
    }
    return this.aggregate.validateCommand(cmd, callback);
  }
711085
def execute_and_report(command, *args, **kwargs):
    
    logging.info("Execute: %s %s" % (command, " ".join(args)))
    try:
        status, out, err = execute(command, *args, **kwargs)
        if status == 0:
            logging.info(
                "%s Finished successfully. Exit Code: 0.",
                os.path.basename(command),
            )
            return True
        else:
            try:
                logging.error(
                    "%s failed! Exit Code: %s\nOut: %s\nError: %s",
                    os.path.basename(command),
                    status,
                    out,
                    err,
                )
            except Exception as e:
                # This fails when some non ASCII characters are returned
                # from the application
                logging.error(
                    "%s failed [%s]! Exit Code: %s\nOut: %s\nError: %s",
                    e,
                    os.path.basename(command),
                    status,
                    repr(out),
                    repr(err),
                )
            return False
    except Exception:
        logging.exception(
            "%s failed! Exception thrown!", os.path.basename(command)
        )
        return False
204915
def do_continue(self, args):
        
        self._do_print_from_last_cmd = True
        self._interp.cont()
        return True
652738
def execute_async(self, command, callback=None):
        
        try:
            logger.debug(('{0}: execute async "{1}"'
                          'with callback {2}'.format(self.target_address,
                                                     command,
                                                     callback)))
            future = self.executor.submit(self.execute, command)
            if callback is not None:
                future.add_done_callback(callback)
            return future
        except (AuthenticationException, SSHException,
                ChannelException, SocketError) as ex:
            logger.critical(("{0} execution failed on {1} with exception:"
                             "{2}".format(command, self.target_address,
                                               ex)))
            raise SSHCommandError(self.target_address, command, ex)
307496
async def execute(self, raise_on_error=True):
        ""
        stack = self.command_stack
        if not stack:
            return []
        if self.scripts:
            await self.load_scripts()
        if self.transaction or self.explicit_transaction:
            exec = self._execute_transaction
        else:
            exec = self._execute_pipeline

        conn = self.connection
        if not conn:
            conn = self.connection_pool.get_connection()
            # assign to self.connection so reset() releases the connection
            # back to the pool after we're done
            self.connection = conn

        try:
            return await exec(conn, stack, raise_on_error)
        except (ConnectionError, TimeoutError) as e:
            conn.disconnect()
            if not conn.retry_on_timeout and isinstance(e, TimeoutError):
                raise
            # if we were watching a variable, the watch is no longer valid
            # since this connection has died. raise a WatchError, which
            # indicates the user should retry his transaction. If this is more
            # than a temporary failure, the WATCH that the user next issues
            # will fail, propegating the real ConnectionError
            if self.watching:
                raise WatchError("A ConnectionError occured on while watching "
                                 "one or more keys")
            # otherwise, it's safe to retry since the transaction isn't
            # predicated on any state
            return await exec(conn, stack, raise_on_error)
        finally:
            await self.reset()
317715
def on_success(self, retval, task_id, args, kwargs):
        """"""
        super().on_success(retval, task_id, args, kwargs)
        self._operation_run.on_success()
943333
def execute_command(self, cmd, params=None, callback=None, raw=False):
        '''
        
        '''
        def execute_with_callbacks(cmd, params=None, callback=None, raw=False):
            code, params = self.send_command(cmd, params, raw)
            if callback:
                callback(code, params)
            return code, params

        if self.daemon:
            t = Thread(target=execute_with_callbacks,
                    args=(cmd, ), kwargs={'params':params, 'callback':callback, 'raw':raw})
            t.daemon = True
            t.start()
        else:
            return execute_with_callbacks(cmd, params, callback, raw)