edit
This commit is contained in:
parent
0aeb620679
commit
df995bf9fe
32
main.py
32
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")
|
||||
|
|
Loading…
Reference in New Issue