Bläddra i källkod

migrate to git

pull/10/head
Cian Butler 4 år sedan
förälder
incheckning
67e413f9dc
33 ändrade filer med 102 tillägg och 448 borttagningar
  1. +1
    -1
      RRS-SYNC.TXT
  2. +1
    -1
      TODO
  3. +0
    -45
      attic/dump_userdb.sh
  4. +0
    -106
      attic/rebuild_userdb_staff.py
  5. +0
    -91
      attic/rebuild_userdb_students.py
  6. +0
    -9
      attic/userdb_reserved.sql
  7. +0
    -8
      attic/userdb_staff.sql
  8. +0
    -10
      attic/userdb_students.sql
  9. +0
    -43
      attic/userdb_users.sql
  10. +0
    -20
      attic/userdb_usertypes.sql
  11. +1
    -1
      common.css
  12. +0
    -0
      continous_rrs_backup.sh
  13. +1
    -1
      doc.css
  14. +0
    -0
      fixup-rb-dcu-tree.py
  15. +1
    -1
      func-spec.html
  16. +1
    -1
      index.html
  17. +1
    -1
      install-manual.html
  18. +0
    -2
      newyear_ldif.py
  19. +8
    -3
      rbaccount.py
  20. +16
    -11
      rbconfig.py
  21. +1
    -1
      rberror.py
  22. +1
    -1
      rbopt.py
  23. +29
    -1
      rbuser.py
  24. +4
    -4
      rbuserdb.py
  25. +1
    -1
      rebuild_userdb_reserved.py
  26. +0
    -0
      remove_dcutree_ldif.py
  27. +1
    -1
      rrs.cgi
  28. +1
    -1
      rrs.py
  29. +1
    -1
      tech-manual.html
  30. +1
    -1
      user-manual.html
  31. +7
    -2
      useradm.py
  32. +24
    -0
     
  33. +0
    -79
      vote.py

+ 1
- 1
RRS-SYNC.TXT Visa fil

@@ -2,7 +2,7 @@
# Steps required to use a standalone RRS setup and then sync in changes
# afterwards.
#
# $Id: RRS-SYNC.TXT,v 1.1 2003/10/24 16:10:30 cns Exp cns $
# $Id: RRS-SYNC.TXT,v 1.2 2005/10/09 22:55:31 cns Exp $
#

#======================================================================


+ 1
- 1
TODO Visa fil

@@ -1,4 +1,4 @@
$Id: TODO,v 1.3 2003/10/24 14:52:51 cns Exp cns $
$Id: TODO,v 1.4 2004/03/07 21:11:38 cns Exp $

=======
useradm


+ 0
- 45
attic/dump_userdb.sh Visa fil

@@ -1,45 +0,0 @@
#!/bin/sh
#
# Dump databases to committee folder.
#
# $Id: update_userdb_dumps.sh,v 1.4 2002/02/16 21:50:54 cns Exp cns $
#

OUT=/local/committee/userdb
PSQL="/usr/local/pgsql/bin/psql -h localhost -d userdb"
PG_DUMP="/usr/local/pgsql/bin/pg_dump -h localhost -d userdb"
USERDB_BACKUP="/local/admin/scripts/users/backup-of-userdb.dump"

printf "$OUT dumps: "

# Dump each database and keep a copy of yesterday's database
# (for doing comparisons/diffs).
#
for i in users students reserved; do
$PSQL -c "select * from $i" > $OUT/$i.new
# Only rotate them if there was no error from psql
# and a non-empty dump was generated.
#
if [ $? -eq 0 -a -s $OUT/$i.new ]; then
printf "$i "
mv $OUT/$i $OUT/$i.yesterday
mv $OUT/$i.new $OUT/$i
else
printf "$i (FAILED) "
rm -f $OUT/$i.new
fi
done

echo "Done."

