action='store', dest='CFG_FILE', help='/full/path/to/config.file (usually dmrlink.cfg)') cli_args = parser.parse_args() if not cli_args.CFG_FILE: cli_args.CFG_FILE = os.path.dirname( os.path.abspath(__file__)) + '/dmrlink.cfg' # Call the external routine to build the configuration dictionary CONFIG = dmrlink_config.build_config(cli_args.CFG_FILE) # Call the external routing to start the system logger logger = dmrlink_log.config_logging(CONFIG['LOGGER']) config_reports(CONFIG) logger.info( 'DMRlink \'bridge.py\' (c) 2013-2015 N0MJS & the K0USY Group - SYSTEM STARTING...' ) # Shut ourselves down gracefully with the IPSC peers. def sig_handler(_signal, _frame): logger.info('*** DMRLINK IS TERMINATING WITH SIGNAL %s ***', str(_signal)) for system in systems: this_ipsc = systems[system] logger.info('De-Registering from IPSC %s', system) de_reg_req_pkt = this_ipsc.hashed_packet( this_ipsc._local['AUTH_KEY'], this_ipsc.DE_REG_REQ_PKT)
if cli_args.LOG_HANDLERS: CONFIG['LOGGER']['LOG_HANDLERS'] = cli_args.LOG_HANDLERS logger = config_logging(CONFIG['LOGGER']) logger.info( 'DMRlink \'dmrlink.py\' (c) 2013 - 2015 N0MJS & the K0USY Group - SYSTEM STARTING...' ) # Set signal handers so that we can gracefully exit if need be def sig_handler(_signal, _frame): logger.info('*** DMRLINK IS TERMINATING WITH SIGNAL %s ***', str(_signal)) for system in systems: systems[system].de_register_self() reactor.stop() for sig in [signal.SIGTERM, signal.SIGINT, signal.SIGQUIT]: signal.signal(sig, sig_handler) # INITIALIZE THE REPORTING LOOP report_server = config_reports(CONFIG, logger, reportFactory) # Build ID Aliases peer_ids, subscriber_ids, talkgroup_ids, local_ids = build_aliases( CONFIG, logger) # INITIALIZE AN IPSC OBJECT (SELF SUSTAINING) FOR EACH CONFIGRUED IPSC systems = mk_ipsc_systems(CONFIG, logger, systems, rcmIPSC, report_server) # INITIALIZATION COMPLETE -- START THE REACTOR reactor.run()
if cli_args.LOG_LEVEL: CONFIG['LOGGER']['LOG_LEVEL'] = cli_args.LOG_LEVEL if cli_args.LOG_HANDLERS: CONFIG['LOGGER']['LOG_HANDLERS'] = cli_args.LOG_HANDLERS logger = config_logging(CONFIG['LOGGER']) logger.info('DMRlink \'dmrlink.py\' (c) 2013 - 2015 N0MJS & the K0USY Group - SYSTEM STARTING...') # Set signal handers so that we can gracefully exit if need be def sig_handler(_signal, _frame): logger.info('*** DMRLINK IS TERMINATING WITH SIGNAL %s ***', str(_signal)) for system in systems: systems[system].de_register_self() reactor.stop() for sig in [signal.SIGTERM, signal.SIGINT, signal.SIGQUIT]: signal.signal(sig, sig_handler) # INITIALIZE THE REPORTING LOOP report_server = config_reports(CONFIG, logger, reportFactory) # Build ID Aliases peer_ids, subscriber_ids, talkgroup_ids, local_ids = build_aliases(CONFIG, logger) # INITIALIZE AN IPSC OBJECT (SELF SUSTAINING) FOR EACH CONFIGRUED IPSC systems = mk_ipsc_systems(CONFIG, logger, systems, playbackIPSC, report_server) # INITIALIZATION COMPLETE -- START THE REACTOR reactor.run()
logger.info('*** DMRLINK IS TERMINATING WITH SIGNAL %s ***', str(_signal)) for system in systems: this_ipsc = systems[system] logger.info('De-Registering from IPSC %s', system) de_reg_req_pkt = this_ipsc.hashed_packet( this_ipsc._local['AuthKey'], this_ipsc.DE_REG_REQ_PKT) this_ipsc.send_to_ipsc(de_reg_req_pkt) reactor.stop() # Set signal handers so that we can gracefully exit if need be for sig in [signal.SIGTERM, signal.SIGINT, signal.SIGQUIT]: signal.signal(sig, sig_handler) # setup the reporting loop report_server = config_reports(config, logger, reportFactory) # IPSC instance creation for system in config['Systems']: if config['Systems'][system]['LOCAL']['Enabled']: systems[system] = bridgeIPSC(system, config, cli_args.BridgeFile, logger, report_server) reactor.listenUDP( config['Systems'][system]['LOCAL']['PORT'], systems[system], interface=config['Systems'][system]['LOCAL']['IP']) logger.debug('Instance created: %s, %s', system, systems[system]) reactor.run()
# CLI argument parser - handles picking up the config file from the command line, and sending a "help" message parser = argparse.ArgumentParser() parser.add_argument('-c', '--config', action='store', dest='CFG_FILE', help='/full/path/to/config.file (usually dmrlink.cfg)') cli_args = parser.parse_args() if not cli_args.CFG_FILE: cli_args.CFG_FILE = os.path.dirname(os.path.abspath(__file__))+'/dmrlink.cfg' # Call the external routine to build the configuration dictionary CONFIG = dmrlink_config.build_config(cli_args.CFG_FILE) # Call the external routing to start the system logger logger = dmrlink_log.config_logging(CONFIG['LOGGER']) config_reports(CONFIG) logger.info('DMRlink \'bridge.py\' (c) 2013-2015 N0MJS & the K0USY Group - SYSTEM STARTING...') # Shut ourselves down gracefully with the IPSC peers. def sig_handler(_signal, _frame): logger.info('*** DMRLINK IS TERMINATING WITH SIGNAL %s ***', str(_signal)) for system in systems: this_ipsc = systems[system] logger.info('De-Registering from IPSC %s', system) de_reg_req_pkt = this_ipsc.hashed_packet(this_ipsc._local['AUTH_KEY'], this_ipsc.DE_REG_REQ_PKT) this_ipsc.send_to_ipsc(de_reg_req_pkt) reactor.stop() # Set signal handers so that we can gracefully exit if need be