コード例 #1
0
    def run_forever(self) -> None:
        """
        Start the server, publish all provided_service, and run until interrupted.
        Then, unregister all services.
        """

        try:
            self.setup()
            # TODO: These three could go into a provider_setup() method
            if self.secure:
                authorization_response = self.consume_service(CoreServices.PUBLICKEY.service_definition)
                self.auth_authentication_info = responses.process_publickey(authorization_response)
            self._initialize_provided_services()
            self._register_all_services()
            self._initialize_event_subscription()
            self._subscribe_all_events()
            self._logger.info('Starting server')
            print('Started Arrowhead ArrowheadSystem')
            self.provider.run_forever(
                    address=self.system.address,
                    port=self.system.port,
                    # TODO: keyfile and certfile should be given in provider.__init__
                    keyfile=self.keyfile,
                    certfile=self.certfile,
            )
        except KeyboardInterrupt:
            self._logger.info('Shutting down server')
        finally:
            print('Shutting down Arrowhead system')
            self._unregister_all_services()
            self._unsubscribe_all_events()
            self._logger.info('Server shut down')
コード例 #2
0
 async def client_setup(self):
     await self.setup()
     if self.secure:
         authorization_response = await self.consume_service(
             CoreServices.PUBLICKEY.service_definition)
         self.auth_authentication_info = responses.process_publickey(
             authorization_response)
     self._initialize_provided_services()
     await self._register_all_services()
コード例 #3
0
 def test_publickey(self, publickey_response, publickey_true):
     test_publickey = csr.process_publickey(publickey_response)
     assert test_publickey == publickey_true