source: tbroadcast/v2.0.1/scripts/tbroadcast @ 255

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

Màj num version

  • Property svn:executable set to *
File size: 3.6 KB
RevLine 
[240]1#!/usr/bin/env python
[232]2#----------------------------------#
[242]3# -- Author: V. Garonne
4# -- Mail: garonne@lal.in2p3.fr
[232]5# -- Date: 08/25/2006
6# -- Name: tbroadcast
7# -- Description: main program
8#----------------------------------#
9
10import os
11import sys
[234]12import string
[232]13
14from tbroadcast import Scheduler
15
[240]16def usage():
17    print 'Usage : > tbroadcast [global options] [<command>]'
18    print '# command :'
19    print '#   <command>: command to execute'
20    print '# global options :'
[243]21    print '#   -f=<file>             : Input file'
22    print '#   -help                 : Print help'
[248]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]'
[244]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'
[248]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' 
[252]31    print '#   -version              : version of tbroadcast'       
[248]32    print '#   -silent               : Disable print'     
[242]33    print '#   -test                 : Simulate execution'
[240]34
[232]35if __name__ == '__main__':
[240]36    # Default options
[243]37    num_worker    = 20
38    command       = ''
[255]39    version       = 'v2.0.1'
[243]40    test          = False
41    check         = False
42    print_graph   = False
43    local         = False
44    ignore_cycles = False
[244]45    silent        = False
[245]46    perf          = False     
[243]47    output        = None
[244]48    error         = None
[243]49    file          = None
[240]50    for arg in sys.argv[1:len(sys.argv)]:           
[232]51         if arg[0]=='-':
[240]52             option = string.split(arg,'=')[0]
[252]53             if option == '-version':
54                 print version
55                 sys.exit(-1)
[240]56             if option == '-nb':
[243]57                num_worker = int (string.split(arg,'=')[1]) 
58             if option == '-f':
59                file = string.split(arg,'=')[1]
[245]60             if option == '-perf':
[248]61                perf = string.split(arg,'=')[1]
[243]62             if option == '-output':
63                output = string.split(arg,'=')[1]
[244]64             if option == '-error':
65                error = string.split(arg,'=')[1]
[243]66             if option == '-local':
67                 local= True
68             if option == '-ignore_cycles':             
69                 ignore_cycles = True
[244]70             if option == '-silent':             
[245]71                 silent = True                 
[243]72             if option == '-help':   
73                  usage()
74                  sys.exit(-1)     
75                             
76             if option == '-test':
77                     test = True   
[242]78             elif option == '-check':
[243]79                     check = True   
[242]80             elif option == '-print':
[243]81                     print_graph = True   
[232]82         else:
83              command = arg
[240]84
[245]85    master = Scheduler (num_workers=num_worker, file=file, ignore_cycles=ignore_cycles, local=local, output=output, error=error, silent=silent, perf=perf)
[242]86    if test:
87        master.simulate_execution()
88    elif check:
89        master.check_execution (package=master.get_current_package())   
90    elif print_graph:
91        master.print_dependencies ()
92    else:
93        master.execute_all (command)
[232]94    sys.exit(-1);
[255]95#--------- EoF --------#
Note: See TracBrowser for help on using the repository browser.