def _assembleArguments(self, sAction, fWithInterpreter=True): """ Creates an argument array for subprocess.Popen, splitting the sScriptCmdLine like bourne shell would. fWithInterpreter is used (False) when checking that the script exists. Returns None on bad input. """ # # This is a good place to export the test set id to the environment. # os.environ['TESTBOX_TEST_SET_ID'] = str(self._idResult) cTimeoutLeft = utils.timestampSecond() - self._tsSecStarted cTimeoutLeft = 0 if cTimeoutLeft >= self._cSecTimeout else self._cSecTimeout - cTimeoutLeft os.environ['TESTBOX_TIMEOUT'] = str(cTimeoutLeft) os.environ['TESTBOX_TIMEOUT_ABS'] = str(self._tsSecStarted + self._cSecTimeout) # # Do replacements and split the command line into arguments. # if self._sScriptCmdLine.find('@ACTION@') >= 0: sCmdLine = self._sScriptCmdLine.replace('@ACTION@', sAction) else: sCmdLine = self._sScriptCmdLine + ' ' + sAction for sVar in [ 'TESTBOX_PATH_BUILDS', 'TESTBOX_PATH_RESOURCES', 'TESTBOX_PATH_SCRATCH', 'TESTBOX_PATH_SCRIPTS', 'TESTBOX_PATH_UPLOAD', 'TESTBOX_UUID', 'TESTBOX_REPORTER', 'TESTBOX_ID', 'TESTBOX_TEST_SET_ID', 'TESTBOX_TIMEOUT', 'TESTBOX_TIMEOUT_ABS' ]: if sCmdLine.find('${' + sVar + '}') >= 0: sCmdLine = sCmdLine.replace('${' + sVar + '}', os.environ[sVar]) asArgs = utils.argsSplit(sCmdLine) # # Massage argv[0]: # - Convert portable slashes ('/') to the flavor preferred by the # OS we're currently running on. # - Run python script thru the current python interpreter (important # on systems that doesn't sport native hash-bang script execution). # asArgs[0] = asArgs[0].replace('/', os.path.sep) if not os.path.isabs(asArgs[0]): asArgs[0] = os.path.join(self._oTestBoxScript.getPathScripts(), asArgs[0]) if asArgs[0].endswith('.py') and fWithInterpreter: if sys.executable is not None and len(sys.executable) > 0: asArgs.insert(0, sys.executable) else: asArgs.insert(0, 'python') return asArgs
def _assembleArguments(self, sAction, fWithInterpreter = True): """ Creates an argument array for subprocess.Popen, splitting the sScriptCmdLine like bourne shell would. fWithInterpreter is used (False) when checking that the script exists. Returns None on bad input. """ # # This is a good place to export the test set id to the environment. # os.environ['TESTBOX_TEST_SET_ID'] = str(self._idResult); cTimeoutLeft = utils.timestampSecond() - self._tsSecStarted; cTimeoutLeft = 0 if cTimeoutLeft >= self._cSecTimeout else self._cSecTimeout - cTimeoutLeft; os.environ['TESTBOX_TIMEOUT'] = str(cTimeoutLeft); os.environ['TESTBOX_TIMEOUT_ABS'] = str(self._tsSecStarted + self._cSecTimeout); # # Do replacements and split the command line into arguments. # if self._sScriptCmdLine.find('@ACTION@') >= 0: sCmdLine = self._sScriptCmdLine.replace('@ACTION@', sAction); else: sCmdLine = self._sScriptCmdLine + ' ' + sAction; for sVar in [ 'TESTBOX_PATH_BUILDS', 'TESTBOX_PATH_RESOURCES', 'TESTBOX_PATH_SCRATCH', 'TESTBOX_PATH_SCRIPTS', 'TESTBOX_PATH_UPLOAD', 'TESTBOX_UUID', 'TESTBOX_REPORTER', 'TESTBOX_ID', 'TESTBOX_TEST_SET_ID', 'TESTBOX_TIMEOUT', 'TESTBOX_TIMEOUT_ABS' ]: if sCmdLine.find('${' + sVar + '}') >= 0: sCmdLine = sCmdLine.replace('${' + sVar + '}', os.environ[sVar]); asArgs = utils.argsSplit(sCmdLine); # # Massage argv[0]: # - Convert portable slashes ('/') to the flavor preferred by the # OS we're currently running on. # - Run python script thru the current python interpreter (important # on systems that doesn't sport native hash-bang script execution). # asArgs[0] = asArgs[0].replace('/', os.path.sep); if not os.path.isabs(asArgs[0]): asArgs[0] = os.path.join(self._oTestBoxScript.getPathScripts(), asArgs[0]); if asArgs[0].endswith('.py') and fWithInterpreter: if sys.executable: asArgs.insert(0, sys.executable); else: asArgs.insert(0, 'python'); return asArgs;