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

Function ClearSession

tools.py:474–492  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

472
473# 清理php_session文件
474def ClearSession():
475 spath = '/tmp'
476 total = count = 0
477 import shutil
478 print('|-正在清理PHP_SESSION ...')
479 for d in os.listdir(spath):
480 if d.find('sess_') == -1: continue
481 filename = spath + '/' + d
482 fsize = os.path.getsize(filename)
483 print('|---[' + ToSize(fsize) + '] del ' + filename),
484 total += fsize
485 if os.path.isdir(filename):
486 shutil.rmtree(filename)
487 else:
488 os.remove(filename)
489 print('\t\033[1;32m[OK]\033[0m')
490 count += 1
491 print('|-已完成php_session的清理,删除[' + str(count) + ']个文件,共释放磁盘空间[' + ToSize(total) + ']')
492 return total, count
493
494
495# 清空回收站

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