Advertisement
Guest User

OmelgePasteTwo

a guest
Nov 24th, 2014
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # your code goes here
  2. import subprocess
  3. import urllib2
  4. import re
  5. import time
  6.  
  7. def main():
  8.     delay_time = 0;
  9.     ipaddr = urllib2.urlopen('http://www.myipaddress.com/show-my-ip-address/')
  10.     ip_re = "[0-9]{3}.[0-9]{3}.[0-9]{3}.[0-9]{3}"
  11.     ip = re.findall(ip_re, ipaddr.read())[0]
  12.     def while_body():
  13.         print("Starting release.")
  14.         subprocess.check_call(["ipconfig", "/release"])
  15.         print("Go unplug your modem.")
  16.         time.delay(delay_time)
  17.     while_body() #No do...while, and I'm too lazy not to do this.
  18.     while re.findall(ip_re, urllib2.urlopen('http://www.myipaddress.com/show-my-ip-address/').read())[0] == ip:
  19.             while_body()
  20.             delay_time += 1000
  21.     print("Starting renew.")
  22.     subprocess.check_call(["ipconfig",  "/renew"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement