コード例 #1
0
ファイル: __init__.py プロジェクト: koirikivi/sauerkraut
    def __init__(self, service, serializer, method_names):
        self._service = service
        self._serializer = serializer
        self._dispatcher = jsonrpc.Dispatcher()
        for method_name in method_names:
            wrapped_method = getattr(self._service, method_name)

            def wrapper(*args, **kwargs):
                # TODO: the deserialization is a bit silly
                deserialized_args = self._serializer.deserialize(
                    method_name, args)
                deserialized_kwargs = self._serializer.deserialize(
                    method_name, kwargs)
                result = wrapped_method(*deserialized_args,
                                        **deserialized_kwargs)
                return self._serializer.serialize(method_name, result)

            update_wrapper(wrapper, wrapped_method)
            self._dispatcher[method_name] = wrapper

        @Request.application
        def application(request):
            response = jsonrpc.JSONRPCResponseManager.handle(
                request.data, self._dispatcher)
            return Response(response.json, mimetype='application/json')

        self._application = application
コード例 #2
0
    def __init__(self, child_process):
        self.child_process = child_process
        self.command_arg_parser = _ArgumentParser(
            description='Execute an RPC method on the child')
        self.command_arg_parser.add_argument('method')
        self.command_arg_parser.add_argument('--id', '-i', dest='json_rpc_id')
        self.command_arg_parser.add_argument('--params', '-p', dest='params')
        self._started_event = threading.Event()
        self._stopped_event = threading.Event()
        self.dispatcher = jsonrpc.Dispatcher()
        self.dispatcher["stop"] = self._respond_immediately_for_stop
        self.dispatcher["wait_for_start"] = self._wait_for_start

        self.stdin = sys.stdin
        sys.stdin = open(os.devnull, 'r')

        self.stdout = sys.stdout
        sys.stdout = open(os.devnull, 'w')

        self._stdout_lock = threading.RLock()
        self._sys_in_thread = threading.Thread(
            target=self._sys_in_thread_target,
            name="pf_%s_stdin" % repr(child_process))
        self._sys_in_thread.daemon = True
        self._should_stop = False
コード例 #3
0
ファイル: peer.py プロジェクト: amhankin/wand
    def __init__(self, *args, **kwargs):
        # JSON configuration initialisation
        super().__init__(*args, **kwargs)
        self.set_up_logger()

        self.connections = {}

        self.dsp = jsonrpc.Dispatcher()
        self.add_rpc_methods()

        self.next_id = 0
        self.results = {}
コード例 #4
0
ファイル: server.py プロジェクト: Globalync/platformio-core
 def __init__(self, shutdown_timeout=0):
     super(JSONRPCServerFactory, self).__init__()
     self.shutdown_timeout = shutdown_timeout
     self.dispatcher = jsonrpc.Dispatcher()
コード例 #5
0
 def __init__(self):
     super(JSONRPCServerFactory, self).__init__()
     self.dispatcher = jsonrpc.Dispatcher()
コード例 #6
0
 def __init__(self, shutdown_timeout=0):
     self.shutdown_timeout = shutdown_timeout
     self.dispatcher = jsonrpc.Dispatcher()