init
This commit is contained in:
parent
ab7036754f
commit
8fc783179c
32
main.py
Normal file
32
main.py
Normal file
@ -0,0 +1,32 @@
|
||||
import os, time ,requests
|
||||
|
||||
def network_test():
|
||||
try:
|
||||
html = requests.get("https://www.baidu.com",timeout=5)
|
||||
print("{} network 200 , ok".format(time.ctime()))
|
||||
return True
|
||||
except:
|
||||
print("{} network 403 , down".format(time.ctime()))
|
||||
return False
|
||||
|
||||
def network_restart():
|
||||
print("重启en0")
|
||||
return True
|
||||
|
||||
def main():
|
||||
i = 0
|
||||
while(1):
|
||||
if not network_test():
|
||||
i +=1
|
||||
print(i)
|
||||
time.sleep(3)
|
||||
else:
|
||||
time.sleep(10)
|
||||
if (i > 2):
|
||||
network_restart()
|
||||
time.sleep(10)
|
||||
i = 0
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user