Handle a command callback
347749
private void handleCommandCallback(final String message) {
		// JSON callback
        final JSONObject jsonObject = new JSONObject(message);
		final String eventType = jsonObject.getString("event");

		final CommandCallbackHandler commandCallbackHandler = commandCallbacks.get(eventType);
		if( commandCallbackHandler == null ) {
			logger.error("Unknown event: {}", message);
			return;
		}
		try {
			commandCallbackHandler.handleChannelData(jsonObject);
		} catch (final BitfinexClientException e) {
			logger.error("Got an exception while handling callback");
		}
	}
1103683
def _call(self, command, ignore_errors=None):
        
        if ignore_errors is None:
            ignore_errors = []
        cmd = []
        cmd.extend(self._prefix)
        cmd.extend([self._path, "-iP"])
        cmd.extend(command)
        command = cmd

        logger.debug("Cmd %s" % command)
        null = open('/dev/null', 'w')
        retcode = subprocess.call(command, stdout=null, stderr=null)
        null.close()

        if retcode in ignore_errors:
            logger.debug(
                "<-- Cmd %s returned %d (ignored)" % (command, retcode))
            return

        if retcode:
            logger.error(
                "<-- Cmd %s returned: %d (error)" % (command, retcode))
            raise subprocess.CalledProcessError(retcode, command)

        logger.debug("<-- Returned %d (good)" % retcode)
        return
587635
def handle(self):
        ""
        if self.TELNET_ISSUE:
            self.writeline(self.TELNET_ISSUE)
        if not self.authentication_ok():
            return
        if self.DOECHO:
            self.writeline(self.WELCOME)

        self.session_start()
        while self.RUNSHELL:
            raw_input = self.readline(prompt=self.PROMPT).strip()
            self.input = self.input_reader(self, raw_input)
            self.raw_input = self.input.raw
            if self.input.cmd:
                cmd = self.input.cmd.upper()
                params = self.input.params
                if self.COMMANDS.has_key(cmd):
                    try:
                        self.COMMANDS[cmd](params)
                    except:
                        log.exception('Error calling %s.' % cmd)
                        (t, p, tb) = sys.exc_info()
                        if self.handleException(t, p, tb):
                            break
                else:
                    self.writeerror("Unknown command '%s'" % cmd)
        log.debug("Exiting handler")
759564
def handle_call(self, frame, argument_list):
        """"""
        fun = frame.f_code.co_name
        log.info('Calling: %r' % fun)

        init = 'Echo|%s' % dump({
            'for':
                '__call__',
            'val':
                '%s(%s)' % (
                    fun, ', '.join([
                        '%s=%s' % (key, self.safe_better_repr(value))
                        for key, value in get_args(frame).items()
                    ])
                )
        })
        self.interaction(
            frame, init=init, exception_description='Calling %s' % fun
        )
1078514
def handle_cmd_options():
    '''
    
    '''
    parser = OptionParser()
    parser.add_option("-s", "--silent", action="store_true", dest="silent",
                      help="print any warnings", default=False)
    (options, args) = parser.parse_args()
    return options, args
503361
function execute(command, callback){
  exec(command, function(error, stdout, stderr){ callback(error, stdout); });
}
1167724
def _call(self, command, ignore_errors=None):
        
        if ignore_errors is None:
            ignore_errors = []

        command = self._get_command(command)
        logger.debug("Cmd %s" % command)
        null = open('/dev/null', 'w')
        retcode = subprocess.call(command, stdout=null, stderr=null)
        null.close()

        if retcode in ignore_errors:
            logger.debug(
                "<-- Cmd %s returned %d (ignored)" % (command, retcode))
            return

        if retcode:
            logger.error(
                "<-- Cmd %s returned: %d (error)" % (command, retcode))
            raise subprocess.CalledProcessError(retcode, command)

        logger.debug("<-- Returned %d (good)" % retcode)
        return
1239339
def _command_callback(self, message):
        
        payload = message['payload']
        if message['$'] == 'before':
            self._commands.append({'level': self._depth,
                                   'payload': payload,
                                   'logs': []})
            self._depth += 1
        else:
            while not self._queue.empty():
                self._commands[-1]['logs'].append(self._queue.get())
            self._depth = max(self._depth-1, 0)
232363
def act(self, cmd_name, param):
        
        command = getattr(self, cmd_name)
        if param:
            command(param)
        else:
            command()
