Example #1
0
 def closeLogsApi(self):
     logPath = mw.getLogsDir()
     os.system('rm -f ' + logPath + '/*')
     os.system('kill -USR1 `cat ' + mw.getServerDir() +
               'openresty/nginx/logs/nginx.pid`')
     mw.writeLog('文件管理', '网站日志已被清空!')
     tmp = self.getDirSize(logPath)
     return mw.returnJson(True, tmp[0].split()[0])
Example #2
0
def getLogsList():
    args = getArgs()
    data = checkArgs(args, ['siteName'])
    if not data[0]:
        return data[1]

    data = []
    path = mw.getLogsDir() + '/waf'
    files = os.listdir(path)
    for f in files:
        if f == '.DS_Store':
            continue
        f = f.split('_')
        if f[0] == args['siteName']:
            fl = f[1].split('.')
            data.append(fl[0])

    return mw.returnJson(True, 'ok!', data)
Example #3
0
def getSafeLogs():
    args = getArgs()
    data = checkArgs(args, ['siteName', 'toDate', 'p'])
    if not data[0]:
        return data[1]

    path = mw.getLogsDir() + '/waf'
    file = path + '/' + args['siteName'] + '_' + args['toDate'] + '.log'
    if not os.path.exists(file):
        return mw.returnJson(False, "文件不存在!")

    retData = []
    file = open(file)
    while 1:
        lines = file.readlines(100000)
        if not lines:
            break
        for line in lines:

            retData.append(json.loads(line))

    return mw.returnJson(True, '设置成功!', retData)
Example #4
0
if sys.platform != 'darwin':
    os.chdir('/www/server/mdserver-web')


chdir = os.getcwd()
sys.path.append(chdir + '/class/core')
reload(sys)
sys.setdefaultencoding('utf-8')

import mw
print('==================================================================')
print('★[' + time.strftime("%Y/%m/%d %H:%M:%S") + '],切割日志')
print('==================================================================')
print('|--当前保留最新的[' + sys.argv[2] + ']份')
logsPath = mw.getLogsDir()
px = '.log'


def split_logs(oldFileName, num):
    global logsPath
    if not os.path.exists(oldFileName):
        print('|---' + oldFileName + '文件不存在!')
        return

    logs = sorted(glob.glob(oldFileName + "_*"))
    count = len(logs)
    num = count - num

    for i in range(count):
        if i > num:
Example #5
0
 def getWwwPathApi(self):
     path = mw.getLogsDir()
     return mw.getJson({'path': path})