MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / ClearOther

Function ClearOther

tools.py:503–529  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

501
502# 清理其它
503def ClearOther():
504 clearPath = [
505 {'path': '/www/server/panel', 'find': 'testDisk_'},
506 {'path': '/www/wwwlogs', 'find': 'log'},
507 {'path': '/tmp', 'find': 'panelBoot.pl'},
508 {'path': '/www/server/panel/install', 'find': '.rpm'},
509 {'path': '/www/server/panel/install', 'find': '.zip'},
510 {'path': '/www/server/panel/install', 'find': '.gz'}
511 ]
512
513 total = count = 0
514 print('|-正在清理临时文件及网站日志 ...')
515 for c in clearPath:
516 for d in os.listdir(c['path']):
517 if d.find(c['find']) == -1: continue
518 filename = c['path'] + '/' + d
519 if os.path.isdir(filename): continue
520 fsize = os.path.getsize(filename)
521 print('|---[' + ToSize(fsize) + '] del ' + filename),
522 total += fsize
523 os.remove(filename)
524 print('\t\033[1;32m[OK]\033[0m')
525 count += 1
526 public.serviceReload()
527 os.system('sleep 1 && /etc/init.d/bt reload > /dev/null &')
528 print('|-已完成临时文件及网站日志的清理,删除[' + str(count) + ']个文件,共释放磁盘空间[' + ToSize(total) + ']')
529 return total, count
530
531
532# 关闭普通日志

Callers 1

ClearSystemFunction · 0.70

Calls 4

listdirMethod · 0.80
ToSizeFunction · 0.70
findMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected