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 '# -f=<file> : Input file' |
---|
22 | print '# -help : Print help' |
---|
23 | print '# -local : Reach packages only within the current project' |
---|
24 | print '# -global : Reach packages in all CMTPATH/CMTPROJECTPATH items' |
---|
25 | print '# -ignore_cycles : Suppress automatically the cycles' |
---|
26 | print '# -nb=<num_worker> : Change the total number of threads[default is 20]' |
---|
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 '# -perf=<file> : Store for each package the time for executing the command in the <file> file' |
---|
30 | print '# -print : Print dependencies for each package' |
---|
31 | print '# -version : version of tbroadcast' |
---|
32 | print '# -silent : Disable print' |
---|
33 | print '# -test : Simulate execution' |
---|
34 | |
---|
35 | if __name__ == '__main__': |
---|
36 | # Default options |
---|
37 | num_worker = 20 |
---|
38 | command = '' |
---|
39 | version = 'HEAD' |
---|
40 | test = False |
---|
41 | check = False |
---|
42 | print_graph = False |
---|
43 | local = False |
---|
44 | ignore_cycles = False |
---|
45 | silent = False |
---|
46 | perf = False |
---|
47 | output = None |
---|
48 | error = None |
---|
49 | file = None |
---|
50 | |
---|
51 | if len(sys.argv) == 1: |
---|
52 | test = True |
---|
53 | else: |
---|
54 | for arg in sys.argv[1:len(sys.argv)]: |
---|
55 | if arg[0]=='-': |
---|
56 | option = string.split(arg,'=')[0] |
---|
57 | if option == '-version': |
---|
58 | print version |
---|
59 | sys.exit(-1) |
---|
60 | if option == '-nb': |
---|
61 | num_worker = int (string.split(arg,'=')[1]) |
---|
62 | if option == '-f': |
---|
63 | file = string.split(arg,'=')[1] |
---|
64 | if option == '-perf': |
---|
65 | perf = string.split(arg,'=')[1] |
---|
66 | if option == '-output': |
---|
67 | output = string.split(arg,'=')[1] |
---|
68 | if option == '-error': |
---|
69 | error = string.split(arg,'=')[1] |
---|
70 | if option == '-local': |
---|
71 | local= True |
---|
72 | if option == '-ignore_cycles': |
---|
73 | ignore_cycles = True |
---|
74 | if option == '-silent': |
---|
75 | silent = True |
---|
76 | if option == '-help': |
---|
77 | usage() |
---|
78 | sys.exit(-1) |
---|
79 | |
---|
80 | if option == '-test': |
---|
81 | test = True |
---|
82 | elif option == '-check': |
---|
83 | check = True |
---|
84 | elif option == '-print': |
---|
85 | print_graph = True |
---|
86 | else: |
---|
87 | command = arg |
---|
88 | |
---|
89 | master = Scheduler (num_workers=num_worker, file=file, ignore_cycles=ignore_cycles, local=local, output=output, error=error, silent=silent, perf=perf) |
---|
90 | if test: |
---|
91 | master.simulate_execution() |
---|
92 | elif check: |
---|
93 | master.check_execution (package=master.get_current_package()) |
---|
94 | elif print_graph: |
---|
95 | master.print_dependencies () |
---|
96 | else: |
---|
97 | master.execute_all (command) |
---|
98 | sys.exit(-1); |
---|
99 | #--------- EoF --------# |
---|