A handler for undefined commands.
 Raises Rye::CommandNotFound exception.
344876
def method_missing(cmd, *args, &block)
      if cmd == :to_ary
        super
      elsif @rye_safe
        ex = Rye::CommandNotFound.new(cmd.to_s)
        raise ex unless @rye_exception_hook.has_key? ex.class
        @rye_exception_hook[Rye::CommandNotFound].call ex
      else
        if block.nil?
          run_command cmd, *args
        else
          ex = Rye::CommandNotFound.new(cmd.to_s)
          raise ex unless @rye_exception_hook.has_key? ex.class
        end
      end
    end
172880
def handle_internal_commands(command):
    
    if command.startswith(":"):
        target = _get_registered_target(command[1:], default=None)
        if target:
            return target()
535846
def _check_cmd(call):
    '''
    
    '''
    if call['retcode'] != 0:
        comment = ''
        std_err = call.get('stderr')
        std_out = call.get('stdout')
        if std_err:
            comment += std_err
        if std_out:
            comment += std_out

        raise CommandExecutionError('Error running command: {0}'.format(comment))

    return call
207033
def get_command(name):
    ''''''
    command = global_commands_table.get(name.lower())
    if not command:
        raise CommandNotFound(name)
    return command
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")
110102
function Command(args) {
  if (false === (this instanceof Command)) throw new Error('new operator required');
  if (typeof args == 'function') { // shorthand for function command
    args = {type: 'Function', contents: args};
  }
  if (args instanceof Procedure) { // shorthand for Procedure command
    args = {type: 'Procedure', contents: args};
  }
  args = args || {};
  var i;
  var unusedProperties = getInvalidProperties(args,
    ['name', 'description', 'type', 'contents', 'scope', 'timeout', 'theme', 'icon', 'bucket', 'presentationMode','location','images']);
  var errorList = [];
  for (i = 0; i < unusedProperties.length; i++) errorList.push('invalid property: ' + unusedProperties[i]);
  if (errorList.length > 1) throw new Error('error creating Command: multiple errors');
  if (errorList.length) throw new Error('error creating Command: ' + errorList[0]);
  for (i in args) this[i] = args[i];
  this.name = this.name || "a command"; // name is optional
  if ('string' != typeof this.name) throw new Error('name must be string');
  if ('undefined' == typeof this.description) this.description = this.name + ' Command';
  if ('undefined' == typeof this.type) this.type = 'Stub';
  if (!contains(Command.getTypes(), this.type)) throw new Error('Invalid command type: ' + this.type);
  switch (this.type) {
    case 'Stub':
      break;
    case 'Menu':
      if (!(this.contents instanceof Array)) throw new Error('contents must be array of menu items');
      if (!this.contents.length) throw new Error('contents must be array of menu items');
      for (i in this.contents) {
        if (this.contents.hasOwnProperty(i))
          if (typeof this.contents[i] != 'string' && !(this.contents[i] instanceof Command))
            throw new Error('contents must be array of menu items');
      }
      break;
    case 'Presentation':
      if (!(this.contents instanceof Presentation)) throw new Error('contents must be a Presentation');
      this.presentationMode = this.presentationMode || 'View';
      if (!contains(Command.getPresentationModes(), this.presentationMode)) throw new Error('Invalid presentationMode: ' + this.presentationMode);
      //['View', 'Edit', 'List']
      break;
    case 'Function':
      if (typeof this.contents != 'function') throw new Error('contents must be a Function');
      break;
    case 'Procedure':
      if (!(this.contents instanceof Procedure)) throw new Error('contents must be a Procedure');
      break;
    default:
      throw new TypeError();
  }
  if ('undefined' != typeof this.scope)
    if (!((this.scope instanceof Model) || (this.scope instanceof List)))
      throw new Error('optional scope property must be Model or List');
  if ('undefined' != typeof this.timeout)
    if (typeof this.timeout != 'number') throw new Error('timeout must be a Number');
  if ('undefined' != typeof this.timeout)
    if (typeof this.timeout != 'number') throw new Error('timeout must be a Number');
  if ('undefined' != typeof this.theme) {
    if ('string' != typeof this.theme) throw new Error('invalid theme');
    if (!contains(['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'], this.theme))
      throw new Error('invalid theme');
  }
  if ('undefined' != typeof this.icon) {
    if ('string' != typeof this.icon) throw new Error('invalid icon');
    if (!contains(['fa', 'glyphicon'], this.icon.split('-')[0]) || !this.icon.split('-')[1])
      throw new Error('invalid icon');
  }

  // Validations done
  this._eventListeners = [];
}
1147749
function (cmd, callback) {
    debug('called a custom command handler');
    console.log('Is your use case not solvable without a custom command handling? Sagas? Micro-Services?');

    var self = this;

    function _handle (aggId) {
      var concatenatedId = self.getConcatenatedId(aggId, cmd);

      var isFirst = !self.getNextCommandInQueue(concatenatedId);

      self.queueCommand(concatenatedId, cmd, callback);

      if (!isFirst) {
        return;
      }

      (function handleNext (aggregateId, c) {
        var concId = self.getConcatenatedId(aggregateId, c);
        var cmdEntry = self.getNextCommandInQueue(concId);
        if (cmdEntry) {
          if (cmdEntry.callback.length > 2) {
            self.cmdHndlFn(aggregateId, cmdEntry.command, self, function (err, evts, aggData, meta) {
              self.removeCommandFromQueue(concId, cmdEntry.command);
              handleNext(aggregateId, cmdEntry.command);
              cmdEntry.callback(err, evts, aggData, meta);
            });
            return;
          }
          self.cmdHndlFn(aggregateId, cmdEntry.command, self, function (err, evts) {
            self.removeCommandFromQueue(concId, cmdEntry.command);
            handleNext(aggregateId, cmdEntry.command);
            cmdEntry.callback(err, evts);
          });
        }
      })(aggId, cmd);
    }

    if (dotty.exists(cmd, this.definitions.command.aggregateId)) {
      return _handle(dotty.get(cmd, this.definitions.command.aggregateId));
    }

    debug('no aggregateId in command, so generate a new one');

    this.getNewAggregateId(cmd, function (err, id) {
      if (err) {
        debug(err);
        return callback(err);
      }

      return _handle(id);
    });
  }
