1 |
douglas |
587 |
#!/usr/bin/env python |
2 |
|
|
# CCS Computer Science |
3 |
douglas |
592 |
# Change Full Name |
4 |
douglas |
587 |
# |
5 |
|
|
# Douglas Thrift |
6 |
|
|
# |
7 |
|
|
# $Id$ |
8 |
|
|
|
9 |
douglas |
593 |
from __future__ import with_statement |
10 |
douglas |
591 |
import admin |
11 |
douglas |
590 |
import common |
12 |
douglas |
593 |
import ldap |
13 |
douglas |
680 |
import MySQLdb |
14 |
douglas |
598 |
import psycopg2 |
15 |
douglas |
587 |
import re |
16 |
douglas |
593 |
import sys |
17 |
douglas |
598 |
import users |
18 |
douglas |
587 |
|
19 |
|
|
if __name__ == '__main__': |
20 |
|
|
try: |
21 |
douglas |
598 |
user = '' |
22 |
|
|
string = re.compile('^[a-z0-9]{1,16}$') |
23 |
douglas |
587 |
|
24 |
douglas |
598 |
while string.match(user) is None: |
25 |
|
|
user = raw_input('User Name: ') |
26 |
douglas |
597 |
|
27 |
douglas |
598 |
if users.user(user): |
28 |
|
|
admin.error('User exists: %s.' % user) |
29 |
douglas |
587 |
|
30 |
douglas |
598 |
name = '' |
31 |
|
|
string = re.compile('^[^:]+$') |
32 |
douglas |
593 |
|
33 |
douglas |
598 |
while string.match(name) is None: |
34 |
|
|
name = raw_input('Full Name: ') |
35 |
|
|
|
36 |
|
|
password = common.new_password() |
37 |
|
|
|
38 |
douglas |
591 |
if admin.master(): |
39 |
douglas |
598 |
admin.adduser(user, name, password) |
40 |
|
|
|
41 |
|
|
admin.run(common.add_all(user, name, password)) |
42 |
|
|
except (common.PasswordError, ldap.LDAPError, OSError, MySQLdb.MySQLError, psycopg2.Error, psycopg2.Warning), error: |
43 |
douglas |
593 |
admin.error(error) |
44 |
douglas |
587 |
except (EOFError, KeyboardInterrupt): |
45 |
douglas |
592 |
admin.eof() |