# Make sure committee can read 'em.
#
chmod 640 $OUT/*
chgrp committe $OUT/*

printf "Full dump: "

$PG_DUMP > $USERDB_BACKUP

echo "Done."

+ 0
- 106
attic/rebuild_userdb_staff.py Visa fil

@@ -1,106 +0,0 @@
#! /usr/bin/env python

"""Rebuild staff table in userdb from DCU's LDAP staff tree."""

import ldap
import pgdb
import re

__version__ = "$Revision$"
__author__ = "Cillian Sharkey"

def main():
"""Program entry function."""

ldaphost = 'atlas.dcu.ie'
dbh = pgdb.connect(database = 'userdb')
cur = dbh.cursor()
l = ldap.open(ldaphost)
l.simple_bind_s('', '') # anonymous bind
print 'userdb/staff:',
print 'Search',
staff = l.search_s('ou=staff,o=dcu', ldap.SCOPE_SUBTREE, 'objectclass=person', ('fullName', 'givenName', 'sn', 'mail', 'cn', 'gecos'))
print '[%d].' % len(staff),
# Delete all existing entries.
#
print 'Purge.',
cur.execute('delete from staff')
# Add new entries.
#
print 'Populate.',
total = 0
ids = {}
insert_staff = "INSERT INTO staff (id, name, email) VALUES (%s, %s, %s)"
re_gecos = re.compile(r'^(.*),.*(\d{8})')
for i in staff:
try:
attr = i[1]
id = name = None
# Check gecos for full name and staff id.
#
if attr.has_key('gecos'):
res = re_gecos.search(attr['gecos'][0])
if res:
name = res.group(1)
id = int(res.group(2))
# If no id in gecos, cycle through each cn attribute value
# until we find one that is a number (which can only be the id
# number).
#
if not id:
if attr.has_key('cn'):
for j in attr['cn']:
try:
id = int(j)
except ValueError:
pass
else:
break
else:
# No id found!
continue
# Ignore entries with duplicate IDs.
#
if ids.has_key(id):
continue
else:
ids[id] = 1
# If no name found from gecos and no fullName attribute,
# construct their full name from first name ('givenName')
# followed by their surname ('sn').
#
if not name:
if attr.has_key('fullName'):
name = attr['fullName'][0]
else:
name = '%s %s' % (attr['givenName'][0], attr['sn'][0])
email = attr['mail'][0]
cur.execute(insert_staff, (id, name, email))
total += 1
except KeyError, e:
pass
print 'Done [%d/%d].' % (total, len(staff))

dbh.commit()
cur.execute('END; VACUUM ANALYZE staff')
dbh.close()
l.unbind()
if __name__ == "__main__":
main()

+ 0
- 91
attic/rebuild_userdb_students.py Visa fil

@@ -1,91 +0,0 @@
#! /usr/bin/env python

"""Rebuild students table in userdb from DCU's LDAP student tree."""

import ldap
import pgdb

__version__ = "$Revision: 1.1 $"
__author__ = "Cillian Sharkey"

def main():
"""Program entry function."""

ldaphost = 'atlas.dcu.ie'
dbh = pgdb.connect(database = 'userdb')
cur = dbh.cursor()
l = ldap.open(ldaphost)
l.simple_bind_s('', '') # anonymous bind
print 'userdb/students:',
print 'Search',
students = l.search_s('ou=students,o=dcu', ldap.SCOPE_SUBTREE, 'objectclass=person', ('givenName', 'sn', 'mail', 'l', 'cn'))
print '[%d].' % len(students),
# Delete all existing entries.
#
print 'Purge.',
cur.execute('delete from students')
# Add new entries.
#
print 'Populate.',
total = 0
ids = {}
insert_student = 'INSERT INTO students (id, name, email, course, year) VALUES (%d, %s, %s, %s, %s)'
for i in students:
try:
attr = i[1]
# Extract course & year from 'l' attribute value. Assumes last
# character is the year (1, 2, 3, 4, X, O, C, etc.) and the rest is the
# course name. Uppercase course & year for consistency.
#
course = attr['l'][0][:-1].upper() or 'N/A'
year = attr['l'][0][-1].upper() or 'N/A'
# Cycle through each 'cn' attribute value until we find one that is a
# number (which can only be the id number).
#
for j in attr['cn']:
try:
id = int(j)
except ValueError:
pass
else:
break
else:
# No ID number found! Skip this ldap entry.
continue
if ids.has_key(id):
continue
else:
ids[id] = 1
# Construct their full name from first name ('givenName') followed by
# their surname ('sn').
#
name = '%s %s' % (attr['givenName'][0], attr['sn'][0])
email = attr['mail'][0]
cur.execute(insert_student, (id, name, email, course, year))
total += 1
except KeyError:
pass
print 'Done [%d/%d].' % (total, len(students))
dbh.commit()
cur.execute('END; VACUUM ANALYZE students')
dbh.close()
l.unbind()


if __name__ == "__main__":
main()

+ 0
- 9
attic/userdb_reserved.sql Visa fil

@@ -1,10 +0,0 @@

CREATE TABLE "reserved" (
username VARCHAR(8) NOT NULL PRIMARY KEY,
info VARCHAR NOT NULL
);

GRANT ALL ON reserved TO root;
GRANT SELECT ON users TO webgroup;
GRANT SELECT ON users TO www;

+ 0
- 8
attic/userdb_staff.sql Visa fil

@@ -1,9 +0,0 @@

CREATE TABLE "staff" (
id INT PRIMARY KEY,
name VARCHAR NOT NULL,
email VARCHAR NOT NULL
);

GRANT ALL ON staff TO root;

+ 0
- 10
attic/userdb_students.sql Visa fil

@@ -1,11 +0,0 @@

CREATE TABLE "students" (
id INT PRIMARY KEY,
name VARCHAR NOT NULL,
email VARCHAR NOT NULL,
course VARCHAR NOT NULL,
year VARCHAR NOT NULL
);

GRANT ALL ON students TO root;

+ 0
- 43
attic/userdb_users.sql Visa fil

@@ -1,44 +0,0 @@

CREATE TABLE "users" (
username VARCHAR(8) PRIMARY KEY,
usertype VARCHAR NOT NULL CONSTRAINT valid_usertype REFERENCES usertypes,
name VARCHAR NOT NULL CONSTRAINT require_name CHECK (name != ''),
newbie BOOLEAN NOT NULL,
email VARCHAR NOT NULL CONSTRAINT require_email CHECK (email != ''),

id INT UNIQUE CONSTRAINT require_id CHECK ((usertype != 'member' AND usertype != 'associat' AND usertype != 'staff') OR (id IS NOT NULL AND id > 0)),
course VARCHAR CONSTRAINT require_course CHECK (usertype != 'member' OR (course IS NOT NULL AND course != '')),
year VARCHAR CONSTRAINT require_year CHECK (usertype != 'member' OR year IS NOT NULL),
years_paid INT CONSTRAINT require_years_paid CHECK ((usertype != 'member' AND usertype != 'associat' AND usertype != 'staff') OR (years_paid IS NOT NULL)),

created_by VARCHAR(8) NOT NULL CONSTRAINT require_created_by CHECK (created_by != ''),
created_at TIMESTAMP(0) NOT NULL DEFAULT now(),
updated_by VARCHAR(8) NOT NULL CONSTRAINT require_updated_by CHECK (updated_by != ''),
updated_at TIMESTAMP(0) NOT NULL DEFAULT now(),

-- Following are optional or non-essential additions
birthday DATE
);

GRANT ALL ON users TO root;
GRANT SELECT ON users TO webgroup;
GRANT SELECT ON users TO www;

/*
* Set updated_at to current time for each update
*/

