Request data fromo the server.

        :param cmd: repo handler command.

        :returns: Result.
762226
def request(self, cmd, *args, **kwargs):
        
        params = {'action': cmd}
        #TODO: serialize the kwargs?
        params.update(kwargs)
        return self.__request(self.url, params)
976605
def _exec_request(self, service, method=None, path_args=None, data=None,
                      params=None):
        """"""
        if path_args is None:
            path_args = []

        req = {
            'method': method or 'get',
            'url': '/'.join(str(a).strip('/') for a in [
                cfg.CONF.tvdb.service_url, service] + path_args),
            'data': json.dumps(data) if data else None,
            'headers': self.headers,
            'params': params,
            'verify': cfg.CONF.tvdb.verify_ssl_certs,
        }

        LOG.debug('executing request (%s %s)', req['method'], req['url'])
        resp = self.session.request(**req)

        resp.raise_for_status()
        return resp.json() if resp.text else resp.text
701263
def data_from_query(self, cmd):
        
        res  = None
        ckey = "%s /%s" % (self.command, cmd)

        if not isinstance(self._query_params, dict):
            self._query_params = {}

        if ckey in _NCMD:
            self._cmd = _NCMD[ckey]
        else:
            for key in sorted(_RCMD, key=len, reverse=True):
                if not key.startswith("%s " % self.command):
                    continue

                m = _RCMD[key].name.match(cmd)
                if m:
                    self._cmd = _RCMD[key]
                    self._query_params.update(m.groupdict())
                    break

        try:
            if not self._cmd:
                raise self.req_error(404)

            if not self._cmd.to_log:
                self._to_log = False

            if self._cmd.to_auth:
                self.authenticate(self._cmd.auth_users)

            if self._cmd.static:
                if self._cmd.handler:
                    res = self._cmd.handler(self)

                return self.static_file(cmd, res)

            res = self._cmd.handler(self)

            if not isinstance(res, HttpResponse):
                return self.response_dumps(res)

            return res
        finally:
            self._query_params = {}
1045990
def _create_get_request(self, resource, billomat_id='', command=None, params=None):
        
        if not params:
            params = {}

        if not command:
            command = ''
        else:
            command = '/' + command

        assert (isinstance(resource, str))
        if billomat_id:
            assert (isinstance(billomat_id, int) or isinstance(billomat_id, str))

            if isinstance(billomat_id, int):
                billomat_id = str(billomat_id)
        response = self.session.get(
            url=self.api_url + resource + ('/' + billomat_id if billomat_id else '') + command,
            params=params,
        )

        return self._handle_response(response)
140548
def blocking_request(cmd, timeout)
      raise BlockingError, "Blocking request not allowed on EM main thread for command #{cmd.inspect}" if EM.reactor_thread?
      # Use a queue to block and wait for response
      response_queue = Queue.new
      # Need to execute on EM main thread where command client is running
      EM.next_tick { @client.send_command(cmd, false, timeout) { |response| response_queue << response } }
      return response_queue.shift
    end
297214
def perform(self, cmd, msg='', extra_headers=None):
        """"""
        tries = 0
        while 1:
            conn = None
            try:
                conn = self.get_connection()
                if hasattr(msg, 'read') and hasattr(msg, 'fileno'):
                    msg_length = str(os.fstat(msg.fileno()).st_size)
                elif hasattr(msg, 'read'):
                    msg.seek(0, 2)
                    msg_length = str(msg.tell() + 2)
                else:
                    if msg:
                        try:
                            msg_length = str(len(msg) + 2)
                        except TypeError:
                            conn.close()
                            raise ValueError(
                                'msg param should be a string or file handle')
                    else:
                        msg_length = '2'

                headers = self.get_headers(cmd, msg_length, extra_headers)

                if isinstance(msg, types.StringTypes):
                    if self.gzip and msg:
                        msg = compress(msg + '\r\n', self.compress_level)
                    else:
                        msg = msg + '\r\n'
                    conn.send(headers + msg)
                else:
                    conn.send(headers)
                    if hasattr(msg, 'read'):
                        if hasattr(msg, 'seek'):
                            msg.seek(0)
                        conn.sendfile(msg, self.gzip, self.compress_level)
                conn.send('\r\n')
                try:
                    conn.socket().shutdown(socket.SHUT_WR)
                except socket.error:
                    pass
                return get_response(cmd, conn)
            except socket.gaierror as err:
                if conn is not None:
                    conn.release()
                raise SpamCError(str(err))
            except socket.timeout as err:
                if conn is not None:
                    conn.release()
                raise SpamCTimeOutError(str(err))
            except socket.error as err:
                if conn is not None:
                    conn.close()
                errors = (errno.EAGAIN, errno.EPIPE, errno.EBADF,
                          errno.ECONNRESET)
                if err[0] not in errors or tries >= self.max_tries:
                    raise SpamCError("socket.error: %s" % str(err))
            except BaseException:
                if conn is not None:
                    conn.release()
                raise
            tries += 1
            self.backend_mod.sleep(self.wait_tries)
847257
def request_command_status(blink, network, command_id):
    
    url = "{}/network/{}/command/{}".format(blink.urls.base_url,
                                            network,
                                            command_id)
    return http_get(blink, url)
533884
def send(self, load, tries=None, timeout=None, raw=False):  # pylint: disable=unused-argument
        '''
        
        '''
        if 'cmd' not in load:
            log.error('Malformed request, no cmd: %s', load)
            return {}
        cmd = load['cmd'].lstrip('_')
        if cmd in self.cmd_stub:
            return self.cmd_stub[cmd]
        if not hasattr(self.fs, cmd):
            log.error('Malformed request, invalid cmd: %s', load)
            return {}
        return getattr(self.fs, cmd)(load)
