Exemplo n.º 1
0
 def getCommandOutputData(cmdID, workerServer):
     log.log(cpc.util.log.TRACE,"Trying to pull command output from %s"%
             workerServer)
     s2smsg=ServerMessage(workerServer)  
     rundata_response = s2smsg.pullAssetRequest(cmdID, Asset.cmdOutput())
     
     if rundata_response.getType() != "application/x-tar":
         log.error("Incorrect response type: %s, should be %s"%
                   (rundata_response.getType(), 'application/x-tar'))
         if rundata_response.getType() == "text/json":
             errormsg=rundata_response.message.read(len(rundata_response.
                                                        message))
             presp=ProcessedResponse(rundata_response)
             if not presp.isOK():
                 log.error('Response from worker server not OK: %s'%
                           errormsg)
     else:
         s2smsg.clearAssetRequest(cmdID)
         log.log(cpc.util.log.TRACE,
                 "Successfully pulled command output data from %s."%
                 workerServer)
         return rundata_response
         #runfile = rundata_response.getRawData()
         #this doesnt work because the mmap closes as it is returned
     return None
Exemplo n.º 2
0
 def _fetchRemoteRunFiles(self, rc):
     """Get the result files from a remote run directory to a local
         command directory.
         Return true if successful. May throw exception in case of failure"""
     if rc.haveData:
         log.debug("Fetching remote results directory %s to %s" %
                   (rc.runDir, rc.cmd.getDir()))
         # the data is remote: we must fetch data through a
         # server-to-server command.
         msg = ServerMessage(rc.workerServer)
         resp = msg.deadWorkerFetchRequest(rc.workerDir, rc.runDir)
         if resp.getType() == "application/x-tar":
             # untar the return data and  use it.
             runfile = resp.getRawData()
             log.debug("extracting file for %s to dir %s" %
                       (rc.cmd.id, rc.cmd.getDir()))
             cpc.util.file.extractSafely(rc.cmd.getDir(), fileobj=runfile)
             return True
     return False