|
|
|
|
@ -2671,7 +2671,7 @@ if __name__ == '__main__':
|
|
|
|
|
# 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='CONFIG_FILE', help='/full/path/to/config.file (usually hblink.cfg)')
|
|
|
|
|
parser.add_argument('-r', '--rules', action='store', dest='RULES_FILE', help='/full/path/to/rules.file (usually rules.py)')
|
|
|
|
|
#parser.add_argument('-r', '--rules', action='store', dest='RULES_FILE', help='/full/path/to/rules.file (usually rules.py)')
|
|
|
|
|
parser.add_argument('-l', '--logging', action='store', dest='LOG_LEVEL', help='Override config file logging level.')
|
|
|
|
|
cli_args = parser.parse_args()
|
|
|
|
|
|
|
|
|
|
@ -2698,8 +2698,8 @@ if __name__ == '__main__':
|
|
|
|
|
CONFIG = config.build_config(cli_args.CONFIG_FILE)
|
|
|
|
|
|
|
|
|
|
# Ensure we have a path for the rules file, if one wasn't specified, then use the default (top of file)
|
|
|
|
|
if not cli_args.RULES_FILE:
|
|
|
|
|
cli_args.RULES_FILE = os.path.dirname(os.path.abspath(__file__))+'/rules.py'
|
|
|
|
|
#if not cli_args.RULES_FILE:
|
|
|
|
|
# cli_args.RULES_FILE = os.path.dirname(os.path.abspath(__file__))+'/rules.py'
|
|
|
|
|
|
|
|
|
|
# Start the system logger
|
|
|
|
|
if cli_args.LOG_LEVEL:
|
|
|
|
|
@ -2745,13 +2745,13 @@ if __name__ == '__main__':
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Import the ruiles file as a module, and create BRIDGES from it
|
|
|
|
|
spec = importlib.util.spec_from_file_location("module.name", cli_args.RULES_FILE)
|
|
|
|
|
rules_module = importlib.util.module_from_spec(spec)
|
|
|
|
|
try:
|
|
|
|
|
spec.loader.exec_module(rules_module)
|
|
|
|
|
logger.info('(ROUTER) Routing bridges file found and bridges imported: %s', cli_args.RULES_FILE)
|
|
|
|
|
except (ImportError, FileNotFoundError):
|
|
|
|
|
sys.exit('(ROUTER) TERMINATING: Routing bridges file not found or invalid: {}'.format(cli_args.RULES_FILE))
|
|
|
|
|
#spec = importlib.util.spec_from_file_location("module.name", cli_args.RULES_FILE)
|
|
|
|
|
#rules_module = importlib.util.module_from_spec(spec)
|
|
|
|
|
#try:
|
|
|
|
|
# spec.loader.exec_module(rules_module)
|
|
|
|
|
# logger.info('(ROUTER) Routing bridges file found and bridges imported: %s', cli_args.RULES_FILE)
|
|
|
|
|
#except (ImportError, FileNotFoundError):
|
|
|
|
|
#sys.exit('(ROUTER) TERMINATING: Routing bridges file not found or invalid: {}'.format(cli_args.RULES_FILE))
|
|
|
|
|
|
|
|
|
|
#Load pickle of bridges if it's less than 25 seconds old
|
|
|
|
|
#if os.path.isfile('bridge.pkl'):
|
|
|
|
|
@ -2768,7 +2768,10 @@ if __name__ == '__main__':
|
|
|
|
|
#os.unlink("bridge.pkl")
|
|
|
|
|
#else:
|
|
|
|
|
|
|
|
|
|
BRIDGES = make_bridges(rules_module.BRIDGES)
|
|
|
|
|
BRIDGES = make_bridges({'9990': [{'SYSTEM': 'ECHO', 'TS': 2, 'TGID': 9990, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'NONE', 'ON': [], 'OFF': [], 'RESET': []},]}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#Subscriber map for unit calls - complete with test entry
|
|
|
|
|
|