def _cmdExec(self, oResponse, oConnection): """ Execute incoming command """ # Check if required parameters given and make a little sense. idResult = oResponse.getIntChecked( constants.tbresp.EXEC_PARAM_RESULT_ID, 1); sScriptZips = oResponse.getStringChecked(constants.tbresp.EXEC_PARAM_SCRIPT_ZIPS); sScriptCmdLine = oResponse.getStringChecked(constants.tbresp.EXEC_PARAM_SCRIPT_CMD_LINE); cSecTimeout = oResponse.getIntChecked( constants.tbresp.EXEC_PARAM_TIMEOUT, 30); oResponse.checkParameterCount(5); sScriptFile = utils.argsGetFirst(sScriptCmdLine); if sScriptFile is None: raise TestBoxException('Bad script command line: "%s"' % (sScriptCmdLine,)); if len(os.path.basename(sScriptFile)) < len('t.py'): raise TestBoxException('Script file name too short: "%s"' % (sScriptFile,)); if len(sScriptZips) < len('x.zip'): raise TestBoxException('Script zip name too short: "%s"' % (sScriptFile,)); # One task at the time. if self.isRunning(): raise TestBoxException('Already running other command'); # Don't bother running the task without the shares mounted. self._oTestBoxScript.mountShares(); # Raises exception on failure. # Kick off the task and ACK the command. with self._oCurTaskLock: self._oCurTask = TestBoxExecTask(self._oTestBoxScript, idResult = idResult, sScriptZips = sScriptZips, sScriptCmdLine = sScriptCmdLine, cSecTimeout = cSecTimeout); oConnection.sendAckAndClose(constants.tbresp.CMD_EXEC); return True;
def _cmdExec(self, oResponse, oConnection): """ Execute incoming command """ # Check if required parameters given and make a little sense. idResult = oResponse.getIntChecked( constants.tbresp.EXEC_PARAM_RESULT_ID, 1); sScriptZips = oResponse.getStringChecked(constants.tbresp.EXEC_PARAM_SCRIPT_ZIPS); sScriptCmdLine = oResponse.getStringChecked(constants.tbresp.EXEC_PARAM_SCRIPT_CMD_LINE); cSecTimeout = oResponse.getIntChecked( constants.tbresp.EXEC_PARAM_TIMEOUT, 30); oResponse.checkParameterCount(5); sScriptFile = utils.argsGetFirst(sScriptCmdLine); if sScriptFile is None: raise TestBoxException('Bad script command line: "%s"' % (sScriptCmdLine,)); if len(os.path.basename(sScriptFile)) < len('t.py'): raise TestBoxException('Script file name too short: "%s"' % (sScriptFile,)); if len(sScriptZips) < len('x.zip'): raise TestBoxException('Script zip name too short: "%s"' % (sScriptFile,)); # One task at the time. if self.isRunning(): raise TestBoxException('Already running other command'); # Don't bother running the task without the shares mounted. self._oTestBoxScript.mountShares(); # Raises exception on failure. # Kick off the task and ACK the command. self._oCurTaskLock.acquire(); try: self._oCurTask = TestBoxExecTask(self._oTestBoxScript, idResult = idResult, sScriptZips = sScriptZips, sScriptCmdLine = sScriptCmdLine, cSecTimeout = cSecTimeout); finally: self._oCurTaskLock.release(); oConnection.sendAckAndClose(constants.tbresp.CMD_EXEC); return True;