Ship commands to the daemon
        Arguments:
            commands: e.g., '?WATCH={{'enable':true,'json':true}}'|'?VERSION;'|'?DEVICES;'|'?DEVICE;'|'?POLL;'
551540
def send(self, commands):
        
        try:
            self.streamSock.send(bytes(commands, encoding='utf-8'))
        except TypeError:
            self.streamSock.send(commands)  # 2.7 chokes on 'bytes' and 'encoding='
        except (OSError, IOError) as error:  # HEY MOE, LEAVE THIS ALONE FOR NOW!
            sys.stderr.write(f'\nAGPS3 send command fail with {error}\n')
1328281
def _cmd(self, command, data=None, params=None, api_version=1):
    
    return self._post("commands/" + command, ApiCommand,
        data=data, params=params, api_version=api_version)
826243
def edit_command(self, payload):
        """"""
        key = payload['key']
        command = payload['command']
        if self.queue[key]:
            if self.queue[key]['status'] in ['queued', 'stashed']:
                self.queue[key]['command'] = command
                answer = {'message': 'Command updated', 'status': 'error'}
            else:
                answer = {'message': "Entry is not 'queued' or 'stashed'",
                          'status': 'error'}
        else:
            answer = {'message': 'No entry with this key', 'status': 'error'}

        # Pause all processes and the daemon
        return answer
1331428
def run_command(self, cmd, history=True, new_prompt=True):
        """"""
        if not cmd:
            cmd = ''
        else:
            if history:
                self.add_to_history(cmd)
        if not self.multithreaded:
            if 'input' not in cmd:
                self.interpreter.stdin_write.write(
                                                to_binary_string(cmd + '\n'))
                self.interpreter.run_line()
                self.refresh.emit()
            else:
                self.write(_('In order to use commands like "raw_input" '
                             'or "input" run Spyder with the multithread '
                             'option (--multithread) from a system terminal'),
                           error=True)
        else:
            self.interpreter.stdin_write.write(to_binary_string(cmd + '\n'))
1331895
def get_commands(mod):
    
    import inspect
    import types

    commands = {}

    def check(c):
        return (inspect.isclass(c) and
            issubclass(c, Command) and c is not Command and not issubclass(c, CommandManager))

    for name in dir(mod):
        c = getattr(mod, name)
        if check(c):
            commands[c.name] = c

    return commands
305987
def command(self, command, value=1, check=True, allowable_errors=None,
                codec_options=DEFAULT_CODEC_OPTIONS, _deadline=None, **kwargs):
        """"""
        if isinstance(command, (bytes, unicode)):
            command = SON([(command, value)])
        options = kwargs.copy()
        command.update(options)

        def on_ok(response):
            if check:
                msg = "TxMongo: command {0} on namespace {1} failed with '%s'".format(repr(command), ns)
                _check_command_response(response, msg, allowable_errors)

            return response

        ns = self["$cmd"].with_options(codec_options=codec_options)
        return ns.find_one(command, _deadline=_deadline).addCallback(on_ok)
129226
def activate_watch(self, watch_id, params=None):
        
        if watch_id in SKIP_IN_PATH:
            raise ValueError("Empty value passed for a required argument 'watch_id'.")
        return self.transport.perform_request(
            "PUT", _make_path("_watcher", "watch", watch_id, "_activate"), params=params
        )
1306117
def dispatch_command(self, command, params=None):
        """"""
        try:
            if command in self.handlers:
                self.handlers[command](**params)
            else:
                logging.warning('Unsupported command: %s: %s',
                                command, params)
        except Exception as e:
            logging.warning('Error during command execution',
                            exc_info=sys.exc_info())
            raise e
1234491
def command(self, command, arg=None):
        
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

        try:
            sock.connect((self.host, self.port))
            payload = {"command": command}
            if arg is not None:
                # Parameter must be converted to basestring (no int)
                payload.update({'parameter': unicode(arg)})

            sock.send(json.dumps(payload))
            received = self._receive(sock)
        finally:
            sock.shutdown(socket.SHUT_RDWR)
            sock.close()

        return json.loads(received[:-1])
453996
def submit_commands(self, devices, execution):
        
        fs = []
        for device in devices:
            if device[key_id_] != self.device_id:
                logging.warning('Ignoring command for unknown device: %s'
                                % device[key_id_])
                continue
            if not execution:
                logging.warning('Ignoring noop execution')
                continue
            for command in execution:
                f = self.executor.submit(
                    self.dispatch_command, **command
                )
                fs.append(f)
        return fs
319841
def dispatch(argdict):
    ''''''
    cmd = argdict['command']
    ftc = getattr(THIS_MODULE, 'do_'+cmd)
    ftc(argdict)
1026383
def send_command(self, command, args=None):
        
        if args:
            if isinstance(args, str):
                final_command = command + ' ' + args + '\x04'
            else:
                # We just let ujson propogate the error here if it can't parse the arguments
                final_command = command + ' ' + ujson.dumps(args) + '\x04'
        else:
            final_command = command + '\x04'
        self.sslwrap.sendall(final_command.encode('utf-8'))
        return self._recv_data()
321211
def commands(self, event):
        
        commands = sorted(self.commands_dict().keys())
        return "Available commands: %s" % " ".join(commands)
922133
def _command(self, sock_info, command, slave_ok=False, value=1, check=True,
                 allowable_errors=None, read_preference=ReadPreference.PRIMARY,
                 codec_options=DEFAULT_CODEC_OPTIONS,
                 write_concern=None,
                 parse_write_concern_error=False, session=None, **kwargs):
        """"""
        if isinstance(command, string_type):
            command = SON([(command, value)])

        command.update(kwargs)
        with self.__client._tmp_session(session) as s:
            return sock_info.command(
                self.__name,
                command,
                slave_ok,
                read_preference,
                codec_options,
                check,
                allowable_errors,
                write_concern=write_concern,
                parse_write_concern_error=parse_write_concern_error,
                session=s,
                client=self.__client)
834598
def _cmd(binary, *args):
    '''
    
    '''
    binary = salt.utils.path.which(binary)
    if not binary:
        raise CommandNotFoundError('{0}: command not found'.format(binary))
    cmd = [binary] + list(args)
    return __salt__['cmd.run_stdout']([binary] + list(args),
                                      python_shell=False)
471395
def command(self, server_id, command, *args):
        
        server = self._storage[server_id]
        try:
            if args:
                result = getattr(server, command)(*args)
            else:
                result = getattr(server, command)()
        except AttributeError:
            raise ValueError("Cannot issue the command %r to server %s"
                             % (command, server_id))
        self._storage[server_id] = server
        return result
555331
def run_commands(self, commands):
        """"""
        if "eos" in self.profile:
            return list(self.parent.cli(commands).values())[0]
        else:
            raise AttributeError("MockedDriver instance has not attribute '_rpc'")