コード例 #1
0
ファイル: CallTrace.py プロジェクト: sanpingz/cgi-tools
 def startCommand(self):
     if 'Started' == self.status:
         ctid = str(self.ctid)
         input = 'data/start'+ctid+'.xml'
         cmm = './xml2cfg'
         labip = str(self.labip)
         out = 'data/out'+ctid+'.xml'
         command =cmm+' -h '+labip+' -p '+hostParam['port']+' -i '+input+' -o '+out
         func_obj = FuncWrapper(os.system, command)
         try:
             t = Timeout(5, func_obj)
             timer = time.time()
             t.run()
             timer = time.time()-timer
             #print timer
             cb = func_obj.result
             try:
                 os.remove(input)
                 os.remove(out)
             except WindowsError: pass
         except OSError, Exception:
             self.status = 'Failure'
             self.error['startCommand'] = 'command execute error'
             raise Exception("CMDError")
             #cb = os.system(command)
         else:
             if cb : self.status = 'Failure'
コード例 #2
0
ファイル: CallTrace.py プロジェクト: sanpingz/cgi-tools
 def safeCommand(self, labip, method=''):
     ctid = str(self.ctid)
     input = join('data',method+ctid+'.xml')
     cmm = './xml2cfg'
     out = join('data','out'+ctid+'.xml')
     command =cmm+' -h '+labip+' -p '+HOST_PORT+' -i '+input+' -o '+out
     func_obj = FuncWrapper(os.system, command)
     try:
         t = Timeout(8, func_obj)
         t.run()
         cb = func_obj.result
         logger.info('subscriber -> %s, trace id -> %s' % (self.handle, self.ctid))
         logger.info(command)
     except Exception:
         self.status = 'Failure'
         self.error['startCommand'] = 'command execute error on '+labip
         logException()