ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/ccs/admin/secret.py
Revision: 687
Committed: 2010-07-18T03:39:30-07:00 (14 years, 11 months ago) by douglas
Content type: text/x-python
File size: 636 byte(s)
Log Message:
Use optparse instead of argparse. Man pages!

File Contents

# User Rev Content
1 douglas 606 #!/usr/bin/env python
2     # CCS Computer Science
3     # Secret Password
4     #
5     # Douglas Thrift
6     #
7     # $Id$
8    
9     import admin
10     import common
11     import os
12    
13     if __name__ == '__main__':
14 douglas 681 parser = admin.parser()
15 douglas 606
16 douglas 687 parser.add_option('-f', '--force', action = 'store_true', help = 'prompt for a new secret even if one already exists')
17 douglas 606
18 douglas 687 if parser.parse_args()[0].force or not os.path.exists(admin.SECRET):
19 douglas 681 try:
20     password = common.new_password()
21    
22     os.umask(0077)
23    
24     with open(admin.SECRET, 'wb') as secret:
25     secret.write(password)
26     except (common.PasswordError, IOError), error:
27     admin.error(error)
28     except (EOFError, KeyboardInterrupt):
29     admin.eof()

Properties

Name Value
svn:executable *
svn:keywords Id