#!/usr/bin/env python # $Id: lstats,v 1.4 2003/08/20 10:37:47 sduff Exp $ import re, sys, urllib import httplib, urllib import getpass user = getpass.getuser() stats = { "-db": "citylabstats.fp5", "-layid": "4", "-token.0": "25", "-token.1": "", "-skip": "9", "-max": "1", "-format": "formvwcss.htm", "-mode": "browse", "-new": "", "Date": "", "Time": "11:00am", "Entered By": user } labs = [ "Salomaa People", "Salomaa Used", "Hopper People", "Hopper Used", "Bolam People", "Bolam Used", "Knuth People", "Knuth Used", "Turing People", "Turing Used", "Sutherland People", "Sutherland Used", "Games People", "Games Used", "Alice People", "Alice Used", "Beard People", "Beard Used", "Pearcy People", "Pearcy Used", "Lions People", "Lions Used", "Boole People", "Boole Used", "Scheutz People", "Scheutz Used", "Babbage People", "Babbage Used" # "Aho People", # removed, because very important people moved in here # "Aho Used", ] # # USERNAME: dutyp # PASSWORD: --- REMOVED --- # headers = { "Content-type": "application/x-www-form-urlencoded", "Authorization": "Basic --- REMOVED ---", "Accept": "*/*" } print "NEW! if you make a mistake and then press enter, type `-' to go back a line" print "1-9.00 2-11.00 3-1.00 4-3.00 5-5.00 6-7.00" try: i = int(raw_input("Please select the time: [1-6] ")) except: print "moron" sys.exit(0) if i == 1: stats["Time"] = "9:00am" elif i == 2: stats["Time"] = "11:00am" elif i == 3: stats["Time"] = "1:00pm" elif i == 4: stats["Time"] = "3:00pm" elif i == 5: stats["Time"] = "5:00pm" elif i == 6: stats["Time"] = "7:00pm" #elif i == 7: # stats["Time"] = "9:00pm" else: print "dont recognise the time" sys.exit(0) p = re.compile('.*Used') i = 0 lablen = len(labs) while i < lablen: ri = "%s\t" % labs[i] inp = raw_input(ri) if inp == "-": i = i-2 if i < 0: i=-1 if inp == "": m = p.match(labs[i]) if m: # this is a used, so use the previous stats[labs[i]] = stats[labs[i-1]] else: # this is a ppl in labs, so set to 0 stats[labs[i]] = 0 else: stats[labs[i]] = inp i = i + 1 params = urllib.urlencode(stats) print params # Stats have been updated, now send them off conn = httplib.HTTPConnection("quoll.cs.rmit.edu.au") conn.request("POST", "/FMRes/FMPro", params, headers) response = conn.getresponse() data = response.read() conn.close() # Set everything back to normal print response.read() #print data