1075462
function handler(current, argv) {
        var cmds = pargv._commands;
        var completions = [];
        if (pargv._env.EXEC === argv[0])
            argv.shift(); // remove first arg which is app/exec name.
        var tmpCmd = pargv.getCommand(utils.first(argv)); // is first is known command.
        if (tmpCmd) { // limit to single command if known.
            cmds = {}; // set the commands to just the one known command.
            cmds[tmpCmd._name] = tmpCmd;
            var sliced_1 = argv.slice(1); // remove command name.
            var curCmdIdx_1 = 0;
            var lastCmdIdx_1 = tmpCmd._arguments.length - 1; // last index for commands.
            sliced_1.forEach(function (el, i) {
                if (!constants_1.FLAG_EXP.test(el) && i <= lastCmdIdx_1) {
                    var prev_1 = sliced_1[i - 1] || null;
                    var prevKey = tmpCmd.isOption(prev_1);
                    if (!prevKey && !constants_1.FLAG_EXP.test(prev_1)) // could be val for option.
                        curCmdIdx_1 = i;
                }
            });
            var curIdx = sliced_1.length - 1;
            var prevIdx = sliced_1.length - 2;
            var prev = sliced_1[prevIdx] || null;
            var isFlagPrev = prev && constants_1.FLAG_EXP.test(prev);
            var isBool = tmpCmd.isBool(prev);
            var isOption = isFlagPrev && !isBool;
            var isCommand = (curCmdIdx_1 >= 0) &&
                (curCmdIdx_1 <= lastCmdIdx_1);
            //  !FLAG_EXP.test(sliced[curIdx])
            if (isCommand || isOption) {
                var key = isOption ? tmpCmd.aliasToKey(prev) : tmpCmd.aliasToKey(curCmdIdx_1);
                if (tmpCmd._completions[key])
                    completions = completions.concat(tmpCmd._completions[key]);
            }
            if (tmpCmd._completions['*']) // anon custom completions.
                completions = completions.concat(tmpCmd._completions['*']);
        }
        else {
            var _loop_1 = function (k) {
                var cmd = cmds[k];
                [cmd._name].concat(cmd.aliases(cmd._name) || []) // iterate commands.
                    .forEach(function (el, i) {
                    if (!~completions.indexOf(el))
                        completions.push(el);
                });
                cmd._options.forEach(function (o) {
                    if (!~completions.indexOf(o))
                        completions.push(o);
                    (cmd.aliases(o) || []).forEach(function (el) {
                        if (!~completions.indexOf(el))
                            completions.push(el);
                    });
                });
            };
            for (var k in cmds) {
                _loop_1(k);
            }
        }
        // TODO: clunky redundant need to refactor this.
        var _options = completions.filter(function (c) { return constants_1.FLAG_EXP.test(c); });
        var _cmds = completions.filter(function (c) { return !constants_1.FLAG_EXP.test(c); });
        return _cmds.sort().concat(_options.sort());
    }
249881
def handle(self, msg):
        """"""
        debug_msg = ': {!r}'.format(msg) if self.debug else ''
        log.debug('request: %d bytes%s', len(msg), debug_msg)
        buf = io.BytesIO(msg)
        code, = util.recv(buf, '>B')
        if code not in self.methods:
            log.warning('Unsupported command: %s (%d)', msg_name(code), code)
            return failure()

        method = self.methods[code]
        log.debug('calling %s()', method.__name__)
        reply = method(buf=buf)
        debug_reply = ': {!r}'.format(reply) if self.debug else ''
        log.debug('reply: %d bytes%s', len(reply), debug_reply)
        return reply
406242
function handleCommandError(ex) {
    // If the command throws an exception, display the error message and command help.
    if (ex instanceof Error) {
        console.log(chalk.red(ex.message));
    } else {
        console.log(chalk.red(ex));
    }
    console.log();
    const helpArgs = {
        _: [command]
    };
    helpCommand(helpArgs);
}
1133021
def handle_command_event(self, event, command, args):
        
        argspec = getargspec(command)
        num_all_args = len(argspec.args) - 2  # Ignore self/event args
        num_pos_args = num_all_args - len(argspec.defaults or [])
        if num_pos_args <= len(args) <= num_all_args:
            response = command(self, event, *args)
        elif num_all_args == num_pos_args:
            s = "s are" if num_all_args != 1 else " is"
            response = "%s arg%s required" % (num_all_args, s)
        else:
            bits = (num_pos_args, num_all_args)
            response = "between %s and %s args are required" % bits
        response = "%s: %s" % (self.get_nickname(event), response)
        self.message_channel(response)
217510
def call(cmd, shell=True, **kwargs):
    "  "

    LOGGER.debug("Cmd: %s" % cmd)
    check_call(cmd, shell=shell, stdout=LOGFILE_HANDLER.stream, **kwargs)
1292208
def dispatch(self, command: Command) -> Iterator[Any]:
        
        LOG.debug("Dispatching command %s", command["command"])
        for callback in self._routes[command["command"]]:
            yield callback
431321
function handleIt(cb) {
    callbacks = cb;
    broadcast = callbacks.broadcast;

    let msg = {
      cmd: MessageType.RockPaperScissors,
      handlerId: id
    };
    broadcast("action", msg);

    // Return a promise for the result
    deferred = q.defer();
    return deferred.promise;
  }
1361522
def handle_command(self, command):
        
        try:
            tree = secET.fromstring(command)
        except secET.ParseError:
            logger.debug("Erroneous client input: %s", command)
            raise OSPDError('Invalid data')

        if not self.command_exists(tree.tag) and tree.tag != "authenticate":
            raise OSPDError('Bogus command name')

        if tree.tag == "get_version":
            return self.handle_get_version_command()
        elif tree.tag == "start_scan":
            return self.handle_start_scan_command(tree)
        elif tree.tag == "stop_scan":
            return self.handle_stop_scan_command(tree)
        elif tree.tag == "get_scans":
            return self.handle_get_scans_command(tree)
        elif tree.tag == "get_vts":
            return self.handle_get_vts_command(tree)
        elif tree.tag == "delete_scan":
            return self.handle_delete_scan_command(tree)
        elif tree.tag == "help":
            return self.handle_help_command(tree)
        elif tree.tag == "get_scanner_details":
            return self.handle_get_scanner_details()
        else:
            assert False, "Unhandled command: {0}".format(tree.tag)