def async_execute(self, msg): if self.overwrite_time_parameterization: start_state = self._start_state if self._start_state else self.get_current_state( ) group = self.get_name() msg = add_time_parametrisation(msg, start_state, group) if not msg.success: msg = None else: msg = msg.parametrized_trajectory elif msg.joint_trajectory.points[-1].time_from_start == 0: raise Exception("The time from start is not set!") self._start_state = None services.execute(msg, wait=False, persistent=True)
def test_executeCorrectness(self): fakeCommand = "some fake command to passed as a list" pOpen = self.__patchPOpen() services.execute(fakeCommand) expected = [ call(services.formatCommandLine(fakeCommand), bufsize=1, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT), call().communicate() ] self.assertCalls(pOpen, expected)
def test_executeWithFailure(self): status, receivedOutput = services.execute(TEST_COMMAND_LINE + " --fail") self.assertNotEqual(0, status) self.assertEqual([], receivedOutput) self.assertCalls(self.printMock, [])
def test_executeSilently(self): status, receivedOutput = services.execute(TEST_COMMAND_LINE + " --pass", beSilent=True) self.assertEqual(0, status) self.assertEqual(TEST_FAKE_OUTPUT, receivedOutput) self.assertCalls(self.printMock, [])
def test_executeWithSuccess(self): status, receivedOutput = services.execute(TEST_COMMAND_LINE + " --pass") self.assertEqual(0, status) self.assertEqual(TEST_FAKE_OUTPUT, receivedOutput) expected = [call(line, end='') for line in TEST_FAKE_OUTPUT] self.assertCalls(self.printMock, expected)
def run(self): status, log = execute(self.__getOutputPath( 'bin', self.__makefile[StatMakefile.EXEC]), beSilent=self.__beSilent) self.__log.extend(log) if status: message = 'The executable of package "{0}" failed with error-code {1:#X}.\n'.format( self.__fileName, status & 0xFFFFFFFF) self.__log.append(message) raise TestsRunnerException(message)
def compile(self): environ = dict(os.environ, STAT_NAMESPACE=self.__makefile.name) makeCommand = formatMakeCommand( self.__fileName, self.__arguments, ) status, log = execute(makeCommand, beSilent=self.__beSilent, env=environ) self.__log.extend(log) if status: raise TestsRunnerException( 'Package "{0}" failed to compile.'.format(self.__fileName))
if __name__ == '__main__': # 计算pre级operator utils.apply_on_factors(operators.execute, [ 'pre_risk_free_rate.PreRiskFreeRate', 'pre_capital.PreCapital', 'pre_universe.PreUniverse' ]) # 计算operator utils.apply_on_factors(operators.execute, [ 'barra_size_operator.BarraSizeOperator', 'barra_beta_operator.BarraBetaOperator', 'barra_momentum_operator.BarraMomentumOperator', 'barra_book_to_price_operator.BarraBookToPriceOperator', 'barra_liquidity_operator.BarraLiquidityOperator', 'barra_non_linear_size_operator.BarraNonLinearSizeOperator', 'barra_earnings_yield_operator.BarraEarningsYieldOperator', 'barra_growth_operator.BarraGrowthOperator', 'barra_leverage_operator.BarraLeverageOperator', 'barra_residual_volatility_operator.BarraResidualVolatilityOperator' ]) # 计算post级operator operators.execute('post_barra_factors_stand.PostBarraFactorsStand') # 计算model models.execute('barra_cne5_model.BarraCNE5Model') # 计算service services.execute('barra_cne5_service.BarraCNE5RetService')