Changeset 517 for tbroadcast/HEAD/scripts
- Timestamp:
- Sep 7, 2009, 2:43:28 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tbroadcast/HEAD/scripts/tbroadcast
r508 r517 3 3 # -- Author: V. Garonne 4 4 # -- Mail: garonne@lal.in2p3.fr 5 # -- Date: 08/25/2006 5 # -- Date: 08/25/2006 6 6 # -- Name: tbroadcast 7 7 # -- Description: main program 8 8 #----------------------------------# 9 9 10 import os11 10 import sys 12 import string11 import time 13 12 14 13 def 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 """ 15 Usage: 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 34 43 35 44 if __name__ == '__main__': … … 38 47 cur_version = sys.version_info 39 48 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) 42 52 43 53 from tbroadcast import Scheduler … … 46 56 num_worker = 20 47 57 command = '' 48 version = 'v2.0. 4'58 version = 'v2.0.7' 49 59 test = False 50 check = False51 60 print_graph = False 52 61 local = False 53 62 ignore_cycles = False 54 63 silent = False 55 perf = False 64 perf = False 65 sort = False 56 66 output = None 57 67 error = None … … 60 70 makefile = 'Makefile' 61 71 keep_going = True 62 72 63 73 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 67 79 if arg[0]=='-': 68 option = string.split(arg,'=')[0]80 option = arg.split('=')[0] 69 81 if option == '-version': 70 82 print version 71 83 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': 85 99 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': 89 103 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 99 109 elif option == '-print': 100 print_graph = True101 elif option == '-make': 110 print_graph = True 111 elif option == '-make': 102 112 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) 104 119 else: 105 120 command = arg 106 121 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) 110 131 if test: 111 132 master.simulate_execution() 112 elif check:113 master.check_execution (package=master.get_current_package())114 133 elif print_graph: 115 master.print_dependencies 134 master.print_dependencies() 116 135 elif make: 117 master.generate_make (makefile, command) 136 master.generate_make (makefile, command) 118 137 else: 138 print 'tbroadcast: start of job at', time.strftime('%d-%b-%Y %T') 119 139 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) 121 142 #--------- EoF --------#
Note: See TracChangeset
for help on using the changeset viewer.