Changeset 240 for tbroadcast
- Timestamp:
- Aug 28, 2006, 1:20:02 PM (18 years ago)
- Location:
- tbroadcast/v2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
tbroadcast/v2/python/tbroadcast.py
r239 r240 49 49 def instanciate_packages(self): 50 50 # We create the schedule of the work units 51 print '# First, we initialize the DAG by parsing cmt show uses (takes a certain time... huk should be improved asap)'51 print '# First, we initialize the DAG by parsing cmt show uses' 52 52 cmd = 'cmt show uses' 53 53 status, output = commands.getstatusoutput (cmd) … … 117 117 sys.exit(-1) 118 118 self.packages[result[0]]['path'] = full_path 119 print '# really takes a certain time ...'119 print '# Sometimes takes a certain time (should be improved asap)' 120 120 121 121 def get_current_package(self): … … 198 198 packages = self.get_next_work_units() 199 199 if len(packages) !=0: 200 print '\n# Execute parallel actions within ', packages 200 print '\n#--------------------------------------------------------------' 201 print '# Execute parallel actions within packages', packages 201 202 for package in packages: 202 203 self.add_work_unit (package, command) … … 218 219 # the work the threads will have to do 219 220 def do_execute(self, arg): 220 path = self.get_work_area_path (arg['package']) 221 self.set_work_unit_status (arg['package'], 'running') 222 cmd = "cmt -use="+ arg['package'] + " run '"+ arg['cmd'] + "'" 223 os.chdir(path) 224 print '#--------------------------------------------------------------' 225 print '# Now trying ['+ arg['cmd']+'] in ' + path 226 print '#--------------------------------------------------------------' 227 cmd = arg['cmd'] 228 status, output, error, pythonError = exeCommand(cmd, iTimeout = 10) 229 self.suppress_work_unit (arg['package']) 230 self.set_work_unit_status (arg['package'], 'done') 231 # status, output= commands.getstatusoutput(cmd) 232 #print output 233 #if status != 0: 234 # raise RuntimeError(output) 235 return {'output':output, 'cmd': arg['cmd'], 'package':arg['package']} 221 path = self.get_work_area_path (arg['package']) 222 if path == None: 223 raise RuntimeError('Path to package '+ arg['package'] +' not found') 224 self.set_work_unit_status (arg['package'], 'running') 225 cmd = "cmt -use="+ arg['package'] + " run '"+ arg['cmd'] + "'" 226 os.chdir(path) 227 print '#--------------------------------------------------------------' 228 print '# Now trying ['+ arg['cmd']+'] in ' + path 229 print '#--------------------------------------------------------------' 230 cmd = arg['cmd'] 231 status, output, error, pythonError = exeCommand(cmd, iTimeout = 10) 232 self.suppress_work_unit (arg['package']) 233 self.set_work_unit_status (arg['package'], 'done') 234 # status, output= commands.getstatusoutput(cmd) 235 #if status != 0: 236 # raise RuntimeError(output) 237 return {'output':output, 'cmd': arg['cmd'], 'package':arg['package']} 236 238 237 239 # this will be called when an exception occurs within a thread 238 240 def handle_exception(self, request, exc_info): 239 241 #traceback.print_stack() 240 print "# Exception occured in request #%s: %s" % \ 241 (request.requestID, exc_info[1]) 242 print '#--------------------------------------------------------------' 243 #print "# Exception occured in request #%s: %s" %(request.requestID, exc_info[1]) 244 print "# Exception occured: %s" %(exc_info[1]) 245 print '#--------------------------------------------------------------' 246 sys.exit(-1) 242 247 #--------- EoF --------# -
tbroadcast/v2/scripts/tbroadcast
r237 r240 1 #!/usr/bin/env python 21 #!/usr/bin/env python 2 2 #----------------------------------# 3 3 # -- Author: V.Garonne … … 13 13 from tbroadcast import Scheduler 14 14 15 def 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 15 23 if __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)]: 22 28 if arg[0]=='-': 23 if string.split(arg,'=')[0] == '-nb': 29 option = string.split(arg,'=')[0] 30 if option == '-nb': 24 31 num_worker = int (string.split(arg,'=')[1]) 32 else: 33 usage() 34 sys.exit(-1) 35 25 36 else: 26 37 command = arg 27 28 # we create a pool of num_worker worker threads 29 #print 'num_worker', num_worker , command 38 30 39 master = Scheduler (num_workers=num_worker) 31 40 master.execute_all (command)
Note: See TracChangeset
for help on using the changeset viewer.