void set_number_of_retry(in long nbRetry);
+ void set_startup_code(in string codeAtStartUp);
+
+ string get_startup_code();
+
void addLogFileNameGroup(in vectorOfString groupOfLogFileNames);
vectorOfVectorOfString getAllLogFileNameGroups();
SALOME::SetNumberOfRetry( nbRetry );
}
+void Abstract_Engines_Container_i::set_startup_code(const char *codeAtStartUp)
+{
+ _code_at_startup = codeAtStartUp;
+}
+
+char *Abstract_Engines_Container_i::get_startup_code()
+{
+ return CORBA::string_dup( this->_code_at_startup.c_str() );
+}
+
Engines::vectorOfString_var FromVecStringCppToCORBA( const std::vector<std::string>& group)
{
Engines::vectorOfString_var ret( new Engines::vectorOfString );
if( !_code_to_exe_on_startup.empty() )
{
INFOS("[GiveContainer] container " << containerNameInNS << " python code executed " << _code_to_exe_on_startup);
+ cont->set_startup_code( _code_to_exe_on_startup.c_str() );
cont->execute_python_code( _code_to_exe_on_startup.c_str() );
}
INFOS("[GiveContainer] container " << containerNameInNS << " verbosity positionning Activation = " << SALOME::VerbosityActivated() << " Verbosity Level = " << SALOME::VerbosityLevelStr());
void set_big_obj_on_disk_directory(const char *directory) override;
void set_number_of_retry(CORBA::Long nbRetry) override;
+
+ void set_startup_code(const char *codeAtStartUp) override;
+
+ char *get_startup_code() override;
void addLogFileNameGroup(const Engines::vectorOfString& groupOfLogFileNames) override;
std::string _localfilename;
std::string _load_script;
std::string _py_container_name;
+ std::string _code_at_startup;
CORBA::ORB_var _orb;
PortableServer::POA_var _poa;
PortableServer::ObjectId *_id;
return True,StdErrTreatment(closeEyesOnErrorAtExit , stderr)
if not closeEyesOnErrorAtExit:
return False, stderr
- return stderr[-len(MY_KEY_TO_DETECT_FINISH):] == MY_KEY_TO_DETECT_FINISH,stderr[:-len(MY_KEY_TO_DETECT_FINISH)]
+ if stderr[-len(MY_KEY_TO_DETECT_FINISH):] == MY_KEY_TO_DETECT_FINISH:
+ return True,stderr[:-len(MY_KEY_TO_DETECT_FINISH)]
+ else:
+ return False,stderr
#
def InternalExecResistant( code, context, outargsname):
def RetrieveUniquePartFromPfx( fname ):
return os.path.splitext( os.path.basename(fname)[len(EXEC_CODE_FNAME_PXF):] )[0]
with tempfile.NamedTemporaryFile(dir=os.getcwd(),prefix=EXEC_CODE_FNAME_PXF,suffix=".py", mode="w", delete = False) as codeFd:
+ codeFd.write( "{}\n".format( containerRef.get_startup_code() ) )
codeFd.write( code )
if closeEyesOnErrorAtExit:
codeFd.write( """
atexit.register(ErrorAtexit)
print("OKKKKKK")
-j = 9 * i
+j = 9 * i * a
print("OKKKKKK3333")
"""
hostname = "localhost"
cp = pylauncher.GetRequestForGiveContainer(hostname,"container_crash_test")
salome.cm.SetNumberOfRetry( 3 )
+ salome.cm.SetCodeOnContainerStartUp("""a = 2""")
salome.cm.SetBigObjOnDiskThreshold(1000)
salome.cm.SetOverrideEnvForContainersSimple(env = [])
cont = salome.cm.GiveContainer(cp)
pyscript.executeFirst(refPtr)
ret = pyscript.executeSecond(["j"])
ret = pickle.loads( SALOME_PyNode.SeqByteReceiver(ret[0]).data() )
- self.assertEqual(ret,27)
+ self.assertEqual(ret,54)
with open(cont.locallogfilename) as f:
logCont = f.read( )
self.assertTrue( "WARNING : Retry #" in logCont)