[240] | 1 | #!/usr/bin/env python |
---|
[232] | 2 | #----------------------------------# |
---|
[242] | 3 | # -- Author: V. Garonne |
---|
| 4 | # -- Mail: garonne@lal.in2p3.fr |
---|
[232] | 5 | # -- Date: 08/25/2006 |
---|
| 6 | # -- Name: tbroadcast |
---|
| 7 | # -- Description: main program |
---|
| 8 | #----------------------------------# |
---|
| 9 | |
---|
| 10 | import os |
---|
| 11 | import sys |
---|
[234] | 12 | import string |
---|
[232] | 13 | |
---|
| 14 | from tbroadcast import Scheduler |
---|
| 15 | |
---|
[240] | 16 | def usage(): |
---|
| 17 | print 'Usage : > tbroadcast [global options] [<command>]' |
---|
| 18 | print '# command :' |
---|
| 19 | print '# <command>: command to execute' |
---|
| 20 | print '# global options :' |
---|
[243] | 21 | print '# -check : Check execution (deadlocks)' |
---|
| 22 | print '# -f=<file> : Input file' |
---|
| 23 | print '# -help : Print help' |
---|
| 24 | print '# -local : ' |
---|
| 25 | print '# -ignore_cycles : ' |
---|
| 26 | print '# -nb=<num_worker> : Total number of threads' |
---|
[244] | 27 | print '# -output=<location> : Output directory to store output files with the form <package>_output.log' |
---|
| 28 | print '# -error=<location> : Output directory to store error output with the form <package>_error.log' |
---|
[243] | 29 | print '# -print : Print dependency graph' |
---|
[242] | 30 | print '# -test : Simulate execution' |
---|
[240] | 31 | |
---|
[232] | 32 | if __name__ == '__main__': |
---|
[240] | 33 | # Default options |
---|
[243] | 34 | num_worker = 20 |
---|
| 35 | command = '' |
---|
| 36 | test = False |
---|
| 37 | check = False |
---|
| 38 | print_graph = False |
---|
| 39 | local = False |
---|
| 40 | ignore_cycles = False |
---|
[244] | 41 | silent = False |
---|
[243] | 42 | output = None |
---|
[244] | 43 | error = None |
---|
[243] | 44 | file = None |
---|
[240] | 45 | for arg in sys.argv[1:len(sys.argv)]: |
---|
[232] | 46 | if arg[0]=='-': |
---|
[240] | 47 | option = string.split(arg,'=')[0] |
---|
| 48 | if option == '-nb': |
---|
[243] | 49 | num_worker = int (string.split(arg,'=')[1]) |
---|
| 50 | if option == '-f': |
---|
| 51 | file = string.split(arg,'=')[1] |
---|
| 52 | if option == '-output': |
---|
| 53 | output = string.split(arg,'=')[1] |
---|
[244] | 54 | if option == '-error': |
---|
| 55 | error = string.split(arg,'=')[1] |
---|
[243] | 56 | if option == '-local': |
---|
| 57 | local= True |
---|
| 58 | if option == '-ignore_cycles': |
---|
| 59 | ignore_cycles = True |
---|
[244] | 60 | if option == '-silent': |
---|
| 61 | silent = True |
---|
| 62 | |
---|
[243] | 63 | if option == '-help': |
---|
| 64 | usage() |
---|
| 65 | sys.exit(-1) |
---|
| 66 | |
---|
| 67 | if option == '-test': |
---|
| 68 | test = True |
---|
[242] | 69 | elif option == '-check': |
---|
[243] | 70 | check = True |
---|
[242] | 71 | elif option == '-print': |
---|
[243] | 72 | print_graph = True |
---|
[232] | 73 | else: |
---|
| 74 | command = arg |
---|
[240] | 75 | |
---|
[244] | 76 | master = Scheduler (num_workers=num_worker, file=file, ignore_cycles=ignore_cycles, local=local, output=output, error=error, silent=silent) |
---|
[242] | 77 | if test: |
---|
| 78 | master.simulate_execution() |
---|
| 79 | elif check: |
---|
| 80 | master.check_execution (package=master.get_current_package()) |
---|
| 81 | elif print_graph: |
---|
| 82 | master.print_dependencies () |
---|
| 83 | else: |
---|
| 84 | master.execute_all (command) |
---|
[232] | 85 | sys.exit(-1); |
---|
[242] | 86 | #--------- EoF --------# |
---|