Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import os
- import time
- username = "admin"
- password = "admin"
- url_connect = "http://192.168.1.1/userRpm/StatusRpm.htm?Connect=Connect&wan=1"
- url_disconnect = "http://192.168.1.1/userRpm/StatusRpm.htm?Disconnect=Disconnect&wan=1"
- while 1:
- # time.sleep(1)
- r = requests.get(url_connect, auth=(username, password))
- # time.sleep(1)
- found = 0
- for _ in range(20):
- if os.system("ping -c 1 " + "ya.ru") == 0:
- found = 1
- break
- if found == 0:
- requests.get(url_disconnect, auth=(username, password))
- continue
- try:
- u = os.popen("speedtest-cli").read().split('\n')[6]
- except:
- print "Ooops"
- continue
- u = u[u.find(' ') + 1:]
- u = u[:u.find(' ')]
- u = float(u)
- print "SPEEEEEEEEED: " + str(u)
- if u > 1:
- break
- requests.get(url_disconnect, auth=(username, password))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement