#!/usr/bin/python import ldap, time, operator # # globals # cscUri = "http://csclub.uwaterloo.ca/xsltproc" cscTerms = ["Winter", "Spring", "Fall"] cscShortTerms = ['w', 's', 'f'] cscLdapUri = "ldap://ldap1.csclub.uwaterloo.ca ldap://ldap2.csclub.uwaterloo.ca" cscLdap = None cscPeopleBase = 'ou=People,dc=csclub,dc=uwaterloo,dc=ca' def cscLdapConnect(): global cscLdap cscLdap = ldap.initialize(cscLdapUri) cscLdap.simple_bind_s("", "") cscLdapConnect() curDate = time.strftime('%d-%m-%Y') year = time.localtime().tm_year term = cscShortTerms[int(time.localtime().tm_mon - 1) / 4] term2 = cscTerms[int(time.localtime().tm_mon - 1) / 4] members = cscLdap.search_s(cscPeopleBase, ldap.SCOPE_SUBTREE, '(&(objectClass=member)(term=%s%d))' % (term, year)) members.sort(key=lambda (_, y): y['cn'][0]) print "

Members This Term

" print "

The members for " + term2 + " " + str(year) + " are listed here. We currently have " + str(len(members)) + " members.
" print "Use of this list for solicitation of any form is prohibited. If you wish to get in touch with the membership as a whole please contact the Executive.

" print "
" print "" print " " for (_, member) in members: if not 'program' in member: member['program'] = [''] print " " print " " print " " print " " print " " print "
NameProgramUsername
" + member['cn'][0] + "" + member['program'][0] + "" + member['uid'][0] + "
" print "
"