%{
#include "ReceiverFactory.hxx"
#include "SALOME_Comm_i.hxx"
+ #include "SALOMEMultiComm.hxx"
+ #include "SenderFactory.hxx"
%}
%typemap(python,in) SALOME::SenderDouble_ptr
$1 = t;
}
+%typemap(python,out) SALOME::SenderDouble_ptr
+{
+ PyObject* pdict = PyDict_New();
+ PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins());
+ PyRun_String("import CORBA", Py_single_input, pdict, pdict);
+ PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input,
+ pdict, pdict);
+ PyObject* orb = PyDict_GetItemString(pdict, "o");
+ // Get the orb Corba C++
+ int argc = 0;
+ char *xargv = "";
+ char **argv = &xargv;
+ CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv);
+ string s = ORB->object_to_string($1);
+ PyObject * tmp = PyString_FromString(s.c_str());
+ $result = PyObject_CallMethod(orb, "string_to_object", "O", tmp);
+}
+
PyObject * getValueForSender(SALOME::SenderDouble_ptr senderDouble);
%{
return result;
}
%}
+
+SALOME::SenderDouble_ptr buildSenderFromList(PyObject *pylist);
+%{
+SALOME::SenderDouble_ptr buildSenderFromList(PyObject *pylist)
+{
+ if (PyList_Check(pylist))
+ {
+ int listLgth = PyList_Size(pylist);
+ double *tab=new double[listLgth];
+ for (int i=0;i<listLgth;i++)
+ {
+ tab[i]=PyFloat_AsDouble(PyList_GetItem(pylist,i));
+ }
+ SALOMEMultiComm communicator;
+ return SenderFactory::buildSender(communicator,tab,listLgth,true);
+ }
+ else
+ {
+ PyErr_SetString(PyExc_TypeError,"not a list");
+ return SALOME::SenderDouble::_nil();
+ }
+}
+%}
#include <unistd.h>
#include <fstream>
#include <iostream>
+#include <sstream>
#include <string.h>
#include <map>
#include <list>
{
}
-SALOME_ResourcesManager::SALOME_ResourcesManager()
+SALOME_ResourcesManager::SALOME_ResourcesManager(CORBA::ORB_ptr orb)
{
+ _NS = new SALOME_NamingService(orb);
_path_resources=getenv("KERNEL_ROOT_DIR");
_path_resources+="/share/salome/resources/CatalogResources.xml";
ParseXmlFile();
SALOME_ResourcesManager::~SALOME_ResourcesManager()
{
+ delete _NS;
}
vector<string> SALOME_ResourcesManager::GetFittingResources(const Engines::MachineParameters& params,const char *moduleName) throw(SALOME_Exception)
const ParserResourcesType& resInfo=_resourcesList[machine];
tempOutputFile << "#! /bin/sh" << endl;
//set env vars
+ tempOutputFile << "python_version=`python -c \"import sys; print sys.version[:3]\"`" << endl;
for(map<string,string>::const_iterator iter=resInfo.ModulesPath.begin();iter!=resInfo.ModulesPath.end();iter++)
{
string curModulePath((*iter).second);
tempOutputFile << (*iter).first << "_ROOT_DIR="<< curModulePath << endl;
tempOutputFile << "export " << (*iter).first << "_ROOT_DIR" << endl;
tempOutputFile << "LD_LIBRARY_PATH=" << curModulePath << "/lib/salome" << ":${LD_LIBRARY_PATH}" << endl;
- tempOutputFile << "PYTHONPATH=" << curModulePath << "/bin/salome:" << curModulePath << "/lib/salome:" << curModulePath << "/lib/python2.2/site-packages/salome:";
- tempOutputFile << curModulePath << "/lib/python2.2/site-packages/salome/shared_modules:${PYTHONPATH}" << endl;
+ tempOutputFile << "PYTHONPATH=" << curModulePath << "/bin/salome:" << curModulePath << "/lib/salome:" << curModulePath << "/lib/python${python_version}/site-packages/salome:";
+ tempOutputFile << curModulePath << "/lib/python${python_version}/site-packages/salome/shared_modules:${PYTHONPATH}" << endl;
}
tempOutputFile << "export LD_LIBRARY_PATH" << endl;
tempOutputFile << "export PYTHONPATH" << endl;
string SALOME_ResourcesManager::BuildCommandToLaunchLocalContainer(const char *containerName)
{
_TmpFileName="";
- string command;
+ ostringstream command;
if(Engines_Container_i::isPythonContainer(containerName))
- command="SALOME_ContainerPy.py ";
+ command << "SALOME_ContainerPy.py ";
else
- command="SALOME_Container ";
- command+=containerName;
- command+=" -";
+ command << "SALOME_Container ";
+ command << containerName << " -";
AddOmninamesParams(command);
- command+=" > /tmp/";
- command+=containerName;
- command += "_";
- command += GetHostname();
- command += ".log 2>&1 &" ;
- cout << "Command is ... " << command << endl << flush;
- return command;
+ command << " > /tmp/" << containerName << "_" << GetHostname() << ".log 2>&1 &";
+ cout << "Command is ... " << command.str() << endl << flush;
+ return command.str();
}
void SALOME_ResourcesManager::RmTmpFile()
// rsh -n ikkyo /export/home/rahuel/SALOME_ROOT/bin/runSession SALOME_Container -ORBInitRef NameService=corbaname::dm2s0017:1515 &
const ParserResourcesType& resInfo=_resourcesList[machine];
bool pyCont=Engines_Container_i::isPythonContainer(containerName);
- string command;
+ ostringstream command;
if(resInfo.Protocol==rsh)
- command = "rsh -n " ;
+ command << "rsh -n " ;
else if(resInfo.Protocol==ssh)
- command = "ssh -f -n ";
+ command << "ssh -f -n ";
else
throw SALOME_Exception("Not implemented yet...");
- command += machine;
- command += " ";
+ command << machine << " ";
string path = (*(resInfo.ModulesPath.find("KERNEL"))).second;
- command +=path;
- command += "/bin/salome/";
+ command << path <<"/bin/salome/";
if ( pyCont )
- command += "SALOME_ContainerPy.py ";
+ command << "SALOME_ContainerPy.py ";
else
- command += "SALOME_Container ";
- command += containerName;
- command += " -";
+ command << "SALOME_Container ";
+ command << containerName;
+ command << " -";
AddOmninamesParams(command);
- command += " > /tmp/";
- command += containerName;
- command += "_";
- command += machine;
- command += ".log 2>&1 &" ;
+ command << " > /tmp/" << containerName << "_" << machine << ".log 2>&1 &" ;
SCRUTE( command );
- return command;
+ return command.str();
}
// Warning need an updated parsed list : _resourcesList
}
}
-void SALOME_ResourcesManager::AddOmninamesParams(string& command) const
+void SALOME_ResourcesManager::AddOmninamesParams(ostream& fileStream) const
{
- string omniORBcfg( getenv( "OMNIORB_CONFIG" ) ) ;
- ifstream omniORBfile( omniORBcfg.c_str() ) ;
- char ORBInitRef[12] ;
- char nameservice[132] ;
- omniORBfile >> ORBInitRef ;
- command += ORBInitRef ;
- command += " " ;
- omniORBfile >> nameservice ;
- omniORBfile.close() ;
- char * bsn = strchr( nameservice , '\n' ) ;
- if ( bsn ) {
- bsn[ 0 ] = '\0' ;
- }
- command += nameservice ;
-}
-
-void SALOME_ResourcesManager::AddOmninamesParams(ofstream& fileStream) const
-{
- string omniORBcfg( getenv( "OMNIORB_CONFIG" ) ) ;
- ifstream omniORBfile( omniORBcfg.c_str() ) ;
- char ORBInitRef[12] ;
- char nameservice[132] ;
- omniORBfile >> ORBInitRef ;
- fileStream << ORBInitRef;
- fileStream << " ";
- omniORBfile >> nameservice ;
- omniORBfile.close() ;
- char * bsn = strchr( nameservice , '\n' ) ;
- if ( bsn ) {
- bsn[ 0 ] = '\0' ;
- }
- fileStream << nameservice;
+ char *iorstr = _NS->getIORaddr();
+ fileStream << "ORBInitRef NameService=" << iorstr;
}
string SALOME_ResourcesManager::BuildTemporaryFileName() const
command += ".sh";
return command;
}
-
-
#include <SALOMEconfig.h>
#include "SALOME_ResourcesCatalog_Handler.hxx"
#include "SALOME_LoadRateManager.hxx"
+#include "SALOME_NamingService.hxx"
#include CORBA_CLIENT_HEADER(SALOME_ContainerManager)
#include <string>
#include <fstream>
{
public:
//! standard constructor
- SALOME_ResourcesManager();
+ SALOME_ResourcesManager(CORBA::ORB_ptr orb);
//!just for test
SALOME_ResourcesManager(const char *xmlFilePath);
//! method that keep from hosts only those having component of name moduleName.
void KeepOnlyResourcesWithModule(std::vector<std::string>& hosts,const char *moduleName) const throw(SALOME_Exception);
- //! methode that add to command all options relative to naming service.
- void AddOmninamesParams(std::string& command) const;
-
//! method that add to command all options relative to naming service.
- void AddOmninamesParams(std::ofstream& fileStream) const;
+ void AddOmninamesParams(std::ostream& fileStream) const;
//! method that generate a file name in /tmp directory
std::string BuildTemporaryFileName() const;
+ SALOME_NamingService *_NS;
+
// will contain the path to the ressources catalog
QString _path_resources;