ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/ccs/admin/adduser.py
Revision: 680
Committed: 2010-07-02T19:40:04-07:00 (15 years ago) by douglas
Content type: text/x-python
File size: 922 byte(s)
Log Message:
Everything is using Python 2.6 now!

File Contents

# User Rev Content
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()

Properties

Name Value
svn:executable *
svn:keywords Id