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 |
|
|
path = os.environ['PATH'].split(os.pathsep) |
16 |
|
|
shells = [] |
17 |
|
|
verbose = bool(sys.argv[1:]) |
18 |
|
|
|
19 |
|
|
for shell in map(lambda shell: shell[0], common.SHELLS[:-1]): |
20 |
|
|
found = False |
21 |
|
|
|
22 |
|
|
for directory in path: |
23 |
|
|
_shell = os.path.join(directory, shell) |
24 |
|
|
|
25 |
|
|
if os.path.exists(_shell) and os.access(_shell, os.R_OK | os.X_OK): |
26 |
|
|
shells.append(_shell) |
27 |
|
|
|
28 |
|
|
if verbose: |
29 |
|
|
print shell + ': ' + _shell |
30 |
|
|
|
31 |
|
|
found = True |
32 |
|
|
|
33 |
|
|
break |
34 |
|
|
|
35 |
|
|
if not found: |
36 |
|
|
admin.error('Shell not found: %s.' % shell) |
37 |
|
|
|
38 |
|
|
for system in common.SYSTEMS: |
39 |
|
|
if shells == map(lambda shell: shell[1][system], common.SHELLS[:-1]): |
40 |
|
|
print system |
41 |
|
|
|
42 |
|
|
sys.exit(0) |
43 |
|
|
|
44 |
|
|
admin.error('Unknown shell layout.') |