CREATE FUNCTION users_updated_at_stamp () RETURNS OPAQUE AS '
DECLARE
curtime timestamp;
BEGIN
curtime = ''now'';
NEW.updated_at := curtime;
RETURN NEW;
END;
' LANGUAGE 'plpgsql';
CREATE TRIGGER users_updated_at BEFORE UPDATE ON users
FOR EACH ROW EXECUTE PROCEDURE users_updated_at_stamp();


+ 0
- 20
attic/userdb_usertypes.sql Visa fil

@@ -1,21 +0,0 @@

CREATE TABLE "usertypes" (
usertype VARCHAR(8) PRIMARY KEY
);

GRANT ALL ON usertypes TO root;

INSERT INTO "usertypes" VALUES ('reserved');
INSERT INTO "usertypes" VALUES ('system');
INSERT INTO "usertypes" VALUES ('founders');
INSERT INTO "usertypes" VALUES ('member');
INSERT INTO "usertypes" VALUES ('associat');
INSERT INTO "usertypes" VALUES ('club');
INSERT INTO "usertypes" VALUES ('society');
INSERT INTO "usertypes" VALUES ('intersoc');
INSERT INTO "usertypes" VALUES ('projects');
INSERT INTO "usertypes" VALUES ('redbrick');
INSERT INTO "usertypes" VALUES ('guest');
INSERT INTO "usertypes" VALUES ('staff');
INSERT INTO "usertypes" VALUES ('dcu');

