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):
|
def testConnect(url):
|
||||||
try:
|
try:
|
||||||
time1=datetime.now().timestamp()
|
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()
|
time2=datetime.now().timestamp()
|
||||||
delay=int((time2-time1)*1000)
|
delay=int((time2-time1)*1000)
|
||||||
except:
|
except:
|
||||||
code=404
|
status_code=404
|
||||||
if code/100>=4:
|
if status_code/100>=4:
|
||||||
delay=10000
|
delay=10000
|
||||||
return (code,delay)
|
return (status_code,delay)
|
||||||
|
|
||||||
if __name__=="__main__":
|
if __name__=="__main__":
|
||||||
lastminute=-1
|
lastminute=-1
|
||||||
|
@ -66,9 +66,9 @@ if __name__=="__main__":
|
||||||
if datetime.now().second==0 and datetime.now().minute!=lastminute:
|
if datetime.now().second==0 and datetime.now().minute!=lastminute:
|
||||||
# if True:
|
# if True:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
(code,delay)=testConnect("https://blog.clf3.org")
|
(status_code,delay)=testConnect("https://blog.clf3.org")
|
||||||
print(code,end=" ")
|
print(status_code,end=" ")
|
||||||
if code/100<=3:
|
if status_code/100<=3:
|
||||||
print("connected",delay,"ms")
|
print("connected",delay,"ms")
|
||||||
else:
|
else:
|
||||||
print("error")
|
print("error")
|
||||||
|
@ -83,9 +83,9 @@ if __name__=="__main__":
|
||||||
elif datetime.now().second==10 and datetime.now().minute!=lastminute:
|
elif datetime.now().second==10 and datetime.now().minute!=lastminute:
|
||||||
# if True:
|
# if True:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
(code,delay)=testConnect("https://cloud.clf3.org")
|
(status_code,delay)=testConnect("https://cloud.clf3.org")
|
||||||
print(code,end=" ")
|
print(status_code,end=" ")
|
||||||
if code/100<=3:
|
if status_code/100<=3:
|
||||||
print("connected",delay,"ms")
|
print("connected",delay,"ms")
|
||||||
else:
|
else:
|
||||||
print("error")
|
print("error")
|
||||||
|
@ -100,9 +100,9 @@ if __name__=="__main__":
|
||||||
elif datetime.now().second==20 and datetime.now().minute!=lastminute:
|
elif datetime.now().second==20 and datetime.now().minute!=lastminute:
|
||||||
# if True:
|
# if True:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
(code,delay)=testConnect("https://code.clf3.org")
|
(status_code,delay)=testConnect("https://code.clf3.org")
|
||||||
print(code,end=" ")
|
print(status_code,end=" ")
|
||||||
if code/100<=3:
|
if status_code/100<=3:
|
||||||
print("connected",delay,"ms")
|
print("connected",delay,"ms")
|
||||||
else:
|
else:
|
||||||
print("error")
|
print("error")
|
||||||
|
@ -117,9 +117,9 @@ if __name__=="__main__":
|
||||||
elif datetime.now().second==30 and datetime.now().minute!=lastminute:
|
elif datetime.now().second==30 and datetime.now().minute!=lastminute:
|
||||||
# if True:
|
# if True:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
(code,delay)=testConnect("https://git.clf3.org")
|
(status_code,delay)=testConnect("https://git.clf3.org")
|
||||||
print(code,end=" ")
|
print(status_code,end=" ")
|
||||||
if code/100<=3:
|
if status_code/100<=3:
|
||||||
print("connected",delay,"ms")
|
print("connected",delay,"ms")
|
||||||
else:
|
else:
|
||||||
print("error")
|
print("error")
|
||||||
|
|
Loading…
Reference in New Issue