Esempio n. 1
0
 def get_channel(self, channel_name):
     # TODO: Change to reader-writer lock.
     with self.channel_map_lock:
         try:
             return self.channel_map[channel_name]
         except KeyError:
             raise ObjectNotFound(channel_name)
Esempio n. 2
0
 def unregister_plugin(self, url):
     with self.apps_lock:
         try:
             app = self.apps_by_url.pop(url)
             self.apps_by_token.pop(app.app_token)
         except KeyError:
             raise ObjectNotFound(url)
Esempio n. 3
0
 def remove_channel(self, channel_name):
     with self.channel_map_lock:
         try:
             channel = self.channel_map.pop(channel_name)
         except KeyError:
             raise ObjectNotFound(channel_name)
     channel.disconnect()
     return True
Esempio n. 4
0
    def get_app_info(self, app_token):
        with self.apps_lock:
            try:
                app = self.apps_by_token[app_token]
            except KeyError:
                raise ObjectNotFound(app_token)

        return {
            "app_name": app.name,
            "app_type": "plugin" if isinstance(app, Plugin) else "system",
            "app_url": app.url,
        }
Esempio n. 5
0
    def update_channel_schema(self, channel_name, request_schema,
                              response_schema):
        with self.channel_map_lock:
            try:
                channel_info = self.channel_map[channel_name].channel_info
            except KeyError:
                raise ObjectNotFound(channel_name)

        # TODO: This might need to be protected by a lock.
        channel_info.request_schema = request_schema
        channel_info.response_schema = response_schema
        logger.info(channel_info.request_schema)
        return True
Esempio n. 6
0
def get_plugin_by_id(plugin_id):
    try:
        return PluginData.get(PluginData.app_id == plugin_id)
    except DoesNotExist:
        raise ObjectNotFound(plugin_id)
Esempio n. 7
0
 def get_plugin_by_url(self, plugin_url):
     plugin_id = url_to_plugin_id(plugin_url)
     try:
         return self.plugin_states[plugin_id]
     except KeyError:
         raise ObjectNotFound(plugin_id)
Esempio n. 8
0
 def get_app_by_url(self, url):
     with self.apps_lock:
         try:
             return self.apps_by_url[url]
         except KeyError:
             raise ObjectNotFound(url)
Esempio n. 9
0
 def find_rpc(self, url, name):
     try:
         return self.rpc_registry[(url, name)]
     except KeyError:
         raise ObjectNotFound("RPC not found: " + rpc_name)
Esempio n. 10
0
 def exception(self):
     raise ObjectNotFound("blah")