+ 1
- 1
common.css Visa fil

@@ -1,7 +1,7 @@
/*
* Style sheet for RRS.
*
* $Id$
* $Id: common.css,v 1.1 2003/03/26 10:24:19 cns Exp $
*/

body {


+ 0
- 0
continous_rrs_backup.sh Visa fil


+ 1
- 1
doc.css Visa fil

@@ -1,7 +1,7 @@
/*
* Style sheet for RRS documentation.
*
* $Id: doc.css,v 1.1 2003/03/26 10:24:19 cns Exp $
* $Id: doc.css,v 1.1 2003/03/28 16:32:38 cns Exp $
*/

body {


+ 0
- 0
fixup-rb-dcu-tree.py Visa fil


+ 1
- 1
func-spec.html Visa fil

@@ -268,7 +268,7 @@ Installation manual.</dd>

<hr>

$Id$
$Id: func-spec.html,v 1.1 2003/03/28 16:33:07 cns Exp $

</body>
</html>

+ 1
- 1
index.html Visa fil

@@ -24,7 +24,7 @@

<hr>

$Id$
$Id: index.html,v 1.1 2003/03/26 10:24:19 cns Exp $

</body>
</html>

+ 1
- 1
install-manual.html Visa fil

@@ -235,7 +235,7 @@ complete for use of RRS.</p>

<hr>

$Id$
$Id: install-manual.html,v 1.1 2003/03/28 16:33:07 cns Exp $

</body>
</html>

+ 0
- 2
newyear_ldif.py Visa fil

@@ -1,7 +1,5 @@
#!/usr/bin/python

import sys

for i in sys.stdin:
i = i.rstrip()
if i.startswith("yearsPaid:"):


+ 8
- 3
rbaccount.py Visa fil

@@ -25,7 +25,7 @@ from rbuser import *
# DATA #
#-----------------------------------------------------------------------------#

__version__ = '$Revision: 1.7 $'
__version__ = '$Revision: 1.8 $'
__author__ = 'Cillian Sharkey'

#-----------------------------------------------------------------------------#
@@ -60,6 +60,11 @@ class RBAccount:
self.cmd('%s -Rp %s %s' % (rbconfig.command_cp, rbconfig.dir_skel, usr.homeDirectory))
self.wrapper(os.chmod, usr.homeDirectory, 0711)
self.wrapper(os.symlink, webtree, '%s/public_html' % usr.homeDirectory)
#symlink vuln fix
try:
self.wrapper(os.chown, usr.homeDirectory+'/public_html', usr.uidNumber, usr.gidNumber)
except OSError:
pass

# Add a .forward file in their home directory to point to their
# alternate email address, but only if they're a dcu person and
@@ -306,14 +311,14 @@ class RBAccount:
def list_add(self, list, email):
"""Add email address to mailing list."""

fd = self.my_popen('%s/bin/add_members -r - %s' % (rbconfig.dir_mailman, self.shquote(list)))
fd = self.my_popen("su -c '%s/bin/add_members -r - %s' list" % (rbconfig.dir_mailman, self.shquote(list)))
fd.write('%s\n' % email)
self.my_close(fd)
def list_delete(self, list, email):
"""Delete email address from a mailing list."""

self.runcmd('%s/bin/remove_members %s %s' % (rbconfig.dir_mailman, self.shquote(list), self.shquote(email)))
self.runcmd("su -c '%s/bin/remove_members %s %s' list" % (rbconfig.dir_mailman, self.shquote(list), self.shquote(email)))
#--------------------------------------------------------------------#
# INTERNAL METHODS #


+ 16
- 11
rbconfig.py Visa fil

@@ -13,7 +13,7 @@ import random
# DATA #
#---------------------------------------------------------------------#

__version__ = '$Revision: 1.10 $'
__version__ = '$Revision: 1.11 $'
__author__ = 'Cillian Sharkey'

# Find out where the rrs directory is.
@@ -28,7 +28,7 @@ maxlen_group = 8
# Default LDAP account attribute values.

ldap_default_objectClass = ['posixAccount', 'top', 'shadowAccount']
ldap_default_hosts = ['carbon', 'prodigy']
ldap_default_hosts = ['paphos', 'metharme']

# RedBrick LDAP settings.

@@ -42,11 +42,16 @@ ldap_reserved_tree = 'ou=reserved,o=redbrick'

# DCU LDAP settings.

ldap_dcu_uri = 'ldap://atlas.dcu.ie'
ldap_dcu_tree = 'o=dcu'
ldap_dcu_students_tree = 'ou=students,o=dcu'
ldap_dcu_staff_tree = 'ou=staff,o=dcu'
ldap_dcu_alumni_tree = 'ou=alumni,o=dcu'
ldap_dcu_uri = 'ldap://ad.dcu.ie'
ldap_dcu_tree = 'o=ad,o=dcu,o=ie'
ldap_dcu_rbdn = 'CN=rblookup,OU=Service Accounts,DC=ad,DC=dcu,DC=ie'
ldap_dcu_rbpw = '/etc/dcu_ldap.secret'
ldap_dcu_students_tree = 'OU=Students,DC=ad,DC=dcu,DC=ie'
#'ou=students,dc=ad,dc=dcu,dc=ie'
ldap_dcu_staff_tree = 'OU=Staff,DC=ad,DC=dcu,DC=ie'
#'ou=staff,dc=ad,dc=dcu,dc=ie'
ldap_dcu_alumni_tree = 'OU=Alumni,DC=ad,DC=dcu,DC=ie'
#'ou=alumni,o=dcu'

# DNS zones RedBrick is authorative for.

@@ -67,7 +72,7 @@ dir_webtree = '/webtree'
dir_signaway_state = '/local/share/agreement/statedir'
dir_daft = '/local/share/daft'
dir_skel = '/etc/skel'
dir_mailman = '/local/mailman'
dir_mailman = '/var/lib/mailman'

# Filenames.

@@ -101,7 +106,7 @@ files_alias = (

# Commands.

command_setquota = '/usr/local/sbin/setquota'
command_setquota = '/usr/sbin/setquota'
command_chown = '/bin/chown'
command_chgrp = '/bin/chgrp'
command_cp = '/bin/cp'
@@ -190,9 +195,9 @@ def gen_passwd():
numchars = '2 3 4 5 6 7 8 9'.split()
password = ''
offset = random.randrange(2)
for c in range(6):
for c in range(8):
password += passchars[(c + offset) % 2][random.randrange(len(passchars[(c + offset) % 2]))]
offset = random.randrange(2) and 6 or 0
offset = random.randrange(2) and 8 or 0
password = password[offset:] + numchars[random.randrange(len(numchars))] + numchars[random.randrange(len(numchars))] + password[:offset]
return password



+ 1
- 1
rberror.py Visa fil

@@ -8,7 +8,7 @@
# DATA #
#-----------------------------------------------------------------------------#

__version__ = '$Revision$'
__version__ = '$Revision: 1.2 $'
__author__ = 'Cillian Sharkey'

#-----------------------------------------------------------------------------#


+ 1
- 1
rbopt.py Visa fil

@@ -8,7 +8,7 @@
# DATA #
#-----------------------------------------------------------------------------#

__version__ = '$Revision: 1.4 $'
__version__ = '$Revision: 1.5 $'
__author__ = 'Cillian Sharkey'

#-----------------------------------------------------------------------------#


+ 29
- 1
rbuser.py Visa fil

@@ -8,7 +8,7 @@
# DATA #
#-----------------------------------------------------------------------------#

__version__ = '$Revision: 1.3 $'
__version__ = '$Revision: 1.4 $'
__author__ = 'Cillian Sharkey'

#-----------------------------------------------------------------------------#
@@ -72,6 +72,34 @@ class RBUser:
#
attr_list_all = attr_list + attr_misc_list

attr_list_info = (
# Attributes associated with user to be used for the useradm info command

'uid', # Username
'usertype', # XXX NOT IN LDAP: contains primary
# usertype from objectClass list.
# Placed here so it's at start of
# output for user's information.
'newbie', # New this year (boolean)
'cn', # Full name
'altmail', # Alternate email
'id', # DCU ID number (integer)
'course', # DCU course code
'year', # DCU course year number/code
'yearsPaid', # Number of years paid (integer)
'updatedby', # Username
'updated', # Timestamp
'createdby', # Username
'created', # Timestamp
'birthday', # Date
# Attributes associated with Unix account.
'gecos',
'loginShell',
'homeDirectory',
)

# List of attributes that have multiple values (i.e. are lists).
#
attr_list_value = (


+ 4
- 4
rbuserdb.py Visa fil

@@ -31,7 +31,7 @@ from rbuser import *
# DATA #
#-----------------------------------------------------------------------------#

__version__ = '$Revision: 1.9 $'
__version__ = '$Revision: 1.10 $'
__author__ = 'Cillian Sharkey'

#-----------------------------------------------------------------------------#
@@ -1381,11 +1381,11 @@ class RBUserDB:
# rest is the course name. Uppercase course & year for
# consistency.
#
if res[1].get('l'):
if res[1].get('physicalDeliveryOfficeName'):
if override or usr.course == None:
usr.course = res[1]['l'][0][:-1].upper()
usr.course = res[1]['physicalDeliveryOfficeName'][0][:-1].upper()
if override or usr.year == None:
usr.year = res[1]['l'][0][-1].upper()
usr.year = res[1]['physicalDeliveryOfficeName'][0][-1].upper()

def set_user_dcu_staff(self, usr, res, override = 0):
"""Populate RBUser object with staff information from DCU


+ 1
- 1
rebuild_userdb_reserved.py Visa fil

@@ -25,7 +25,7 @@ from rbuserdb import *
# DATA #
#-----------------------------------------------------------------------------#

__version__ = "$Revision: 1.4 $"
__version__ = "$Revision: 1.5 $"
__author__ = "Cillian Sharkey"

# Dictionary of (name, description) pairs to add.


+ 0
- 0
remove_dcutree_ldif.py Visa fil


+ 1
- 1
rrs.cgi Visa fil

@@ -14,7 +14,7 @@ import rrs
# DATA #
#-----------------------------------------------------------------------------#

__version__ = '$Revision: 1.1 $'
__version__ = '$Revision: 1.2 $'
__author__ = 'Cillian Sharkey'

#-----------------------------------------------------------------------------#


+ 1
- 1
rrs.py Visa fil

@@ -22,7 +22,7 @@ from rbuserdb import *
# DATA #
#-----------------------------------------------------------------------------#

__version__ = '$Revision: 1.5 $'
__version__ = '$Revision: 1.6 $'
__author__ = 'Cillian Sharkey'

cmds = {


+ 1
- 1
tech-manual.html Visa fil

@@ -539,7 +539,7 @@ from the publically accessible LDAP service on <code>atlas.dcu.ie</code>.</p>

<hr>

$Id$
$Id: tech-manual.html,v 1.1 2003/03/28 16:37:38 cns Exp $

</body>
</html>

+ 1
- 1
user-manual.html Visa fil

@@ -319,7 +319,7 @@ input that was given including a time stamp.</p>

<hr>

$Id$
$Id: user-manual.html,v 1.1 2003/03/28 16:39:08 cns Exp $

</body>
</html>

+ 7
- 2
useradm.py Visa fil

@@ -27,7 +27,7 @@ from rbuserdb import *
# DATA #
#-----------------------------------------------------------------------------#

__version__ = '$Revision: 1.16 $'
__version__ = '$Revision: 1.17 $'
__author__ = 'Cillian Sharkey'

# Command name -> (command description, optional arguments)
@@ -1623,6 +1623,11 @@ Note: if you have left DCU, you need to apply for associate membership.
You can pay in person, by lodging money into our account, electronic bank
transfer, or even PayPal! All the details you need are here:

!!NOTE!!
PayPal doesn't allow the addition of Payment notes, Please email
accounts@redbrick.dcu.ie if you pay by PayPal
!!NOTE!!

http://www.redbrick.dcu.ie/help/joining/

Our bank details are:
@@ -1643,7 +1648,7 @@ Please Note!
if usr.yearsPaid == 0:
fd.write(
"""
If you do not renew by the 30th October 2016, your account will be disabled.
If you do not renew by the 30th November 2016, your account will be disabled.
Your account will remain on the system for a grace period of a year - you
just won't be able to login. So don't worry, it won't be deleted any time
soon! You can renew at any time during the year.


useradm~migrate → Visa fil

@@ -0,0 +1,24 @@
#! /usr/bin/env python

#-----------------------------------------------------------------------------#
# MODULE DESCRIPTION #
#-----------------------------------------------------------------------------#

"""Small bootstrap script for useradm."""

# RedBrick modules

import useradm

#-----------------------------------------------------------------------------#
# DATA #
#-----------------------------------------------------------------------------#

__version__ = '$Revision: 1.1 $'
__author__ = 'Cillian Sharkey'

#-----------------------------------------------------------------------------#
# MAIN #
#-----------------------------------------------------------------------------#

useradm.main()

+ 0
- 79
vote.py Visa fil

@@ -1,79 +0,0 @@
#!/usr/local/bin/python

import sys
import readline
import re
import os

from rbuser import *
from rbuserdb import *

voteregister= 'voted.txt'

#-----------------------------------------------------------------------------#
# MAIN #
#-----------------------------------------------------------------------------#

def main():
"""Program entry function."""

voted = {}

if os.path.exists(voteregister):
fd = open(voteregister, 'r')
for line in fd.readlines():
voted[line.rstrip()] = 1
fd.close()

fd = open(voteregister, 'a')

udb = RBUserDB()
udb.connect()

while 1:
usr = RBUser()
tmp = None
while not tmp:
tmp = raw_input("Please enter Username/Student ID/Student Card: ")
res = re.search(r'\D*\d{2}(\d{8})\d{3}\D*', tmp)
if res:
usr.id = int(res.group(1))
print 'CARD', usr.id
else:
res = re.search(r'^(\d{8})$', tmp)
if res:
usr.id = int(tmp)
print 'ID', usr.id
try:
if usr.id:
udb.get_user_byid(usr)
udb.show(usr)
else:
usr.uid = tmp
udb.get_user_byname(usr)
udb.show(usr)
except RBError:

print 'NO SUCH USER YOU FUCKING DICKHEAD'
else:
if voted.has_key(usr.uid):
print '\nGO FUCK YOUSELF YOU TWO-VOTING PRICK\n'
continue

if usr.usertype not in ('member', 'committe', 'staff'):
print '\nTELL THE COCKMUCH TO GET A REAL MEMBER ACCOUNT\n'
elif usr.yearsPaid <= 0:
print '\nTELL THE SCABBY BASTARD TO PISS OFF\n'
else:
fd.write('%s\n' % usr.uid)
fd.flush()
voted[usr.uid] = 1
print '\nBIG VOTE GO NOW!\n'

fd.close()
sys.exit(0)

if __name__ == "__main__":
main()


Laddar…
Avbryt
Spara