sucessfully reads repeater config from MySQL

pypy
Simon 5 years ago
parent b79870a3cd
commit c4777acf8c

@ -56,6 +56,9 @@ from mk_voice import pkt_gen
#Read voices #Read voices
from read_ambe import readAMBE from read_ambe import readAMBE
#MySQL
from mysql_config import useMYSQL
# Stuff for socket reporting # Stuff for socket reporting
import pickle import pickle
# REMOVE LATER from datetime import datetime # REMOVE LATER from datetime import datetime
@ -1028,6 +1031,25 @@ if __name__ == '__main__':
logger.info('\n\nCopyright (c) 2013, 2014, 2015, 2016, 2018, 2019\n\tThe Regents of the K0USY Group. All rights reserved.\n') logger.info('\n\nCopyright (c) 2013, 2014, 2015, 2016, 2018, 2019\n\tThe Regents of the K0USY Group. All rights reserved.\n')
logger.debug('(GLOBAL) Logging system started, anything from here on gets logged') logger.debug('(GLOBAL) Logging system started, anything from here on gets logged')
#If MySQL is enabled, read master config from MySQL too
if CONFIG['MYSQL']['USE_MYSQL'] == True:
logger.debug('(MYSQL) MySQL config enabled')
SQLCONFIG = {}
sql = useMYSQL(CONFIG['MYSQL']['SERVER'], CONFIG['MYSQL']['USER'], CONFIG['MYSQL']['PASS'], CONFIG['MYSQL']['DB'])
if sql.con():
logger.debug('(MYSQL) reading config from database')
try:
SQLCONFIG = sql.getConfig()
except:
logger.debug('(MYSQL) problem with SQL query, aborting')
sql.close()
else:
logger.debug('(MYSQL) problem connecting to SQL server, aborting')
#Add MySQL config data to config dict
CONFIG['SYSTEMS'].update(SQLCONFIG)
# Set up the signal handler # Set up the signal handler
def sig_handler(_signal, _frame): def sig_handler(_signal, _frame):
logger.info('(GLOBAL) SHUTDOWN: CONFBRIDGE IS TERMINATING WITH SIGNAL %s', str(_signal)) logger.info('(GLOBAL) SHUTDOWN: CONFBRIDGE IS TERMINATING WITH SIGNAL %s', str(_signal))

@ -161,7 +161,7 @@ def build_config(_config_file):
'PASS': config.get(section, 'PASS'), 'PASS': config.get(section, 'PASS'),
'DB': config.get(section, 'DB'), 'DB': config.get(section, 'DB'),
'SERVER': config.get(section, 'SERVER'), 'SERVER': config.get(section, 'SERVER'),
'PORT': config.getint('PORT') 'PORT': config.getint(section,'PORT')
}) })

@ -44,7 +44,7 @@ class useMYSQL:
_cursor.execute("select * from repeaters where ENABLED=1 and MODE='MASTER'") _cursor.execute("select * from repeaters where ENABLED=1 and MODE='MASTER'")
except mysql.connector.Error as err: except mysql.connector.Error as err:
_cursor.close() _cursor.close()
return(False) raise Exception('Problem with cursor execute')
for (callsign, mode, enabled, _repeat, max_peers, export_ambe, ip, port, passphrase, group_hangtime, use_acl, reg_acl, sub_acl, tgid_ts1_acl, tgid_ts2_acl, default_ua_timer, single_mode, voice_ident) in _cursor: for (callsign, mode, enabled, _repeat, max_peers, export_ambe, ip, port, passphrase, group_hangtime, use_acl, reg_acl, sub_acl, tgid_ts1_acl, tgid_ts2_acl, default_ua_timer, single_mode, voice_ident) in _cursor:
@ -68,7 +68,7 @@ class useMYSQL:
}}) }})
CONFIG['SYSTEMS'][callsign].update({'PEERS': {}}) CONFIG['SYSTEMS'][callsign].update({'PEERS': {}})
return(CONFIG) return(CONFIG['SYSTEMS'])
#For testing #For testing

Loading…
Cancel
Save

Powered by TurnKey Linux.