Ignore:
Timestamp:
Sep 7, 2009, 2:43:28 PM (15 years ago)
Author:
rybkin
Message:

Version v2.0.6_rc4 from Igor Kachaev

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tbroadcast/HEAD/scripts/tbroadcast

    r508 r517  
    33# -- Author: V. Garonne
    44# -- Mail: garonne@lal.in2p3.fr
    5 # -- Date: 08/25/2006 
     5# -- Date: 08/25/2006
    66# -- Name: tbroadcast
    77# -- Description: main program
    88#----------------------------------#
    99
    10 import os
    1110import sys
    12 import string
     11import time
    1312
    1413def 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'
     14    print """
     15Usage: tbroadcast [global options] [<command>]
     16#
     17# <command> is executed in <package>/cmt
     18#
     19# global options :
     20#   -help                 : Print help
     21#   -local                : Reach packages only within the current project
     22#                         : if not specified reach packages in all CMTPATH/CMTPROJECTPATH items
     23#   -ignore[_cycles]      : Suppress automatically the cycles
     24#   -sort                 : Compile packages in order of use count, most significant first
     25#   -nb=<num_worker>      : Change the total number of threads[default is 20]
     26#   -output=<location>    : Output directory to store output files with the form <package>_output.log
     27#   -error=<location>     : Output directory to store error output with the form <package>_error.log
     28#   -perf=<file>          : Store for each package the time for executing the command in the <file> file
     29#   -make=<file>          : Generate a recursive Make, [see: http://www.tip.net.au/~millerp/rmch/recu-make-cons-harm.html]
     30#   -print                : Print dependencies for each package and exit
     31#   -version              : Print version of tbroadcast and exit
     32#   -test                 : Simulate execution and exit
     33#   -                     : is accepted and does nothing
     34#
     35# Example:
     36#   tbroadcast -local -ignore -nb=4 'make -j6'
     37"""
     38
     39# Unused options
     40#   -f=<file>             : Input file (option for debug only)
     41#   -no_keep_going        : Exit after the first exit code > 1 found and return it in the shell
     42#   -silent               : Disable print
    3443
    3544if __name__ == '__main__':
     
    3847    cur_version = sys.version_info
    3948
    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"
     49    if not (cur_version[0] > req_version[0] or (cur_version[0] == req_version[0] and cur_version[1] >= req_version[1])):
     50        print "tbroadcast: must use python 2.5 or greater"
     51        sys.exit(-1)
    4252
    4353    from tbroadcast import Scheduler
     
    4656    num_worker    = 20
    4757    command       = ''
    48     version       = 'v2.0.4'
     58    version       = 'v2.0.7'
    4959    test          = False
    50     check         = False
    5160    print_graph   = False
    5261    local         = False
    5362    ignore_cycles = False
    5463    silent        = False
    55     perf          = False     
     64    perf          = False
     65    sort          = False
    5666    output        = None
    5767    error         = None
     
    6070    makefile      = 'Makefile'
    6171    keep_going    = True
    62    
     72
    6373    if len(sys.argv) == 1:
    64         test = True
    65     else:       
    66         for arg in sys.argv[1:len(sys.argv)]:           
     74        usage()
     75        sys.exit(-1)
     76    else:
     77        for arg in sys.argv[1:len(sys.argv)]:
     78#            print "Argument is",arg
    6779             if arg[0]=='-':
    68                  option = string.split(arg,'=')[0]
     80                 option = arg.split('=')[0]
    6981                 if option == '-version':
    7082                     print version
    7183                     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':             
     84                 elif option == '-nb':
     85                     num_worker = int (arg.split('=')[1])
     86                 elif option == '-f':
     87                     file = arg.split('=')[1]
     88                 elif option == '-perf':
     89                     perf = arg.split('=')[1]
     90                 elif option == '-output':
     91                     output = arg.split('=')[1]
     92                 elif option == '-error':
     93                     error = arg.split('=')[1]
     94                 elif option == '-local':
     95                     local = True
     96                 elif option == '-sort':
     97                     sort = True
     98                 elif option[:7] == '-ignore':
    8599                     ignore_cycles = True
    86                  if option == '-silent':             
    87                      silent = True       
    88                  if option == '-no_keep_going':             
     100                 elif option == '-silent':
     101                     silent = True
     102                 elif option == '-no_keep_going':
    89103                     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   
     104                 elif option == '-help':
     105                     usage()
     106                     sys.exit(-1)
     107                 elif option == '-test':
     108                     test = True
    99109                 elif option == '-print':
    100                          print_graph = True   
    101                  elif option == '-make':       
     110                     print_graph = True
     111                 elif option == '-make':
    102112                     make     = True
    103                      makefile = string.split(arg,'=')[1]
     113                     makefile = arg.split('=')[1]
     114                 elif option == '-':
     115                     pass
     116                 else:
     117                     print 'tbroadcast: bad option "%s", use -help for help' % option
     118                     sys.exit(-1)
    104119             else:
    105                   command = arg
     120                 command = arg
    106121
    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)
     122#   print "End of arguments. Command to execute", command
     123
     124    if not (command or test or print_graph):
     125        print 'tbroadcast: no command specified'
     126        sys.exit(-1)
     127
     128    master = Scheduler (num_workers=num_worker, file=file, ignore_cycles=ignore_cycles,
     129                        local=local, output=output, error=error, silent=silent, perf=perf,
     130                        keep_going=keep_going, sort=sort)
    110131    if test:
    111132        master.simulate_execution()
    112     elif check:
    113         master.check_execution (package=master.get_current_package())   
    114133    elif print_graph:
    115         master.print_dependencies ()
     134        master.print_dependencies()
    116135    elif make:
    117         master.generate_make (makefile, command)   
     136        master.generate_make (makefile, command)
    118137    else:
     138        print 'tbroadcast: start of job at', time.strftime('%d-%b-%Y %T')
    119139        master.execute_all (command)
    120     #sys.exit(-1);
     140        print 'tbroadcast: end of job at', time.strftime('%d-%b-%Y %T')
     141    #sys.exit(-1)
    121142#--------- EoF --------#
Note: See TracChangeset for help on using the changeset viewer.