#!/usr/bin/python import urllib import time #User configurable parameters username = 'yourusername' password = 'yourpassword' iss = 'true' # false if you want to open some ports for the outside world retries = 15 authUrl = 'https://auth.lawn.gatech.edu/index.php' statUrl = 'https://auth.lawn.gatech.edu/login_status.php' logoutUrl = 'https://auth.lawn.gatech.edu/logout.php?output=text' sleep_time = 1 # Check if we are logged into the system def checking_status(): f = urllib.urlopen(statUrl) stat = f.read() if stat.find("logged_in") > -1 : print "You are logged into LAWN" f.close() return True else: f.close() return False # If we aren't already logged in, make a request for logging in def make_POST_request(): data = urllib.urlencode({"username":username, "password":password, "iss": iss, "output":"cli"}) f = urllib.urlopen(authUrl, data) f.close() # Logout of LAWN. Unused as of now def do_logout(): f = urllib.urlopen(logoutUrl) print "Logging out ..." f.close() # Main routine if not checking_status(): make_POST_request() print "Logging in ..." tries = 1 while tries < retries: if checking_status(): break tries += 1 time.sleep(sleep_time) if tries == retries: print "FAILURE: Tried 15 times but couldn't log in"