148034
async def send_cmd(self, cmd, loop=None):
        """"""
        _LOGGER.info("Send cmd = %s", cmd)

        if cmd not in COMMANDS and cmd not in range(0, 999):
            _LOGGER.error("Unknown command")
            raise PyMediaroomError("Unknown commands")

        keys = []
        if cmd in range(0, 999):
            for character in str(cmd):
                keys.append(COMMANDS["Number"+str(character)])
            if len(keys) < 3:
                keys.append(COMMANDS["OK"])
            self.current_channel = cmd
        else:
            keys = [COMMANDS[cmd]]

        try:
            async with timeout(OPEN_CONTROL_TIMEOUT, loop=loop):
                async with self.lock:
                    _LOGGER.debug("Connecting to %s:%s", self.stb_ip, REMOTE_CONTROL_PORT)
                    stb_recv, stb_send = await asyncio.open_connection(self.stb_ip,
                                                                       REMOTE_CONTROL_PORT,
                                                                       loop=loop)
                    await stb_recv.read(6)
                    _LOGGER.info("Connected to %s:%s", self.stb_ip, REMOTE_CONTROL_PORT)

                    for key in keys:
                        _LOGGER.debug("%s key=%s", cmd, key)
                        stb_send.write("key={}\n".format(key).encode('UTF-8'))
                        _ = await stb_recv.read(3)
                        await asyncio.sleep(0.300)

        except asyncio.TimeoutError as error:
            _LOGGER.warning(error)
            raise PyMediaroomError("Timeout connecting to {}".format(self.stb_ip))
        except ConnectionRefusedError as error:
            _LOGGER.warning(error)
            raise PyMediaroomError("Connection refused to {}".format(self.stb_ip))
433107
def send_command_return(self, obj, command, *arguments):
        
        return self._perform_command('{}/{}'.format(self.session_url, obj.ref), command, OperReturnType.line_output,
                                     *arguments).json()
664267
def _exec_command(self, cmd):
        
        _, out, err = self._client.exec_command(cmd, timeout=self._timeout)
        return out.read().strip() if not err.read().strip() else None
592755
def command(execute=None):  # noqa: E501
    
    if connexion.request.is_json:
        execute = Execute.from_dict(connexion.request.get_json())  # noqa: E501

    if(not hasAccess()):
        return redirectUnauthorized()

    try:
        connector = None

        parameters = {}

        if (execute.command.parameters):
            parameters = execute.command.parameters

        credentials = Credentials()
        options = Options(debug=execute.command.options['debug'], sensitive=execute.command.options['sensitive'])

        if (execute.auth):
            credentials = mapUserAuthToCredentials(execute.auth, credentials)

        if (not execute.auth.api_token):
            options.sensitive = True

        connector = Connector(options=options, credentials=credentials, command=execute.command.command,
                              parameters=parameters)

        commandHandler = connector.execute()

        response = Response(status=commandHandler.getRequest().getResponseStatusCode(),
                            body=json.loads(commandHandler.getRequest().getResponseBody()))

        if (execute.command.options['debug']):
            response.log = connector.logBuffer

        return response
    except:
        State.log.error(traceback.format_exc())
        if ('debug' in execute.command.options and execute.command.options['debug']):
            return ErrorResponse(status=500,
                                 message="Uncaught exception occured during processing. To get a larger stack trace, visit the logs.",
                                 state=traceback.format_exc(3))
        else:
            return ErrorResponse(status=500, message="")
192319
def command(self, cmd, retries=None, timeout_cmd=None):
        
        retries = retries or self._retries_default
        timeout = timeout_cmd or self._timeout_default

        session = self.get_session(retries)
        url = self.__base_url(cmd)
        for loop in range(1, 2 + retries):
            _LOGGER.debug("Running query attempt %s", loop)
            try:
                resp = session.get(
                    url,
                    auth=self._token,
                    stream=True,
                    timeout=timeout,
                )
                resp.raise_for_status()
                break
            except requests.RequestException as error:
                if loop <= retries:
                    _LOGGER.warning("Trying again due to error %s", error)
                    continue
                else:
                    _LOGGER.error("Query failed due to error %s", error)
                    raise CommError('Could not communicate with camera')

        _LOGGER.debug("Query worked. Exit code: <%s>", resp.status_code)
        return resp
1122364
def sendCommand(self, command):
        
        command_data = [ord(x) for x in buffer(command)]
        self.hid.write(command_data)
        response_data = ''.join(chr(x) for x in self.hid.read(64))
        response = command.RESPONSE.from_buffer_copy(response_data)
        if response.status != 0:
            raise CommandException(response.status)
        return response
943439
def help(self, command=None):
        
        cmd = 'help'
        if command: cmd += ' %s' % command
        return self.fetch(cmd)[1]
397995
def _execCmd(self, cmd, args):
        
        output = self._eslconn.api(cmd, args)
        if output:
            body = output.getBody()
            if body:
                return body.splitlines()
        return None
233574
def fetch(self, command):
        
        logging.debug('SENT: %s: %s' % (self.host, command))
        self.write('%s\n' % command)
        while 1:
            buffer = self.read_until('\n').strip()
            if len(buffer):
                break
        status, length = map(int, buffer.split())
        content = ''
        assert status == 200, 'Bad response code: {status} {text} ({command})'.format(status=status, text=self.read_until('\n').strip(), command=command)
        while len(content) < length:
            content += self.read_until('\n')
        logging.debug('RECV: %s: %dB %s' % (status,length,content[:30]))
        self.read_eager()
        return (status, length), content