source: tbroadcast/v2.0.6/scripts/tbroadcast

Last change on this file was 511, checked in by garonne, 16 years ago

upgraded version to 2.0.6

  • Property svn:executable set to *
File size: 4.8 KB
Line 
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
10import os
11import sys
12import string
13
14def usage():
15 print 'Usage : > tbroadcast [global options] [<command>]'
16 print '# command :'
17 print '# <command>: command to execute'
18 print '# global options :'
19 print '# -f=<file> : Input file'
20 print '# -help : Print help'
21 print '# -local : Reach packages only within the current project'
22 print '# -global : Reach packages in all CMTPATH/CMTPROJECTPATH items'
23 print '# -ignore_cycles : Suppress automatically the cycles'
24 print '# -make=<file> : Generate a recursive Make, [see: http://www.tip.net.au/~millerp/rmch/recu-make-cons-harm.html]'
25 print '# -nb=<num_worker> : Change the total number of threads[default is 20]'
26 print '# -no_keep_going : Exit after the first exit code > 1 found and return it in the shell'
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
35if __name__ == '__main__':
36 # check python version
37 req_version = (2,5)
38 cur_version = sys.version_info
39
40 if not (cur_version[0] > req_version[0] or (cur_version[0] == req_version[0] and cur_version[1] >= req_version[1])):
41 raise "must use python 2.5 or greater"
42
43 from tbroadcast import Scheduler
44
45 # Default options
46 num_worker = 20
47 command = ''
48 version = 'v2.0.6'
49 test = False
50 check = False
51 print_graph = False
52 local = False
53 ignore_cycles = False
54 silent = False
55 perf = False
56 output = None
57 error = None
58 file = None
59 make = None
60 makefile = 'Makefile'
61 keep_going = True
62
63 if len(sys.argv) == 1:
64 test = True
65 else:
66 for arg in sys.argv[1:len(sys.argv)]:
67 if arg[0]=='-':
68 option = string.split(arg,'=')[0]
69 if option == '-version':
70 print version
71 sys.exit(-1)
72 if option == '-nb':
73 num_worker = int (string.split(arg,'=')[1])
74 if option == '-f':
75 file = string.split(arg,'=')[1]
76 if option == '-perf':
77 perf = string.split(arg,'=')[1]
78 if option == '-output':
79 output = string.split(arg,'=')[1]
80 if option == '-error':
81 error = string.split(arg,'=')[1]
82 if option == '-local':
83 local= True
84 if option == '-ignore_cycles':
85 ignore_cycles = True
86 if option == '-silent':
87 silent = True
88 if option == '-no_keep_going':
89 keep_going = False
90
91 if option == '-help':
92 usage()
93 sys.exit(-1)
94
95 if option == '-test':
96 test = True
97 elif option == '-check':
98 check = True
99 elif option == '-print':
100 print_graph = True
101 elif option == '-make':
102 make = True
103 makefile = string.split(arg,'=')[1]
104 else:
105 command = arg
106
107 master = Scheduler (num_workers=num_worker, file=file, ignore_cycles=ignore_cycles,
108 local=local, output=output, error=error, silent=silent, perf=perf,
109 keep_going=keep_going)
110 if test:
111 master.simulate_execution()
112 elif check:
113 master.check_execution (package=master.get_current_package())
114 elif print_graph:
115 master.print_dependencies ()
116 elif make:
117 master.generate_make (makefile, command)
118 else:
119 master.execute_all (command)
120 #sys.exit(-1);
121#--------- EoF --------#
Note: See TracBrowser for help on using the repository browser.