1160633
def _handle_unknown_command(self):
        
        while self.query_socket.getsockopt(zmq.RCVMORE):
            # Making sure we 'empty' enveloped message. Otherwise, we can't
            # respond.
            self.query_socket.recv()
        self.query_socket.send(b"ERROR Unknown request type")
1032774
def process_command_response(self, command, response):
        
        if response.startswith(b"Unknown command."):
            raise UnknownCommandError(command)
        if response == b"Permission denied.\n":
            raise PermissionError(command)
        if response == b"No such backend.\n":
            raise UnknownServerError(command)

        response = response.decode()
        return response.rstrip("\n")
1176872
def call(command, silent=False):
    
    try:
        if silent:
            with open(os.devnull, 'w')  as FNULL:
                return subprocess.check_call(command_to_array(command), stdout=FNULL)
        else:
            # Using the defaults, shell=False, no i/o redirection.
            return check_call(command_to_array(command))
    except CalledProcessError as e:
        # We are modifying the error itself for 2 reasons.  1) it WILL contain
        # login credentials when run_mongodump is run, 2) CalledProcessError is
        # slightly not-to-spec (the message variable is blank), which means
        # cronutils.ErrorHandler would report unlabeled stack traces.
        e.message = "%s failed with error code %s" % (e.cmd[0], e.returncode)
        e.cmd = e.cmd[0] + " [arguments stripped for security]"
        raise e
638967
def handle_set_command(self, line: str, position: int, tokens: ParseResults) -> ParseResults:
        """"""
        key, value = tokens['key'], tokens['value']
        self.raise_for_invalid_annotation_value(line, position, key, value)
        self.annotations[key] = value
        return tokens
1045234
def eval_command(self, cmd):
        
        if cmd == 'restart':
            self.restart()

        elif cmd == 'stop':
            self.stop()

        else:
            raise ValueError("Unknown Command passed to controller! %s" % cmd)
520394
def _fail_with_undefined_error(self, *args, **kwargs):
        
        if self._undefined_hint is None:
            if self._undefined_obj is missing:
                hint = '%r is undefined' % self._undefined_name
            elif not isinstance(self._undefined_name, basestring):
                hint = '%s has no element %r' % (
                    object_type_repr(self._undefined_obj),
                    self._undefined_name
                )
            else:
                hint = '%r has no attribute %r' % (
                    object_type_repr(self._undefined_obj),
                    self._undefined_name
                )
        else:
            hint = self._undefined_hint
        raise self._undefined_exception(hint)
899785
def run(self, command, opts):
        """"""
        handlers = { 
            'create': self.create,
            'delete': self.delete,
            'list': self.list
        }
        handler = handlers.get(command, None)
        if handler is None:
            error("Unrecognized command: %s" % command, 2)
        handler(opts)
993183
def call_command(self, name, *arguments, **options):
        
        command, defaults = get_command_and_defaults(
            name,
            exclude_packages=self.get_exclude_packages(),
            exclude_command_class=self.__class__)
        if command is None:
            raise management.CommandError(
                "Unknown command: {name:s}".format(
                    name=name))
        defaults.update(options)
        return command.execute(*arguments, **defaults)
925159
def _interpret_oserror(exc, cwd, cmd):
    
    if len(cmd) == 0:
        raise dbt.exceptions.CommandError(cwd, cmd)

    # all of these functions raise unconditionally
    if os.name == 'nt':
        _handle_windows_error(exc, cwd, cmd)
    else:
        _handle_posix_error(exc, cwd, cmd)

    # this should not be reachable, raise _something_ at least!
    raise dbt.exceptions.InternalException(
        'Unhandled exception in _interpret_oserror: {}'.format(exc)
    )
572263
def _handle_command(self, connection, sender, target, command, payload):
        
        try:
            # Find the handler
            handler = getattr(self, "cmd_{0}".format(command))
        except AttributeError:
            self.safe_send(connection, target, "Unknown command: %s",
                            command)
        else:
            try:
                logging.info("! Handling command: %s", command)
                handler(connection, sender, target, payload)
            except Exception as ex:
                logging.exception("Error calling command handler: %s", ex)