Ignore:
Timestamp:
May 28, 2009, 9:44:59 AM (15 years ago)
Author:
garonne
Message:

Commit changes

File:
1 edited

Legend:

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

    r478 r508  
    1818from threading import BoundedSemaphore
    1919
    20 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 from executer   import  exeCommand
    26 from executer   import  getstatusoutput
     20from threadpool  import WorkRequest
     21from threadpool  import ThreadPool
     22from threadpool  import NoResultsPending
     23from threadpool  import NoWorkersAvailable
     24from threadpool  import  makeRequests
     25
     26from  subprocess import Popen
    2727
    2828class Scheduler:
     
    7272    def get_current_project(self):
    7373        cmd = 'cmt show projects | grep current'
    74         status, output = getstatusoutput (cmd)
    75 #        status, output = commands.getstatusoutput (cmd)
     74        status, output = commands.getstatusoutput (cmd)
    7675        if status != 0:
    7776            print output
     
    10099        cmd = 'cmt -private show cycles'
    101100        cycle_found = False
    102         status, output = getstatusoutput (cmd)
    103 #        status, output = commands.getstatusoutput (cmd)
     101        status, output = commands.getstatusoutput (cmd)
    104102        if status != 0:
    105103            print output
     
    252250        else:   
    253251            cmd = 'cat ' + file       
    254         status, output = getstatusoutput (cmd)
    255 #        status, output = commands.getstatusoutput (cmd)
     252        status, output = commands.getstatusoutput (cmd)
    256253        if status != 0:
    257254            print output
     
    312309
    313310    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)
    317313        if status != 0:
    318314            print output
     
    331327        #return os.getcwd ()
    332328        cmd = 'cmt -use='+name+' run pwd'
    333         status, output = getstatusoutput (cmd)
    334 #        status, output = commands.getstatusoutput (cmd)
     329        status, output = commands.getstatusoutput (cmd)
    335330        if status != 0:
    336331            print output
     
    392387            # we create requests
    393388            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)
    395390            # then we put the work request in the queue...
    396391            self.set_work_unit_status (name, 'queued')
     
    441436      print header
    442437      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_name
     438      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
    448443      cmd = "cd "+ path +";"+ arg['cmd']
    449444      #status, output= commands.getstatusoutput(cmd)
    450445      # init output file
     446
     447      self.packages[arg['package']] ['startTime'] = time.time ()                           
     448
    451449      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     
    460464      if not self.keep_going and status > 0:
    461465        sys.exit(status)   
     
    473477      #if status != 0:
    474478      #   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
    495481             
    496482    # this will be called when an exception occurs within a thread
Note: See TracChangeset for help on using the changeset viewer.