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

Function check_disk_space

tools.py:1090–1110  ·  view source on GitHub ↗

@name 检测如果磁盘剩余空间是否小于50M,是就返回False,否则返回True @return bool

()

Source from the content-addressed store, hash-verified

1088
1089# 2025/2/17 14:29 检测如果磁盘剩余空间是否小于500M,是就返回False
1090def check_disk_space():
1091 '''
1092 @name 检测如果磁盘剩余空间是否小于50M,是就返回False,否则返回True
1093 @return bool
1094 '''
1095 disk_info = public.get_disk_usage("/")
1096 if disk_info.free < 50 * 1024 * 1024:
1097 print("==========================================================================")
1098 # 2025/2/17 14:34 输出格式化后的总磁盘空间和剩余空间
1099 os.system("echo -e '\\e[31m紧急:根目录(\"/\")磁盘空间不足50M,请先清理磁盘空间后再执行命令!\\e[0m'")
1100 print("可执行下面命令进行手动清理")
1101 os.system("echo -e '\\e[33m命令:btpython /www/server/panel/script/btcli.py\\e[0m'")
1102 print("总磁盘空间:{},剩余空间:{}".format(public.to_size(disk_info.total), public.to_size(disk_info.free)))
1103 print("计算空间由字节转换,请以实际大小为准!")
1104 print("")
1105 stdout, stderr = public.ExecShell("df -Th")
1106 print("系统 df -Th 输出详情如下:")
1107 print(stdout)
1108 print("==========================================================================")
1109 return False
1110 return True
1111
1112
1113# 命令行菜单

Callers 1

tools.pyFile · 0.70

Calls 4

get_disk_usageMethod · 0.80
ExecShellMethod · 0.80
formatMethod · 0.45
to_sizeMethod · 0.45

Tested by

no test coverage detected