#!/usr/bin/env python
#----------------------------------#
# -- Author: V.Garonne
# -- Date: 08/25/2006 
# -- Name: tbroadcast
# -- Description: main program
#----------------------------------#

import os
import sys
import string

from tbroadcast import Scheduler

def usage():
    print 'Usage : > tbroadcast [global options] [<command>]'
    print '# command :'
    print '#   <command>: command to execute'
    print '# global options :'
    print '#   -nb=<num_worker>]                  : Total number of threads'
    print '#   -help]                             : Print help'

if __name__ == '__main__':
    # Default options
    num_worker = 20
    command    = ''    
    for arg in sys.argv[1:len(sys.argv)]:            
         if arg[0]=='-':
             option = string.split(arg,'=')[0]
             if option == '-nb':
                num_worker = int (string.split(arg,'=')[1])         
             else:
                usage()
                sys.exit(-1)   
                
         else:
              command = arg

    master = Scheduler (num_workers=num_worker)        
    master.execute_all (command)

    sys.exit(-1);
#--------- EoF --------#    