Update index.py

pull/109/head
midoks 4 years ago
parent 18fcce2abc
commit 19bce946cc
  1. 43
      plugins/mysql/index.py

@ -1262,10 +1262,9 @@ def getTotalStatistics():
def findBinlogDoDb(): def findBinlogDoDb():
conf = getConf() conf = getConf()
con = mw.readFile(conf) con = mw.readFile(conf)
rep = 'binlog-do-db\s*=\s*(.*)' rep = r"binlog-do-db\s*?=\s*?(.*)"
tmp = re.search(rep, con) dodb = re.findall(rep, con, re.M)
dlist = tmp.groups()[0].strip() return dodb
return dlist.split(',')
def getMasterDbList(version=''): def getMasterDbList(version=''):
@ -1321,26 +1320,22 @@ def setDbMaster(version):
conf = getConf() conf = getConf()
con = mw.readFile(conf) con = mw.readFile(conf)
rep = 'binlog-do-db\s*=\s*(.*)' rep = r"(binlog-do-db\s*?=\s*?(.*))"
tmp = re.search(rep, con) dodb = re.findall(rep, con, re.M)
dlist = tmp.groups()[0].strip()
dodb = dlist.split(',')
if not args['name'] in dodb:
dlist = dlist + ',' + args['name']
rep = "binlog-do-db\s*=\s*(.*)"
con = re.sub(rep, 'binlog-do-db=' + dlist, con)
mw.writeFile(conf, con)
else: isHas = False
new_dodb_str = '' for x in xrange(0, len(dodb)):
for x in dodb:
if x != args['name']: if dodb[x][1] == args['name']:
new_dodb_str = x + ',' isHas = True
new_dodb_str_len = len(new_dodb_str)
new_dodb_str = new_dodb_str[0:new_dodb_str_len - 1] con = con.replace(dodb[x][0] + "\n", '')
rep = "binlog-do-db\s*=\s*(.*)" mw.writeFile(conf, con)
con = re.sub(rep, 'binlog-do-db=' + new_dodb_str, con)
if not isHas:
prefix = '#binlog-do-db'
con = con.replace(
prefix, prefix + "\nbinlog-do-db=" + args['name'])
mw.writeFile(conf, con) mw.writeFile(conf, con)
restart(version) restart(version)
@ -1353,7 +1348,7 @@ def getMasterStatus(version=''):
con = mw.readFile(conf) con = mw.readFile(conf)
master_status = False master_status = False
if con.find('#log-bin') == -1 and con.find('log-bin') > 1: if con.find('#log-bin') == -1 and con.find('log-bin') > 1:
if con.find('#binlog-do-db') == -1 and con.find('binlog-do-db') > 1: if con.find('binlog-do-db') > 1:
master_status = True master_status = True
data = {} data = {}
data['status'] = master_status data['status'] = master_status

Loading…
Cancel
Save