parser = argparse.ArgumentParser() parser.add_argument('-c', '--config', action='store', dest='CONFIG_FILE', help='/full/path/to/config.file (usually hblink.cfg)') parser.add_argument('-l', '--logging', action='store', dest='LOG_LEVEL', help='Override config file logging level.') cli_args = parser.parse_args() # Ensure we have a path for the config file, if one wasn't specified, then use the execution directory if not cli_args.CONFIG_FILE: cli_args.CONFIG_FILE = os.path.dirname(os.path.abspath(__file__))+'/hblink.cfg' # Call the external routine to build the configuration dictionary CONFIG = hb_config.build_config(cli_args.CONFIG_FILE) # Call the external routing to start the system logger if cli_args.LOG_LEVEL: CONFIG['LOGGER']['LOG_LEVEL'] = cli_args.LOG_LEVEL logger = hb_log.config_logging(CONFIG['LOGGER']) logger.debug('Logging system started, anything from here on gets logged') # Set up the signal handler def sig_handler(_signal, _frame): logger.info('SHUTDOWN: HBLINK IS TERMINATING WITH SIGNAL %s', str(_signal)) hblink_handler(_signal, _frame, logger) logger.info('SHUTDOWN: ALL SYSTEM HANDLERS EXECUTED - STOPPING REACTOR') reactor.stop() # Set signal handers so that we can gracefully exit if need be for sig in [signal.SIGTERM, signal.SIGINT]: signal.signal(sig, sig_handler) # HBlink instance creation logger.info('HBlink \'HBlink.py\' (c) 2016 N0MJS & the K0USY Group - SYSTEM STARTING...')
parser.add_argument('-l', '--logging', action='store', dest='LOG_LEVEL', help='Override config file logging level.') cli_args = parser.parse_args() # Ensure we have a path for the config file, if one wasn't specified, then use the execution directory if not cli_args.CONFIG_FILE: cli_args.CONFIG_FILE = os.path.dirname(os.path.abspath(__file__))+'/hblink.cfg' # Call the external routine to build the configuration dictionary CONFIG = hb_config.build_config(cli_args.CONFIG_FILE) # Call the external routing to start the system logger if cli_args.LOG_LEVEL: CONFIG['LOGGER']['LOG_LEVEL'] = cli_args.LOG_LEVEL logger = hb_log.config_logging(CONFIG['LOGGER']) logger.debug('Logging system started, anything from here on gets logged') # Shut ourselves down gracefully by disconnecting from the masters and clients. def handler(_signal, _frame): logger.info('*** HBLINK IS TERMINATING WITH SIGNAL %s ***', str(_signal)) for client in clients: this_client = clients[client] this_client.send_packet('RPTCL'+CONFIG['CLIENTS'][client]['RADIO_ID']) logger.info('(%s) De-Registering From the Master', client) for master in masters: this_master = masters[master] for client in CONFIG['MASTERS'][master]['CLIENTS']: