kitty.remote.rpc module

RPC implementation, based on jsonrpc https://json-rpc.readthedocs.io/

class kitty.remote.rpc.RpcClient(host, port)[source]

Bases: object

__init__(host, port)[source]
Parameters:url – URL of the RPC server
get_unique_msg_id()[source]
Returns:a unique message id
stop_remote_server()[source]

Stop the remote server (after responding to this message)

class kitty.remote.rpc.RpcHandler(request, client_address, server)[source]

Bases: BaseHTTPServer.BaseHTTPRequestHandler

do_POST()[source]

Handle POST requests

error_response(code, msg)[source]

Send an error response

Parameters:
  • code – error code
  • msg – error message
log_message(fmt, *args)[source]

Override default log and do nothing

send_result(additional_dict)[source]

Send a result to the RPC client

Parameters:additional_dict – the dictionary with the response
valid_response(result)[source]

Send a valid response with the result

Parameters:result – the result of the call
class kitty.remote.rpc.RpcHttpServer(server_address, handler, impl, meta)[source]

Bases: BaseHTTPServer.HTTPServer

__init__(server_address, handler, impl, meta)[source]
Parameters:
  • server_address – address of the server
  • handler – handler for requests
  • impl – reference to the implementation object
log_message(fmt, *args)[source]

Override default log and do nothing

class kitty.remote.rpc.RpcServer(host, port, impl)[source]

Bases: object

__init__(host, port, impl)[source]
Parameters:
  • host – listening address
  • port – listening port
  • impl – implementation class
is_running()[source]

Check if the server is currently running

Returns:whether the server is currently running
start()[source]

Serving loop

stop_server()[source]

Mark the server state to be stopped. No further action needed when called from remote RPC client (stop_remote_server), but requires another request if called directly

kitty.remote.rpc.decode_data(data)[source]

Decode data - list, dict, string, bool or int (and nested)

Parameters:
  • data – data to decode
  • encoding – encoding to use (default: ‘hex’)
Returns:

decoded object of the same type

kitty.remote.rpc.decode_string(data, encoding='hex')[source]

Decode string

Parameters:
  • data – string to decode
  • encoding – encoding to use (default: ‘hex’)
Returns:

decoded string

kitty.remote.rpc.encode_data(data)[source]

Encode data - list, dict, string, bool or int (and nested)

Parameters:
  • data – data to encode
  • encoding – encoding to use (default: ‘hex’)
Returns:

encoded object of the same type

kitty.remote.rpc.encode_string(data, encoding='hex')[source]

Encode string

Parameters:
  • data – string to encode
  • encoding – encoding to use (default: ‘hex’)
Returns:

encoded string