Ignore:
Timestamp:
Aug 28, 2006, 1:20:02 PM (18 years ago)
Author:
garonne
Message:

improve tbroadcast script

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tbroadcast/v2/scripts/tbroadcast

    r237 r240  
    1 #!/usr/bin/env python2
     1#!/usr/bin/env python
    22#----------------------------------#
    33# -- Author: V.Garonne
     
    1313from tbroadcast import Scheduler
    1414
     15def usage():
     16    print 'Usage : > tbroadcast [global options] [<command>]'
     17    print '# command :'
     18    print '#   <command>: command to execute'
     19    print '# global options :'
     20    print '#   -nb=<num_worker>]                  : Total number of threads'
     21    print '#   -help]                             : Print help'
     22
    1523if __name__ == '__main__':
    16 
    17     if len(sys.argv) ==1 :
    18         print 'Usage : > tbroadcast [-nb=<num_worker>] <command>'
    19         sys.exit(-1)   
    20     num_worker = 20   
    21     for arg in sys.argv:           
     24    # Default options
     25    num_worker = 20
     26    command    = ''   
     27    for arg in sys.argv[1:len(sys.argv)]:           
    2228         if arg[0]=='-':
    23              if string.split(arg,'=')[0] == '-nb':
     29             option = string.split(arg,'=')[0]
     30             if option == '-nb':
    2431                num_worker = int (string.split(arg,'=')[1])         
     32             else:
     33                usage()
     34                sys.exit(-1)   
     35               
    2536         else:
    2637              command = arg
    27                      
    28     # we create a pool of num_worker worker threads
    29     #print 'num_worker', num_worker , command
     38
    3039    master = Scheduler (num_workers=num_worker)       
    3140    master.execute_all (command)
Note: See TracChangeset for help on using the changeset viewer.