#!/usr/bin/env python # CCS Computer Science # Layout # # Douglas Thrift # # $Id$ import admin import common import os if __name__ == '__main__': parser = admin.parser(description = 'List CCS CS Lab shell layout') parser.add_option('-v', '--verbose', action = 'store_true', help = 'show information about what shell paths were found') verbose = parser.parse_args()[0].verbose path = os.environ['PATH'].split(os.pathsep) _shells = map(lambda shell: shell[0], common.SHELLS[:-1]) shells = [] if verbose: format = '%%%us: %%s' % ((len(max(_shells, key = len)) + 1) / 2 * 2) for shell in _shells: found = False for directory in path: _shell = os.path.join(directory, shell) if os.path.exists(_shell) and os.access(_shell, os.R_OK | os.X_OK): shells.append(_shell) if verbose: print format % (shell, _shell) found = True break if not found: admin.error('Shell not found: %s.' % shell) for system in common.SYSTEMS: if shells == map(lambda shell: shell[1][system], common.SHELLS[:-1]): print system parser.exit() admin.error('Unknown shell layout.') # vim: noexpandtab tabstop=4