#include "SALOME_Fake_NamingService.hxx"
#include "SALOME_KernelORB.hxx"
+#include <cstring>
+
static SALOME::DataServerManager_var _dsm_singleton;
std::string GetDSMInstanceInternal(const std::vector<std::string>& argv)
root_poa = PortableServer::POA::_narrow(obj);
SALOME_CPythonHelper cPyh;
{
- int argc(1);
- char *argv[2] = {"oops",nullptr};
- cPyh.initializePython(argc,argv);
+ int argcInit((int)argv.size());
+ char **argvInit = new char *[argcInit+1];
+ argvInit[argcInit] = nullptr;
+ for(int i = 0 ; i < argcInit ; ++i)
+ argvInit[i] = strdup(argv[i].c_str());
+ cPyh.initializePython(argcInit,argvInit);
+ for(int i = 0 ; i < argcInit ; ++i)
+ free(argvInit[i]);
+ delete [] argvInit;
}
SALOME_Fake_NamingService *ns(new SALOME_Fake_NamingService);
SALOMESDS::DataServerManager *dsm(new SALOMESDS::DataServerManager(&cPyh,orb,root_poa,ns));
%}
-namespace SALOME
+class SALOME_Exception
{
- class SALOME_Exception
+ public:
+ SALOME_Exception(const std::string& text);
+ %extend
{
- public:
- %extend
+ std::string __str__() const
{
- std::string __str__() const
- {
- return std::string(self->what());
- }
+ return std::string(self->what());
}
- };
-}
-
-using namespace SALOME;
+ }
+};
%exception {
try {
$action
}
- catch (SALOME::SALOME_Exception& _e) {
+ catch (SALOME_Exception& _e) {
// Reraise with SWIG_Python_Raise
- SWIG_Python_Raise(SWIG_NewPointerObj((new SALOME::SALOME_Exception(static_cast< const SALOME::SALOME_Exception& >(_e))),SWIGTYPE_p_INTERP_KERNEL__Exception,SWIG_POINTER_OWN), "INTERP_KERNEL::Exception", SWIGTYPE_p_INTERP_KERNEL__Exception);
+ SWIG_Python_Raise(SWIG_NewPointerObj((new SALOME_Exception(static_cast< const SALOME_Exception& >(_e.what()))),SWIGTYPE_p_SALOME_Exception,SWIG_POINTER_OWN), "SALOME_Exception", SWIGTYPE_p_SALOME_Exception);
SWIG_fail;
}
}
{
if(!PyList_Check(argv))
THROW_SALOME_EXCEPTION("Not a pylist");
- Py_ssize_t sz=PyList_Size(pyLi);
+ Py_ssize_t sz=PyList_Size(argv);
std::vector<std::string> argvCpp(sz);
for(Py_ssize_t i = 0 ; i < sz ; ++i)
{
- PyObject *obj = PyList_GetItem(pyLi,i);
+ PyObject *obj = PyList_GetItem(argv,i);
if(!PyUnicode_Check(obj))
THROW_SALOME_EXCEPTION("Not a pylist of strings");
{
argvCpp[i] = PyUnicode_AsUTF8AndSize(obj,&dummy);
}
}
- GetDSMInstanceInternal(argvCpp);
+ return GetDSMInstanceInternal(argvCpp);
}
}
import CORBA
orb = CORBA.ORB_init([''])
ns = orb.string_to_object(IORNS)
- dsm=ns.Resolve("/DataServerManager")
+ import SALOME
+ dsm = orb.string_to_object(ns.Resolve("/DataServerManager").decode())
+ print(400*"$")
+ print(dsm)
+ print(type(dsm))
dss,isCreated=dsm.giveADataScopeTransactionCalled(scopeName)
assert(not isCreated)
wk=dss.waitForKeyInVar(varName,obj2Str("ef"))