source: tbroadcast/v2.0.3/scripts/tbroadcast @ 309

Last change on this file since 309 was 309, checked in by garonne, 18 years ago

add version number

  • Property svn:executable set to *
File size: 4.2 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 '#   -output=<location>    : Output directory to store output files with the form <package>_output.log'
29    print '#   -error=<location>     : Output directory to store error output with the form <package>_error.log'
30    print '#   -perf=<file>          : Store for each package the time for executing the command in the <file> file'
31    print '#   -print                : Print dependencies for each package' 
32    print '#   -version              : version of tbroadcast'       
33    print '#   -silent               : Disable print'     
34    print '#   -test                 : Simulate execution'
35
36if __name__ == '__main__':
37    # Default options
38    num_worker    = 20
39    command       = ''
40    version       = 'v2.0.3'
41    test          = False
42    check         = False
43    print_graph   = False
44    local         = False
45    ignore_cycles = False
46    silent        = False
47    perf          = False     
48    output        = None
49    error         = None
50    file          = None
51    make          = None
52    makefile      = 'Makefile'
53   
54    if len(sys.argv) == 1:
55        test = True
56    else:       
57        for arg in sys.argv[1:len(sys.argv)]:           
58             if arg[0]=='-':
59                 option = string.split(arg,'=')[0]
60                 if option == '-version':
61                     print version
62                     sys.exit(-1)
63                 if option == '-nb':
64                    num_worker = int (string.split(arg,'=')[1]) 
65                 if option == '-f':
66                    file = string.split(arg,'=')[1]
67                 if option == '-perf':
68                    perf = string.split(arg,'=')[1]
69                 if option == '-output':
70                    output = string.split(arg,'=')[1]
71                 if option == '-error':
72                    error = string.split(arg,'=')[1]
73                 if option == '-local':
74                     local= True
75                 if option == '-ignore_cycles':             
76                     ignore_cycles = True
77                 if option == '-silent':             
78                     silent = True                 
79                 if option == '-help':   
80                      usage()
81                      sys.exit(-1)     
82                                 
83                 if option == '-test':
84                         test = True   
85                 elif option == '-check':
86                         check = True   
87                 elif option == '-print':
88                         print_graph = True   
89                 elif option == '-make':       
90                     make     = True
91                     makefile = string.split(arg,'=')[1]
92             else:
93                  command = arg
94
95    master = Scheduler (num_workers=num_worker, file=file, ignore_cycles=ignore_cycles, local=local, output=output, error=error, silent=silent, perf=perf)
96    if test:
97        master.simulate_execution()
98    elif check:
99        master.check_execution (package=master.get_current_package())   
100    elif print_graph:
101        master.print_dependencies ()
102    elif make:
103        master.generate_make (makefile, command)   
104    else:
105        master.execute_all (command)
106    sys.exit(-1);
107#--------- EoF --------#
Note: See TracBrowser for help on using the repository browser.