Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # your code goes here
- import subprocess
- import urllib2
- import re
- import time
- def main():
- delay_time = 0;
- ipaddr = urllib2.urlopen('http://www.myipaddress.com/show-my-ip-address/')
- ip_re = "[0-9]{3}.[0-9]{3}.[0-9]{3}.[0-9]{3}"
- ip = re.findall(ip_re, ipaddr.read())[0]
- def while_body():
- print("Starting release.")
- subprocess.check_call(["ipconfig", "/release"])
- print("Go unplug your modem.")
- time.delay(delay_time)
- while_body() #No do...while, and I'm too lazy not to do this.
- while re.findall(ip_re, urllib2.urlopen('http://www.myipaddress.com/show-my-ip-address/').read())[0] == ip:
- while_body()
- delay_time += 1000
- print("Starting renew.")
- subprocess.check_call(["ipconfig", "/renew"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement