#!/usr/local/bin/python # list_survey.{cgi|py} # last edited Wednesday 7th January 1998 5:15 # debug = 0 page_title = "Principals' Survey Submission List" empty = "\015\012" submission_path = "/staff/lhay/principal/data/" def put_header(): print "Content-type: text/html\n" print "" print "", page_title, "" print "" print "" print "

" + page_title + "

" # # def put_footer(): print "" def test_form(): import cgi cgi.test() # def list_files(cc): import os,regex,string files = os.listdir(submission_path) survey_types = ('TL1', 'TL2', 'TL3', 'PR1', 'PR2', 'PR3') surveys = {} survey_file = regex.compile(cc+'.*') for subfile in files: if survey_file.match(subfile) >= 0: parts = string.split(subfile, '.') sin = parts[0] stype = parts[1][0:3] if surveys.has_key(sin): surveys[sin].append(stype) else: surveys[sin]=[stype] survey_keys = surveys.keys() survey_keys.sort() print "
"
    for k in survey_keys:
	print k,
	for t in survey_types:
	    if surveys[k].count(t) > 0:
		print t,
	    else:
		print "   ",
	print " "
    print "
" # def process(): country_codes = ("au", "ca", "fi", "fr", "jp", "sc", "sk") for cc in country_codes: list_files(cc) # def main(): import sys, traceback, os, cgi sys.stderr = sys.stdout put_header() #if os.getuid() <> 60001: # print "Not submitted via HTTP. Data not accepted." # put_footer() # sys.exit(1) try: process() except: print """

Error: Incorrect program design or implementation.

I'm sorry for the inconvenience.

Please send Geoff <gfellows@csu.edu.au> an e-mail message.
Tell me the name and version number of your WWW browser and include this screen.
""" #print cgi.print_environ() print "

"
	traceback.print_exc()
	print "
" put_footer() # if __name__ == "__main__": main()