def initialisation(self): """ Charge la configuration à partir d'un fichier ini indiquant les chemins des fichiers contenant : - géométries de la région sur laquelle s'applique le moteur - la socket pour chaque identifiant navitia """ self.instances = {} self.context = zmq.Context() self.default_socket = None for file_name in self.ini_files: logging.info("Initialisation, reading file : " + file_name) conf = ConfigParser.ConfigParser() conf.read(file_name) instance = Instance(self.context, conf.get('instance', 'key')) instance.socket_path = conf.get('instance', 'socket') self.instances[conf.get('instance', 'key')] = instance #we fetch the krakens metadata first # not on the ping thread to always have the data available (for the tests for example) self.init_kraken_instances() self.thread_event = Event() self.thread = Thread(target=self.thread_ping) #daemon thread does'nt block the exit of a process self.thread.daemon = True if self.start_ping: self.thread.start()
def initialisation(self, start_ping=True): """ Charge la configuration à partir d'un fichier ini indiquant les chemins des fichiers contenant : - géométries de la région sur laquelle s'applique le moteur - la socket pour chaque identifiant navitia """ self.instances = {} self.context = zmq.Context() self.default_socket = None # if a .ini file is defined in the settings we take it # else we load all .ini file found in the INSTANCES_DIR if 'INI_FILES' in app.config: ini_files = app.config['INI_FILES'] else: ini_files = glob.glob(app.config['INSTANCES_DIR'] + '/*.ini') for file_name in ini_files: logging.info("Initialisation, reading file : " + file_name) conf = ConfigParser.ConfigParser() conf.read(file_name) instance = Instance(self.context, conf.get('instance', 'key')) instance.socket_path = conf.get('instance', 'socket') if conf.has_option('instance', 'script'): module = import_module(conf.get('instance', 'script')) instance.script = module.Script() else: module = import_module("jormungandr.scripts.default") instance.script = module.Script() # we give all functional parameters to the script if conf.has_section('functional'): functional_params = dict(conf.items('functional')) instance.script.functional_params = functional_params self.instances[conf.get('instance', 'key')] = instance self.thread_event = Event() self.thread = Thread(target=self.thread_ping) #daemon thread does'nt block the exit of a process self.thread.daemon = True if start_ping: self.thread.start()
def initialisation(self): """ Charge la configuration à partir d'un fichier ini indiquant les chemins des fichiers contenant : - géométries de la région sur laquelle s'applique le moteur - la socket pour chaque identifiant navitia """ self.instances = {} self.context = zmq.Context() self.default_socket = None for file_name in self.configuration_files: logging.getLogger(__name__).info( "Initialisation, reading file : " + file_name) if file_name.endswith('.ini'): # Note: the ini configuration file is kept only temporarily, to migration all the # production configuration slowly conf = configparser.ConfigParser() conf.read(file_name) instance = Instance(self.context, conf.get('instance', 'key'), conf.get('instance', 'socket')) elif file_name.endswith('.json'): with open(file_name) as f: config_data = json.load(f) name = config_data['key'] instance = Instance( self.context, name, config_data['zmq_socket'], config_data.get('realtime_proxies', [])) else: logging.getLogger(__name__).warn( 'impossible to init an instance with the configuration ' 'file {}'.format(file_name)) continue self.instances[instance.name] = instance #we fetch the krakens metadata first # not on the ping thread to always have the data available (for the tests for example) self.init_kraken_instances() self.thread_event = Event() self.thread = Thread(target=self.thread_ping) #daemon thread does'nt block the exit of a process self.thread.daemon = True if self.start_ping: self.thread.start()
def register_instance(self, config): logging.getLogger(__name__).debug("instance configuration: %s", config) name = config['key'] instance = Instance(self.context, name, config['zmq_socket'], config.get('street_network'), config.get('realtime_proxies', []), config.get('zmq_socket_type', 'persistent'), config.get('default_autocomplete', 'kraken')) self.instances[instance.name] = instance
def register_instance(self, config): logging.getLogger(__name__).debug("instance configuration: %s", config) name = config['key'] instance = Instance( self.context, name, config['zmq_socket'], config.get('street_network'), config.get('ridesharing'), config.get('realtime_proxies', []), config.get('zmq_socket_type', app.config.get('ZMQ_DEFAULT_SOCKET_TYPE', 'persistent')), config.get('default_autocomplete', None), config.get('equipment_details_providers', []), ) self.instances[instance.name] = instance