From d4b51fd08f0daff82d482c8f41f397c18422e79e Mon Sep 17 00:00:00 2001 From: Cort Buffington Date: Sun, 17 May 2015 11:19:19 -0500 Subject: [PATCH] Prepare for Dynamic Rule Changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change the name of the rules read from the file, then copy it to “RULES” after processing. This will allow us to modify RULES on the fly, while keeping the “original” - This is a hook to add dynamic rule changes. --- bridge.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/bridge.py b/bridge.py index 64280b5..89e6ef7 100755 --- a/bridge.py +++ b/bridge.py @@ -64,7 +64,7 @@ TS_CLEAR_TIME = .2 # but it has to exist. # try: - from bridge_rules import RULES + from bridge_rules import RULES as RULES_FILE logger.info('Bridge rules file found and rules imported') except ImportError: sys.exit('Bridging rules file not found or invalid') @@ -73,8 +73,8 @@ except ImportError: # we need to send in the actual data packets. # -for _ipsc in RULES: - for _rule in RULES[_ipsc]['GROUP_VOICE']: +for _ipsc in RULES_FILE: + for _rule in RULES_FILE[_ipsc]['GROUP_VOICE']: _rule['SRC_GROUP'] = hex_str_3(_rule['SRC_GROUP']) _rule['DST_GROUP'] = hex_str_3(_rule['DST_GROUP']) _rule['SRC_TS'] = _rule['SRC_TS'] - 1 @@ -82,9 +82,11 @@ for _ipsc in RULES: if _ipsc not in NETWORK: sys.exit('ERROR: Bridge rules found for an IPSC network not configured in main configuration') for _ipsc in NETWORK: - if _ipsc not in RULES: + if _ipsc not in RULES_FILE: sys.exit('ERROR: Bridge rules not found for all IPSC network configured') +RULES = RULES_FILE + # Import List of Bridges # This is how we identify known bridges. If one of these is present # and it's mode byte is set to bridge, we don't @@ -106,7 +108,7 @@ class bridgeIPSC(IPSC): else: self.BRIDGE = True logger.info('Initializing standard bridging') - + self.IPSC_STATUS = { 'TS1': {'RX_GROUP':'\x00', 'TX_GROUP':'\x00', 'RX_TIME':0, 'TX_TIME':0, 'RX_SRC_SUB':'\x00', 'TX_SRC_SUB':'\x00'}, 'TS2': {'RX_GROUP':'\x00', 'TX_GROUP':'\x00', 'RX_TIME':0, 'TX_TIME':0, 'RX_SRC_SUB':'\x00', 'TX_SRC_SUB':'\x00'}