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