ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/ccs/admin/layout.py
Revision: 681
Committed: 2010-07-13T02:19:33-07:00 (14 years, 11 months ago) by douglas
Content type: text/x-python
File size: 975 byte(s)
Log Message:
Add mksh to available shells; options with argparse (not sure if I like it).

File Contents

# User Rev Content
1 douglas 600 #!/usr/bin/env python
2     # CCS Computer Science
3     # Layout
4     #
5     # Douglas Thrift
6     #
7     # $Id$
8    
9     import admin
10     import common
11     import os
12     import sys
13    
14     if __name__ == '__main__':
15 douglas 681 parser = admin.parser()
16    
17     parser.add_argument('-v', '--verbose', action = 'store_true', help = 'show information about what shell paths were found')
18    
19     verbose = parser.parse_args().verbose
20 douglas 600 path = os.environ['PATH'].split(os.pathsep)
21     shells = []
22    
23     for shell in map(lambda shell: shell[0], common.SHELLS[:-1]):
24     found = False
25    
26     for directory in path:
27     _shell = os.path.join(directory, shell)
28    
29     if os.path.exists(_shell) and os.access(_shell, os.R_OK | os.X_OK):
30     shells.append(_shell)
31    
32     if verbose:
33     print shell + ': ' + _shell
34    
35     found = True
36    
37     break
38    
39     if not found:
40     admin.error('Shell not found: %s.' % shell)
41    
42     for system in common.SYSTEMS:
43     if shells == map(lambda shell: shell[1][system], common.SHELLS[:-1]):
44     print system
45    
46     sys.exit(0)
47    
48     admin.error('Unknown shell layout.')

Properties

Name Value
svn:executable *
svn:keywords Id