source: tbroadcast/v2.0.4/scripts/tbroadcast @ 396

Last change on this file since 396 was 396, checked in by garonne, 17 years ago

add release number

  • Property svn:executable set to *
File size: 4.5 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
14from tbroadcast import Scheduler
15
16def 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 '#   -make=<file>          : Generate a recursive Make, [see: http://www.tip.net.au/~millerp/rmch/recu-make-cons-harm.html]'
27    print '#   -nb=<num_worker>      : Change the total number of threads[default is 20]'
28    print '#   -no_keep_going        : Exit after the first exit code > 1 found and return it in the shell'
29    print '#   -output=<location>    : Output directory to store output files with the form <package>_output.log'
30    print '#   -error=<location>     : Output directory to store error output with the form <package>_error.log'
31    print '#   -perf=<file>          : Store for each package the time for executing the command in the <file> file'
32    print '#   -print                : Print dependencies for each package' 
33    print '#   -version              : version of tbroadcast'       
34    print '#   -silent               : Disable print'     
35    print '#   -test                 : Simulate execution'
36
37if __name__ == '__main__':
38    # Default options
39    num_worker    = 20
40    command       = ''
41    version       = 'v2.0.4'
42    test          = False
43    check         = False
44    print_graph   = False
45    local         = False
46    ignore_cycles = False
47    silent        = False
48    perf          = False     
49    output        = None
50    error         = None
51    file          = None
52    make          = None
53    makefile      = 'Makefile'
54    keep_going    = True
55   
56    if len(sys.argv) == 1:
57        test = True
58    else:       
59        for arg in sys.argv[1:len(sys.argv)]:           
60             if arg[0]=='-':
61                 option = string.split(arg,'=')[0]
62                 if option == '-version':
63                     print version
64                     sys.exit(-1)
65                 if option == '-nb':
66                    num_worker = int (string.split(arg,'=')[1]) 
67                 if option == '-f':
68                    file = string.split(arg,'=')[1]
69                 if option == '-perf':
70                    perf = string.split(arg,'=')[1]
71                 if option == '-output':
72                    output = string.split(arg,'=')[1]
73                 if option == '-error':
74                    error = string.split(arg,'=')[1]
75                 if option == '-local':
76                     local= True
77                 if option == '-ignore_cycles':             
78                     ignore_cycles = True
79                 if option == '-silent':             
80                     silent = True       
81                 if option == '-no_keep_going':             
82                     keep_going = False
83                             
84                 if option == '-help':   
85                      usage()
86                      sys.exit(-1)     
87                                 
88                 if option == '-test':
89                         test = True   
90                 elif option == '-check':
91                         check = True   
92                 elif option == '-print':
93                         print_graph = True   
94                 elif option == '-make':       
95                     make     = True
96                     makefile = string.split(arg,'=')[1]
97             else:
98                  command = arg
99
100    master = Scheduler (num_workers=num_worker, file=file, ignore_cycles=ignore_cycles, 
101                        local=local, output=output, error=error, silent=silent, perf=perf, 
102                        keep_going=keep_going)
103    if test:
104        master.simulate_execution()
105    elif check:
106        master.check_execution (package=master.get_current_package())   
107    elif print_graph:
108        master.print_dependencies ()
109    elif make:
110        master.generate_make (makefile, command)   
111    else:
112        master.execute_all (command)
113    #sys.exit(-1);
114#--------- EoF --------#
Note: See TracBrowser for help on using the repository browser.