Changeset 508 for tbroadcast/HEAD/python/tbroadcast.py
- Timestamp:
- May 28, 2009, 9:44:59 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tbroadcast/HEAD/python/tbroadcast.py
r478 r508 18 18 from threading import BoundedSemaphore 19 19 20 from threadpool import WorkRequest21 from threadpool import ThreadPool22 from threadpool import NoResultsPending23 from threadpool import NoWorkersAvailable24 from threadpool import makeRequests25 from executer import exeCommand 26 from executer import getstatusoutput20 from threadpool import WorkRequest 21 from threadpool import ThreadPool 22 from threadpool import NoResultsPending 23 from threadpool import NoWorkersAvailable 24 from threadpool import makeRequests 25 26 from subprocess import Popen 27 27 28 28 class Scheduler: … … 72 72 def get_current_project(self): 73 73 cmd = 'cmt show projects | grep current' 74 status, output = getstatusoutput (cmd) 75 # status, output = commands.getstatusoutput (cmd) 74 status, output = commands.getstatusoutput (cmd) 76 75 if status != 0: 77 76 print output … … 100 99 cmd = 'cmt -private show cycles' 101 100 cycle_found = False 102 status, output = getstatusoutput (cmd) 103 # status, output = commands.getstatusoutput (cmd) 101 status, output = commands.getstatusoutput (cmd) 104 102 if status != 0: 105 103 print output … … 252 250 else: 253 251 cmd = 'cat ' + file 254 status, output = getstatusoutput (cmd) 255 # status, output = commands.getstatusoutput (cmd) 252 status, output = commands.getstatusoutput (cmd) 256 253 if status != 0: 257 254 print output … … 312 309 313 310 def get_current_package(self): 314 cmd = 'cmt show macro package' 315 status, output = getstatusoutput (cmd) 316 # status, output = commands.getstatusoutput (cmd) 311 cmd = 'cmt show macro package' 312 status, output = commands.getstatusoutput (cmd) 317 313 if status != 0: 318 314 print output … … 331 327 #return os.getcwd () 332 328 cmd = 'cmt -use='+name+' run pwd' 333 status, output = getstatusoutput (cmd) 334 # status, output = commands.getstatusoutput (cmd) 329 status, output = commands.getstatusoutput (cmd) 335 330 if status != 0: 336 331 print output … … 392 387 # we create requests 393 388 arg = {'cmd': cmd , 'package':name} 394 req = WorkRequest(self.do_execute, [arg] , None, callback=self.result_callback , exc_callback=self.handle_exception)389 req = WorkRequest(self.do_execute, [arg] , None, callback=self.result_callback) 395 390 # then we put the work request in the queue... 396 391 self.set_work_unit_status (name, 'queued') … … 441 436 print header 442 437 project_path = self.current_project['path']+'/'+self.current_project['version']+'/' 443 log_name =string.replace(path, project_path, '')444 log_name = string.replace(log_name, '/cmt', '')445 log_name = string.replace(log_name, '/', '_')446 log_name = log_name+'.loglog'447 arg['log'] = log_name438 log_name = string.replace(path, project_path, '') 439 log_name = string.replace(log_name, '/cmt', '') 440 log_name = string.replace(log_name, '/', '_') 441 log_name = log_name+'.loglog' 442 arg['log'] = log_name 448 443 cmd = "cd "+ path +";"+ arg['cmd'] 449 444 #status, output= commands.getstatusoutput(cmd) 450 445 # init output file 446 447 self.packages[arg['package']] ['startTime'] = time.time () 448 451 449 if self.output is not None: 452 f = open (self.output+'/'+ log_name, 'w+') 453 f.write (header) 454 f.close() 455 if self.error is not None: 456 f = open (self.error+'/error'+log_name, 'w+') 457 f.close() 458 self.packages[arg['package']] ['startTime'] = time.time () 459 status, output, error, pythonError = exeCommand(sCmd=cmd, oLineCallback=self.redirectOutput, arg=arg)#,iTimeout = 3600) 450 f1 = open (self.output+'/'+ log_name, 'w+') 451 f1.write (header) 452 f1.close() 453 f1 = open (self.output+'/'+ log_name, 'a') 454 if self.error is not None: 455 f2 = open (self.error+'/error'+log_name, 'w+') 456 Popen(cmd, shell=True, stdout=f1, stderr=f2).communicate() 457 f2.close() 458 else: 459 Popen(cmd, shell=True, stdout=f1, stderr=f1).communicate() 460 f1.close() 461 else: 462 Popen(cmd, shell=True).communicate() 463 460 464 if not self.keep_going and status > 0: 461 465 sys.exit(status) … … 473 477 #if status != 0: 474 478 # raise RuntimeError(output) 475 return {'output':output, 'cmd': arg['cmd'], 'package':arg['package']} 476 477 def redirectOutput(self, index, buffer, arg): 478 """Filter function to redirect the std output and error of the job 479 executable for real-time debugging 480 """ 481 if self.output is not None: 482 if index==0: 483 f = open (self.output+'/'+arg['log'], 'a') 484 f.write (buffer+'\n') 485 f.close() 486 elif index==1: 487 if self.error is not None: 488 f = open (self.error+'/error'+arg['log'], 'a') 489 else: 490 f = open (self.output+'/'+arg['log'], 'a') 491 f.write (buffer+'\n') 492 f.close() 493 if not self.silent: 494 print buffer 479 return {'cmd': arg['cmd'], 'package':arg['package']} 480 495 481 496 482 # this will be called when an exception occurs within a thread
Note: See TracChangeset
for help on using the changeset viewer.