(self, method, **params)
return resp['result']
Send a command and wait for the result to be available.
Send a command and wait for the result to be available.
Send a command and wait for the result to be available .
def _send_cmd(self, method, **params):
        ''' Send a command and wait for the result to be available. '''
        id = next(self.req_counter)
        out = {'id': id, 'method': method}
        if params:
            out['params'] = params

        # Receive thread will signal us when the response is available
        event = threading.Event()
        self.requests[id] = event
        self.ws.send(json.dumps(out))
        event.wait()

        resp = self.results.pop(id)
        if 'error' in resp:
            raise Exception("Command %s(%s) failed: %s (%d)" % (
                method, ', '.join('%s=%r' % (k,v) for k,v in params.iteritems()), resp['error']['message'], resp['error']['code']))
        return resp['result']
def _send_cmd ( self , method , * * params ) : id = next ( self . req_counter ) out = { 'id' : id , 'method' : method } if params : out [ 'params' ] = params # Receive thread will signal us when the response is available event = threading . Event ( ) self . requests [ id ] = event self . ws . send ( json . dumps ( out ) ) event . wait ( ) resp = self . results . pop ( id ) if 'error' in resp : raise Exception ( "Command %s(%s) failed: %s (%d)" % ( method , ', ' . join ( '%s=%r' % ( k , v ) for k , v in params . iteritems ( ) ) , resp [ 'error' ] [ 'message' ] , resp [ 'error' ] [ 'code' ] ) ) return resp [ 'result' ]