From df995bf9fe011575b8d81f1e29d0ac1a5f9bb6cb Mon Sep 17 00:00:00 2001 From: ClF3 Date: Wed, 24 Jan 2024 01:38:34 +0800 Subject: [PATCH] edit --- main.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/main.py b/main.py index 2370430..be17c44 100644 --- a/main.py +++ b/main.py @@ -51,14 +51,14 @@ def update_graph(filename,history): def testConnect(url): try: time1=datetime.now().timestamp() - code=urllib.request.urlopen(url,timeout=5).getcode() + status_code=urllib.request.urlopen(url,timeout=5).getcode() time2=datetime.now().timestamp() delay=int((time2-time1)*1000) except: - code=404 - if code/100>=4: + status_code=404 + if status_code/100>=4: delay=10000 - return (code,delay) + return (status_code,delay) if __name__=="__main__": lastminute=-1 @@ -66,9 +66,9 @@ if __name__=="__main__": if datetime.now().second==0 and datetime.now().minute!=lastminute: # if True: time.sleep(1) - (code,delay)=testConnect("https://blog.clf3.org") - print(code,end=" ") - if code/100<=3: + (status_code,delay)=testConnect("https://blog.clf3.org") + print(status_code,end=" ") + if status_code/100<=3: print("connected",delay,"ms") else: print("error") @@ -83,9 +83,9 @@ if __name__=="__main__": elif datetime.now().second==10 and datetime.now().minute!=lastminute: # if True: time.sleep(1) - (code,delay)=testConnect("https://cloud.clf3.org") - print(code,end=" ") - if code/100<=3: + (status_code,delay)=testConnect("https://cloud.clf3.org") + print(status_code,end=" ") + if status_code/100<=3: print("connected",delay,"ms") else: print("error") @@ -100,9 +100,9 @@ if __name__=="__main__": elif datetime.now().second==20 and datetime.now().minute!=lastminute: # if True: time.sleep(1) - (code,delay)=testConnect("https://code.clf3.org") - print(code,end=" ") - if code/100<=3: + (status_code,delay)=testConnect("https://code.clf3.org") + print(status_code,end=" ") + if status_code/100<=3: print("connected",delay,"ms") else: print("error") @@ -117,9 +117,9 @@ if __name__=="__main__": elif datetime.now().second==30 and datetime.now().minute!=lastminute: # if True: time.sleep(1) - (code,delay)=testConnect("https://git.clf3.org") - print(code,end=" ") - if code/100<=3: + (status_code,delay)=testConnect("https://git.clf3.org") + print(status_code,end=" ") + if status_code/100<=3: print("connected",delay,"ms") else: print("error")