コード例 #1
0
ファイル: client.py プロジェクト: 602p/krpc
    def __init__(self, rpc_connection, stream_connection):
        self._types = Types()
        self._rpc_connection = rpc_connection
        self._rpc_connection_lock = threading.Lock()
        self._stream_connection = stream_connection
        self._request_type = self._types.as_type("KRPC.Request")
        self._response_type = self._types.as_type("KRPC.Response")

        # Set up the main KRPC service
        self.krpc = KRPC(self)

        services = self.krpc.get_services().services

        # Create class types
        # TODO: is this needed?!?
        for service in services:
            for procedure in service.procedures:
                try:
                    name = Attributes.get_class_name(procedure.attributes)
                    self._types.as_type("Class(" + service.name + "." + name + ")")
                except ValueError:
                    pass

        # Set up services
        for service in services:
            if service.name != "KRPC":
                setattr(self, _to_snake_case(service.name), create_service(self, service))

        # Set up stream update thread
        if stream_connection is not None:
            self._stream_thread = threading.Thread(target=krpc.stream.update_thread, args=(stream_connection,))
            self._stream_thread.daemon = True
            self._stream_thread.start()
        else:
            self._stream_thread = None
コード例 #2
0
ファイル: client.py プロジェクト: mkalte666/krpc
    def __init__(self, rpc_connection, stream_connection):
        self._types = Types()
        self._rpc_connection = rpc_connection
        self._rpc_connection_lock = threading.Lock()
        self._stream_connection = stream_connection
        self._stream_manager = StreamManager(self)

        # Get the services
        services = self._invoke('KRPC', 'GetServices', [], [], [],
                                self._types.services_type).services

        # Set up services
        for service in services:
            setattr(self, snake_case(service.name),
                    create_service(self, service))

        # Set up stream update thread
        if stream_connection is not None:
            self._stream_thread_stop = threading.Event()
            self._stream_thread = threading.Thread(
                target=krpc.streammanager.update_thread,
                args=(self._stream_manager, stream_connection,
                      self._stream_thread_stop))
            self._stream_thread.daemon = True
            self._stream_thread.start()
        else:
            self._stream_thread = None
コード例 #3
0
    def __init__(self, rpc_connection, stream_connection):
        self._types = Types()
        self._rpc_connection = rpc_connection
        self._rpc_connection_lock = threading.Lock()
        self._stream_connection = stream_connection
        self._stream_cache = {}
        self._stream_cache_lock = threading.Lock()
        self._request_type = self._types.as_type('KRPC.Request')
        self._response_type = self._types.as_type('KRPC.Response')

        # Get the services
        services = self._invoke('KRPC', 'GetServices', [], [], [],
                                self._types.as_type('KRPC.Services')).services

        # Set up services
        for service in services:
            setattr(self, snake_case(service.name),
                    create_service(self, service))

        # Set up stream update thread
        if stream_connection is not None:
            self._stream_thread_stop = threading.Event()
            self._stream_thread = threading.Thread(
                target=krpc.stream.update_thread,
                args=(stream_connection, self._stream_thread_stop,
                      self._stream_cache, self._stream_cache_lock))
            self._stream_thread.daemon = True
            self._stream_thread.start()
        else:
            self._stream_thread = None
コード例 #4
0
ファイル: client.py プロジェクト: chippydip/krpc
    def __init__(self, rpc_connection, stream_connection):
        self._types = Types()
        self._rpc_connection = rpc_connection
        self._rpc_connection_lock = threading.Lock()
        self._stream_connection = stream_connection
        self._stream_cache = {}
        self._stream_cache_lock = threading.Lock()
        self._request_type = self._types.as_type('KRPC.Request')
        self._response_type = self._types.as_type('KRPC.Response')

        # Get the services
        services = self._invoke('KRPC', 'GetServices', [], [], [], self._types.as_type('KRPC.Services')).services

        # Set up services
        for service in services:
            setattr(self, snake_case(service.name), create_service(self, service))

        # Set up stream update thread
        if stream_connection is not None:
            self._stream_thread_stop = threading.Event()
            self._stream_thread = threading.Thread(target=krpc.stream.update_thread,
                                                   args=(stream_connection, self._stream_thread_stop,
                                                         self._stream_cache, self._stream_cache_lock))
            self._stream_thread.daemon = True
            self._stream_thread.start()
        else:
            self._stream_thread = None
コード例 #5
0
    def __init__(self, rpc_connection, stream_connection):
        self._types = Types()
        self._rpc_connection = rpc_connection
        self._rpc_connection_lock = threading.Lock()
        self._stream_connection = stream_connection
        self._request_type = self._types.as_type('KRPC.Request')
        self._response_type = self._types.as_type('KRPC.Response')

        # Set up the main KRPC service
        self.krpc = KRPC(self)

        services = self.krpc.get_services().services

        # Create class types
        #TODO: is this needed?!?
        #for service in services:
        #    for procedure in service.procedures:
        #        try:
        #            name = Attributes.get_class_name(procedure.attributes)
        #            self._types.as_type('Class(' + service.name + '.' + name + ')')
        #        except ValueError:
        #            pass

        # Set up services
        for service in services:
            if service.name != 'KRPC':
                setattr(self, _to_snake_case(service.name),
                        create_service(self, service))

        # Set up stream update thread
        if stream_connection is not None:
            self._stream_thread_stop = threading.Event()
            self._stream_thread = threading.Thread(
                target=krpc.stream.update_thread,
                args=(stream_connection, self._stream_thread_stop))
            self._stream_thread.daemon = True
            self._stream_thread.start()
        else:
            self._stream_thread = None
コード例 #6
0
ファイル: client.py プロジェクト: asmigala/krpc
    def __init__(self, rpc_connection, stream_connection):
        self._types = Types()
        self._rpc_connection = rpc_connection
        self._rpc_connection_lock = threading.Lock()
        self._stream_connection = stream_connection
        self._request_type = self._types.as_type('KRPC.Request')
        self._response_type = self._types.as_type('KRPC.Response')

        # Set up the main KRPC service
        self.krpc = KRPC(self)

        services = self.krpc.get_services().services

        # Create class types
        #TODO: is this needed?!?
        #for service in services:
        #    for procedure in service.procedures:
        #        try:
        #            name = Attributes.get_class_name(procedure.attributes)
        #            self._types.as_type('Class(' + service.name + '.' + name + ')')
        #        except ValueError:
        #            pass

        # Set up services
        for service in services:
            if service.name != 'KRPC':
                setattr(self, snake_case(service.name), create_service(self, service))

        # Set up stream update thread
        if stream_connection is not None:
            self._stream_thread_stop = threading.Event()
            self._stream_thread = threading.Thread(target=krpc.stream.update_thread,
                                                   args=(stream_connection,self._stream_thread_stop))
            self._stream_thread.daemon = True
            self._stream_thread.start()
        else:
            self._stream_thread = None