def __generate_event_lookup_table__(self, services): lookup_table = dict() for service in services: events = service.get("events") for event in events: lookup_table.update({event: service.get("target")}) return lookup_table
def __init__(self, freeswitch_host, event_list, services, rules=[], app_config=None): self.__logger__ = logging.getLogger("freepy.lib.server.FreepyOverlord") for rule in rules: if not self.__validate_rule__(rule): self.__logger__.critical("The rule %s is invalid.", str(rule)) raise Exception("The rule {} is invalid.".format(str(rule))) dispatcher = Dispatcher.start(event_list=event_list, dispatch_rules=rules, freeswitch_host=freeswitch_host) app_factory = self.__load_apps_factory__(rules, dispatcher, app_config) for service in services: app_factory.register(service.get("target"), type="singleton") events = self.__generate_event_lookup_table__(services) self.factory = EventSocketClientFactory(DispatcherProxy(app_factory, dispatcher, events))