def execute(self, targets, lines, block=None): """Execute lines of code on targets and possibly block. :Parameters: targets : int, list or 'all' The engine ids the action will apply to. Call `get_ids` to see a list of currently available engines. lines : str A string of Python code to execute. block : boolean Should I block or not. If block=True, wait for the action to complete and return the result. If block=False, return a `PendingResult` object that can be used to later get the result. If block is not specified, the block attribute will be used instead. :Returns: A list of dictionaries with the stdin/stdout/stderr of the command on each targets. """ self._checkClientID() localBlock = self._reallyBlock(block) result = self._executeRemoteMethod('execute', targets, clientID=self._clientID, block=localBlock, lines=lines) if not localBlock: result = PendingResult(self, result) result.addCallback(wrapResultList) else: result = ResultList(result) return result
def get_result(self, targets, i=None): """Get the stdin/stdout/stderr of a previously executed command on targets. :Parameters: targets : int, list or 'all' The engine ids the action will apply to. Call `get_ids` to see a list of currently available engines. i : None or int The command number to retrieve. The default will retrieve the most recent command. :Returns: The result dict for the command. """ self._checkClientID() localBlock = self._reallyBlock() result = self._executeRemoteMethod('get_result', targets, clientID=self._clientID, block=localBlock, id=i) if not localBlock: result = PendingResult(self, result) result.addCallback(wrapResultList) else: result = ResultList(result) return result
def getResult(self, targets, i=None): """Get the stdin/stdout/stderr of a previously executed command on targets. :Parameters: targets : int, list or 'all' The engine ids the action will apply to. Call `getIDs` to see a list of currently available engines. i : None or int The command number to retrieve. The default will retrieve the most recent command. :Returns: The result dict for the command. """ if i is None: # This is because None cannot be marshalled by xml-rpc i = 'None' self._checkClientID() localBlock = self._reallyBlock() result = self._executeRemoteMethod(self._server.getResult, self._clientID, localBlock, targets, i) if not localBlock: result = PendingResult(self, result) result.addCallback(wrapResultList) else: result = ResultList(result) return result