mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-18 23:45:52 +08:00
Update index.py
This commit is contained in:
+17
-18
@@ -88,7 +88,7 @@ def getConf():
|
||||
def getDbPort():
|
||||
file = getConf()
|
||||
content = mw.readFile(file)
|
||||
rep = 'port\s*=\s*(.*)'
|
||||
rep = r'port\s*=\s*(.*)'
|
||||
tmp = re.search(rep, content)
|
||||
return tmp.groups()[0].strip()
|
||||
|
||||
@@ -96,7 +96,7 @@ def getDbPort():
|
||||
def getDbServerId():
|
||||
file = getConf()
|
||||
content = mw.readFile(file)
|
||||
rep = 'server-id\s*=\s*(.*)'
|
||||
rep = r'server-id\s*=\s*(.*)'
|
||||
tmp = re.search(rep, content)
|
||||
return tmp.groups()[0].strip()
|
||||
|
||||
@@ -104,7 +104,7 @@ def getDbServerId():
|
||||
def getSocketFile():
|
||||
file = getConf()
|
||||
content = mw.readFile(file)
|
||||
rep = 'socket\s*=\s*(.*)'
|
||||
rep = r'socket\s*=\s*(.*)'
|
||||
tmp = re.search(rep, content)
|
||||
return tmp.groups()[0].strip()
|
||||
|
||||
@@ -112,14 +112,14 @@ def getSocketFile():
|
||||
def getErrorLogsFile():
|
||||
file = getConf()
|
||||
content = mw.readFile(file)
|
||||
rep = 'log-error\s*=\s*(.*)'
|
||||
rep = r'log-error\s*=\s*(.*)'
|
||||
tmp = re.search(rep, content)
|
||||
return tmp.groups()[0].strip()
|
||||
|
||||
def getAuthPolicy():
|
||||
file = getConf()
|
||||
content = mw.readFile(file)
|
||||
rep = 'authentication_policy\s*=\s*(.*)'
|
||||
rep = r'authentication_policy\s*=\s*(.*)'
|
||||
tmp = re.search(rep, content)
|
||||
if tmp:
|
||||
return tmp.groups()[0].strip()
|
||||
@@ -302,7 +302,7 @@ def status(version=''):
|
||||
def getDataDir():
|
||||
file = getConf()
|
||||
content = mw.readFile(file)
|
||||
rep = 'datadir\s*=\s*(.*)'
|
||||
rep = r'datadir\s*=\s*(.*)'
|
||||
tmp = re.search(rep, content)
|
||||
return tmp.groups()[0].strip()
|
||||
|
||||
@@ -310,7 +310,7 @@ def getDataDir():
|
||||
def getLogBinName():
|
||||
file = getConf()
|
||||
content = mw.readFile(file)
|
||||
rep = 'log-bin\s*=\s*(.*)'
|
||||
rep = r'log-bin\s*=\s*(.*)'
|
||||
tmp = re.search(rep, content)
|
||||
return tmp.groups()[0].strip()
|
||||
|
||||
@@ -318,7 +318,7 @@ def getLogBinName():
|
||||
def getPidFile():
|
||||
file = getConf()
|
||||
content = mw.readFile(file)
|
||||
rep = 'pid-file\s*=\s*(.*)'
|
||||
rep = r'pid-file\s*=\s*(.*)'
|
||||
tmp = re.search(rep, content)
|
||||
return tmp.groups()[0].strip()
|
||||
|
||||
@@ -424,7 +424,7 @@ def getErrorLog():
|
||||
def getShowLogFile():
|
||||
file = getConf()
|
||||
content = mw.readFile(file)
|
||||
rep = 'slow-query-log-file\s*=\s*(.*)'
|
||||
rep = r'slow-query-log-file\s*=\s*(.*)'
|
||||
tmp = re.search(rep, content)
|
||||
return tmp.groups()[0].strip()
|
||||
|
||||
@@ -743,7 +743,7 @@ def initdUinstall():
|
||||
def getMyDbPos():
|
||||
file = getConf()
|
||||
content = mw.readFile(file)
|
||||
rep = 'datadir\s*=\s*(.*)'
|
||||
rep = r'datadir\s*=\s*(.*)'
|
||||
tmp = re.search(rep, content)
|
||||
return tmp.groups()[0].strip()
|
||||
|
||||
@@ -793,7 +793,7 @@ def setMyDbPos(version):
|
||||
def getMyPort():
|
||||
file = getConf()
|
||||
content = mw.readFile(file)
|
||||
rep = 'port\s*=\s*(.*)'
|
||||
rep = r'port\s*=\s*(.*)'
|
||||
tmp = re.search(rep, content)
|
||||
return tmp.groups()[0].strip()
|
||||
|
||||
@@ -807,7 +807,7 @@ def setMyPort(version):
|
||||
port = args['port']
|
||||
file = getConf()
|
||||
content = mw.readFile(file)
|
||||
rep = "port\s*=\s*([0-9]+)\s*\n"
|
||||
rep = r"port\s*=\s*([0-9]+)\s*\n"
|
||||
content = re.sub(rep, 'port = ' + port + '\n', content)
|
||||
mw.writeFile(file, content)
|
||||
restart(version)
|
||||
@@ -898,7 +898,7 @@ def setDbStatus(version):
|
||||
s = 'K'
|
||||
if g in emptys:
|
||||
s = ''
|
||||
rep = '\s*' + g + '\s*=\s*\d+(M|K|k|m|G)?\n'
|
||||
rep = r'\s*' + g + r'\s*=\s*\d+(M|K|k|m|G)?\n'
|
||||
c = g + ' = ' + args[g] + s + '\n'
|
||||
if content.find(g) != -1:
|
||||
content = re.sub(rep, '\n' + c, content, 1)
|
||||
@@ -1571,7 +1571,7 @@ def addDb():
|
||||
dataAccess = args['dataAccess'].strip()
|
||||
ps = args['ps'].strip()
|
||||
|
||||
reg = "^[\w-]+$"
|
||||
reg = r"^[\w-]+$"
|
||||
if not re.match(reg, args['name']):
|
||||
return mw.returnJson(False, '数据库名称不能带有特殊符号!')
|
||||
checks = ['root', 'mysql', 'test', 'sys', 'performance_schema','information_schema']
|
||||
@@ -2163,8 +2163,7 @@ def setDbMaster(version):
|
||||
|
||||
if not isHas:
|
||||
prefix = '#binlog-do-db'
|
||||
con = con.replace(
|
||||
prefix, prefix + "\nbinlog-do-db=" + args['name'])
|
||||
con = con.replace(prefix, prefix + "\nbinlog-do-db=" + args['name'])
|
||||
mw.writeFile(conf, con)
|
||||
|
||||
restart(version)
|
||||
@@ -2326,7 +2325,7 @@ def addMasterRepSlaveUser(version=''):
|
||||
# address = args['address'].strip()
|
||||
# dataAccess = args['dataAccess'].strip()
|
||||
|
||||
reg = "^[\w-]+$"
|
||||
reg = r"^[\w-]+$"
|
||||
if not re.match(reg, username):
|
||||
return mw.returnJson(False, '用户名不能带有特殊符号!')
|
||||
checks = ['root', 'mysql', 'test', 'sys', 'performance_schema','information_schema']
|
||||
@@ -3392,7 +3391,7 @@ def doFullSyncUserImportContentForChannel(file, channel_name):
|
||||
content = content.replace('STOP SLAVE;', "STOP SLAVE for channel '{}';".format(channel_name))
|
||||
content = content.replace('START SLAVE;', "START SLAVE for channel '{}';".format(channel_name))
|
||||
|
||||
find_head = "CHANGE MASTER TO "
|
||||
find_head = r"CHANGE MASTER TO "
|
||||
find_re = find_head+"(.*?);"
|
||||
find_r = re.search(find_re, content, re.I|re.M)
|
||||
if find_r:
|
||||
|
||||
Reference in New Issue
Block a user