| 1 | # bgenall - Generate all bgen-generated modules
|
|---|
| 2 | #
|
|---|
| 3 | import sys
|
|---|
| 4 | import os
|
|---|
| 5 | import string
|
|---|
| 6 |
|
|---|
| 7 | def bgenone(dirname, shortname):
|
|---|
| 8 | os.chdir(dirname)
|
|---|
| 9 | print '%s:'%shortname
|
|---|
| 10 | # Sigh, we don't want to lose CVS history, so two
|
|---|
| 11 | # modules have funny names:
|
|---|
| 12 | if shortname == 'carbonevt':
|
|---|
| 13 | modulename = 'CarbonEvtscan'
|
|---|
| 14 | elif shortname == 'ibcarbon':
|
|---|
| 15 | modulename = 'IBCarbonscan'
|
|---|
| 16 | else:
|
|---|
| 17 | modulename = shortname + 'scan'
|
|---|
| 18 | try:
|
|---|
| 19 | m = __import__(modulename)
|
|---|
| 20 | except:
|
|---|
| 21 | print "Error:", shortname, sys.exc_info()[1]
|
|---|
| 22 | return 0
|
|---|
| 23 | try:
|
|---|
| 24 | m.main()
|
|---|
| 25 | except:
|
|---|
| 26 | print "Error:", shortname, sys.exc_info()[1]
|
|---|
| 27 | return 0
|
|---|
| 28 | return 1
|
|---|
| 29 |
|
|---|
| 30 | def main():
|
|---|
| 31 | success = []
|
|---|
| 32 | failure = []
|
|---|
| 33 | sys.path.insert(0, os.curdir)
|
|---|
| 34 | if len(sys.argv) > 1:
|
|---|
| 35 | srcdir = sys.argv[1]
|
|---|
| 36 | else:
|
|---|
| 37 | srcdir = os.path.join(os.path.join(sys.prefix, 'Mac'), 'Modules')
|
|---|
| 38 | srcdir = os.path.abspath(srcdir)
|
|---|
| 39 | contents = os.listdir(srcdir)
|
|---|
| 40 | for name in contents:
|
|---|
| 41 | moduledir = os.path.join(srcdir, name)
|
|---|
| 42 | scanmodule = os.path.join(moduledir, name +'scan.py')
|
|---|
| 43 | if os.path.exists(scanmodule):
|
|---|
| 44 | if bgenone(moduledir, name):
|
|---|
| 45 | success.append(name)
|
|---|
| 46 | else:
|
|---|
| 47 | failure.append(name)
|
|---|
| 48 | print 'Done:', string.join(success, ' ')
|
|---|
| 49 | if failure:
|
|---|
| 50 | print 'Failed:', string.join(failure, ' ')
|
|---|
| 51 | return 0
|
|---|
| 52 | return 1
|
|---|
| 53 |
|
|---|
| 54 | if __name__ == '__main__':
|
|---|
| 55 | rv = main()
|
|---|
| 56 | sys.exit(not rv)
|
|---|