Changeset 245 for tbroadcast


Ignore:
Timestamp:
Sep 8, 2006, 11:39:11 AM (18 years ago)
Author:
garonne
Message:

correction du bug os.chdir de python

Location:
tbroadcast/v2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tbroadcast/v2/python/tbroadcast.py

    r244 r245  
    2626class Scheduler:
    2727
    28     def __init__(self, num_workers=20, file=None, ignore_cycles=False, local=False, output=None, error=None, silent = False):
     28    def __init__(self, num_workers=20, file=None, ignore_cycles=False, local=False, output=None, error=None, silent = False, perf=False):
    2929        self.pool            = ThreadPool(num_workers=num_workers)
    3030        self.current_package = self.get_current_package()
     
    3838        self.error           = error
    3939        self.silent          = silent
     40        self.perf            = perf
     41        if self.perf:
     42            f = open ('performances.log', 'w+')
     43            f.close()
    4044        if output is not None:
    4145            if not os.path.exists (output):
     
    410414      #print "**Result: %s from request #%s" % (str(result), request.requestID)
    411415      #print "# Result: %s from request #%s" % (result['package'], request.requestID)
    412       self.execute (result['cmd'])
     416      #if result['package'] == 'CodeCheck':
     417      #    sys.exit(-1)
     418      self.execute (result['cmd'])   
    413419
    414420    # the work the threads will have to do
    415421    def do_execute(self, arg):
    416422      path = self.get_work_area_path (arg['package'])
    417       if path == None:
     423      if path == None or not os.path.exists(path):
    418424          raise RuntimeError('Path to package '+ arg['package'] +' not found')
    419425      self.set_work_unit_status (arg['package'], 'running')     
    420       cmd = "cmt -use="+ arg['package'] + " run '"+ arg['cmd'] + "'"
    421       os.chdir(path)       
     426      #cmd = "cmt -use="+ arg['package'] + " run '"+ arg['cmd'] + "'"     
     427      #os.chdir(path)
     428      #arg['cmd'] = "cd "+ path +";"+ arg['cmd']
    422429      print '#--------------------------------------------------------------'
    423430      print '# ('+str(self.get_counter())+'/'+str(len(self.packages))+') Now trying ['+ arg['cmd']+'] in ' + path
    424431      print '#--------------------------------------------------------------'
    425       cmd = arg['cmd']
     432      cmd = "cd "+ path +";"+ arg['cmd']
    426433      #status, output= commands.getstatusoutput(cmd)
    427434      # init output file
     
    431438           if self.error is not None:
    432439               f = open (self.error+'/'+arg['package']+'_error.log', 'w+')
    433                f.close()           
     440               f.close()
     441      self.packages[arg['package']] ['startTime'] = time.time ()                     
    434442      status, output, error, pythonError  = exeCommand(sCmd=cmd, oLineCallback=self.redirectOutput, arg=arg)#,iTimeout = 3600)
     443      self.packages[arg['package']] ['endTime'] = time.time ()
     444      if self.perf:
     445          self.semaphore.acquire ()       
     446          f = open ('performances.log', 'a')
     447          f.write (arg['package']+" "+str(self.packages[arg['package']] ['startTime'])+" "+str(self.packages[arg['package']] ['endTime'] )+'\n') 
     448          f.close()
     449          self.semaphore.release()
    435450      self.suppress_work_unit (arg['package'])
    436451      self.set_work_unit_status (arg['package'], 'done')
     
    465480      #print "# Exception occured in request #%s: %s" %(request.requestID, exc_info[1])
    466481      print "# Exception occured: %s" %(exc_info[1])
     482      print exc_info
    467483      print '#--------------------------------------------------------------'   
    468       sys.exit(-1)
    469 
     484      #sys.exit(-1)
    470485
    471486#--------- EoF --------#
  • tbroadcast/v2/scripts/tbroadcast

    r244 r245  
    4040    ignore_cycles = False
    4141    silent        = False
     42    perf          = False     
    4243    output        = None
    4344    error         = None
     
    5051             if option == '-f':
    5152                file = string.split(arg,'=')[1]
     53             if option == '-perf':
     54                perf = True
    5255             if option == '-output':
    5356                output = string.split(arg,'=')[1]
     
    5962                 ignore_cycles = True
    6063             if option == '-silent':             
    61                  silent = True
    62                  
     64                 silent = True                 
    6365             if option == '-help':   
    6466                  usage()
     
    7476              command = arg
    7577
    76     master = Scheduler (num_workers=num_worker, file=file, ignore_cycles=ignore_cycles, local=local, output=output, error=error, silent=silent)
     78    master = Scheduler (num_workers=num_worker, file=file, ignore_cycles=ignore_cycles, local=local, output=output, error=error, silent=silent, perf=perf)
    7779    if test:
    7880        master.simulate_execution()
Note: See TracChangeset for help on using the changeset viewer.