Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  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.findall("[0-9]{3}.[0-9]{3}.[0-9]{3}.[0-9]{3}", ipaddr.read())[0]
  11.     def while_body():
  12.         print "Starting release."
  13.         subprocess.check_call(["ipconfig", "/release"])
  14.         print("Go unplug your modem.")
  15.         time.delay(delay_time)
  16.     while_body() #No do...while, and I'm too lazy not to do this.
  17.     while re.findall(ip_re, urllib2.urlopen('http://www.myipaddress.com/show-my-ip-address/').read())[0] == ip:
  18.             while_body()
  19.             delay_time += 1000
  20.     print("Starting renew.")
  21.     subprocess.check_call("ipconfig",  "/renew"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement