diff --git a/plugins/mysql-apt/index.py b/plugins/mysql-apt/index.py index 1b89c5fdb..ad67b7ee4 100755 --- a/plugins/mysql-apt/index.py +++ b/plugins/mysql-apt/index.py @@ -95,6 +95,14 @@ def getSocketFile(): return tmp.groups()[0].strip() +def getErrorLogsFile(): + file = getConf() + content = mw.readFile(file) + rep = 'log-error\s*=\s*(.*)' + tmp = re.search(rep, content) + return tmp.groups()[0].strip() + + def contentReplace(content): service_path = mw.getServerDir() content = content.replace('{$ROOT_PATH}', mw.getRootDir()) @@ -244,15 +252,7 @@ def setSkipGrantTables(v): def getErrorLog(): args = getArgs() - path = getDataDir() - filename = '' - for n in os.listdir(path): - if len(n) < 5: - continue - if n == 'error.log': - filename = path + '/' + n - break - # print filename + filename = getErrorLogsFile() if not os.path.exists(filename): return mw.returnJson(False, '指定文件不存在!') if 'close' in args: diff --git a/plugins/mysql-yum/index.py b/plugins/mysql-yum/index.py index 9b35684c9..1015228b1 100755 --- a/plugins/mysql-yum/index.py +++ b/plugins/mysql-yum/index.py @@ -102,6 +102,14 @@ def getSocketFile(): return tmp.groups()[0].strip() +def getErrorLogsFile(): + file = getConf() + content = mw.readFile(file) + rep = 'log-error\s*=\s*(.*)' + tmp = re.search(rep, content) + return tmp.groups()[0].strip() + + def contentReplace(content): service_path = mw.getServerDir() content = content.replace('{$ROOT_PATH}', mw.getRootDir()) @@ -235,15 +243,7 @@ def setSkipGrantTables(v): def getErrorLog(): args = getArgs() - path = getDataDir() - filename = '' - for n in os.listdir(path): - if len(n) < 5: - continue - if n == 'error.log': - filename = path + '/' + n - break - # print filename + filename = getErrorLogsFile() if not os.path.exists(filename): return mw.returnJson(False, '指定文件不存在!') if 'close' in args: diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index 6776721b3..504c483fc 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -92,6 +92,14 @@ def getSocketFile(): return tmp.groups()[0].strip() +def getErrorLogsFile(): + file = getConf() + content = mw.readFile(file) + rep = 'log-error\s*=\s*(.*)' + tmp = re.search(rep, content) + return tmp.groups()[0].strip() + + def getInitdTpl(version=''): path = getPluginDir() + '/init.d/mysql' + version + '.tpl' if not os.path.exists(path): @@ -319,15 +327,7 @@ def setSkipGrantTables(v): def getErrorLog(): args = getArgs() - path = getDataDir() - filename = '' - for n in os.listdir(path): - if len(n) < 5: - continue - if n == 'error.log': - filename = path + '/' + n - break - # print filename + filename = getErrorLogsFile() if not os.path.exists(filename): return mw.returnJson(False, '指定文件不存在!') if 'close' in args: