Merge branch 'dev'

This commit is contained in:
岛风 2024-01-08 19:03:06 +08:00
commit 52b6660f85

23
main.py
View File

@ -19,15 +19,22 @@ def network_restart():
return False return False
return True return True
def convert_seconds(seconds):
hours = seconds // 3600
minutes = (seconds % 3600) // 60
seconds = (seconds % 3600) % 60
return hours, minutes, seconds
def ascii_tag(): def ascii_tag():
sys_s = None sys_s ,sta_s= None, None
sta_s = None
if i > 0: if i > 0:
sys_s = "Down" sys_s = "Down"
sta_s = "{} network 403 , down".format(time.ctime()) sta_s = f"{time.ctime()} network 403 , down"
else: else:
sys_s = "Up" sys_s = "Up"
sta_s = "{} network 200 , ok".format(time.ctime()) sta_s = f"{time.ctime()} network 200 , ok"
t = int(time.time() - k)
t = convert_seconds(t)
os.system("clear") os.system("clear")
print(" _ _ _______ ") print(" _ _ _______ ")
print(" / \ / |_ |_ __ \ ") print(" / \ / |_ |_ __ \ ")
@ -36,13 +43,13 @@ def ascii_tag():
print(" _/ / \ \_ | \_/ |,| |,| \__. |_| | \ \_| \__., ") print(" _/ / \ \_ | \_/ |,| |,| \__. |_| | \ \_| \__., ")
print("|____| |____|'.__.'_/\__/ '.__.'|____| |___|'.__.' ") print("|____| |____|'.__.'_/\__/ '.__.'|____| |___|'.__.' ")
print("") print("")
print("系统架构:{}\n异常次数:{}\n当前状态:{}\n最近记录:{}".format(os.name,j,sys_s,sta_s)) print(f"系统架构:{os.name}\n异常次数:{j}\n当前状态:{sys_s}\n运行时间:{t[0]}{t[1]}{t[2]}\n最近记录:{sta_s}")
return True return True
def main(): def main():
global i ,j global i, j, k
i = 0 i, j = 0, 0
j = 0 k = time.time()
while(1): while(1):
if not network_test(): #网络异常 if not network_test(): #网络异常
i +=1 #异常计数 3次失败重启 i +=1 #异常计数 3次失败重启