The Python protocol
++++++++++++++++++++++
-The Python protocol is based on serialisation done by the cPickle module (C implementation of the pickle module).
+The Python protocol is based on serialisation done by the pickle module.
All that is necessary is to define an object reference type with the Python protocol so that Python objects
can be exchanged between Python inline nodes and with SALOME components implemented in Python.
SALOME components implemented in Python that are required to support this exchange type must be designed
way as the example in the run method described below::
def run(self,s):
- o=cPickle.loads(s)
+ o=pickle.loads(s)
ret={'a':6, 'b':[1,2,3]}
- return cPickle.dumps(ret,-1)
+ return pickle.dumps(ret,-1)
The json protocol
++++++++++++++++++++++
The json protocol is based on `JSON <http://www.json.org/>`_ (JavaScript Object Notation)
-serialisation / deserialisation instead of cPickle. JSON supports fewer data types and requires that
+serialisation / deserialisation instead of pickle. JSON supports fewer data types and requires that
the simplejson Python module should be installed, but it has the advantage that it is more interoperable.
In particular, there are C++ libraries that serialise/deserialise the JSON.
INCLUDE_DIRECTORIES(
${PTHREAD_INCLUDE_DIR}
${OMNIORB_INCLUDE_DIR}
+ ${OMNIORBPY_INCLUDE_DIR}
${PYTHON_INCLUDE_DIRS}
${PROJECT_BINARY_DIR}/idl
${PROJECT_BINARY_DIR}
#ifdef OMNIORB
#include <omniORB4/CORBA.h>
-//--- from omniORBpy.h (not present on Debian Sarge packages)
-struct omniORBPYAPI
-{
- PyObject* (*cxxObjRefToPyObjRef)(const CORBA::Object_ptr cxx_obj,
- CORBA::Boolean hold_lock);
- // Convert a C++ object reference to a Python object reference.
- // If <hold_lock> is true, caller holds the Python interpreter lock.
-
- CORBA::Object_ptr (*pyObjRefToCxxObjRef)(PyObject* py_obj,
- CORBA::Boolean hold_lock);
- // Convert a Python object reference to a C++ object reference.
- // Raises BAD_PARAM if the Python object is not an object reference.
- // If <hold_lock> is true, caller holds the Python interpreter lock.
-
- PyObject* (*handleCxxSystemException)(const CORBA::SystemException& ex);
- // Sets the Python exception state to reflect the given C++ system
- // exception. Always returns NULL. The caller must hold the Python
- // interpreter lock.
-};
-
-omniORBPYAPI* api;
+#include <omniORBpy.h>
+omniORBpyAPI* api=0;
#define OMNIPY_CATCH_AND_HANDLE_SYSTEM_EXCEPTIONS \
catch (const CORBA::SystemException& ex) { \
if (!omnipy)
{
PyErr_SetString(PyExc_ImportError,(char*)"Cannot import _omnipy");
- return;
+ return NULL;
}
PyObject* pyapi = PyObject_GetAttrString(omnipy, (char*)"API");
- api = (omniORBPYAPI*)PyCObject_AsVoidPtr(pyapi);
+ api = (omniORBpyAPI*)PyCapsule_GetPointer(pyapi,"_omnipy.API");
Py_DECREF(pyapi);
#endif
%}
// param 0
PyObject *ret0Py(PyList_New(ret0.size()));
for(std::size_t i=0;i<ret0.size();i++)
- PyList_SetItem(ret0Py,i,PyInt_FromLong(ret0[i]));
+ PyList_SetItem(ret0Py,i,PyLong_FromLong(ret0[i]));
PyTuple_SetItem(ret,0,ret0Py);
// param 1
PyObject *ret1Py(PyList_New(ret1.size()));
// param 2
PyObject *ret2Py(PyList_New(ret2.size()));
for(std::size_t i=0;i<ret2.size();i++)
- PyList_SetItem(ret2Py,i,PyString_FromString(ret2[i].c_str()));
+ PyList_SetItem(ret2Py,i,PyBytes_FromString(ret2[i].c_str()));
PyTuple_SetItem(ret,2,ret2Py);
return ret;
}
if (!omnipy)
{
PyErr_SetString(PyExc_ImportError,(char*)"Cannot import _omnipy");
- return;
+ return NULL;
}
PyObject* pyapi = PyObject_GetAttrString(omnipy, (char*)"API");
- api = (omniORBPYAPI*)PyCObject_AsVoidPtr(pyapi);
+ api = (omniORBpyAPI*)PyCapsule_GetPointer(pyapi,"_omnipy.API");
Py_DECREF(pyapi);
#endif
%}
# additional include directories
INCLUDE_DIRECTORIES(
${OMNIORB_INCLUDE_DIR}
+ ${OMNIORBPY_INCLUDE_DIR}
${PYTHON_INCLUDE_DIR}
${PROJECT_SOURCE_DIR}/src/bases
${PROJECT_SOURCE_DIR}/src/engine
throw YACS::Exception("YACSEvalInputPort::getDefaultValueDefined : internal error !");
if(PyFloat_Check(data))
return new YACSEvalAnyDouble(PyFloat_AsDouble(data));
- if(PyInt_Check(data))
- return new YACSEvalAnyInt((int)PyInt_AsLong(data));
+ if(PyLong_Check(data))
+ return new YACSEvalAnyInt((int)PyLong_AsLong(data));
throw YACS::Exception("YACSEvalInputPort::getDefaultValueDefined : unmanaged types different from int and double for py !");
}
YACS::ENGINE::AnyInputPort *i1(dynamic_cast<YACS::ENGINE::AnyInputPort *>(_ptr));
}
else if(par1)
{
- PyObject *obj(PyInt_FromLong(par1->toInt()));
+ PyObject *obj(PyLong_FromLong(par1->toInt()));
i0->put(obj);
Py_XDECREF(obj);
}
-// Copyright (C) 2012-2016 CEA/DEN, EDF R&D
+ // Copyright (C) 2012-2016 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
PyObject *ob(PyList_New(sz));
for(std::size_t i=0;i<sz;i++)
{
- PyList_SetItem(ob,i,PyInt_FromLong((*_arr)[i]));
+ PyList_SetItem(ob,i,PyLong_FromLong((*_arr)[i]));
}
p->put(ob);
p->exSaveInit();
_salomeInstance=PyObject_Call(startMeth,myArgs,myKWArgs);//new
YACS::ENGINE::AutoPyRef getPortMeth(PyObject_GetAttrString(_salomeInstance,const_cast<char *>("get_port")));//new
YACS::ENGINE::AutoPyRef portPy(PyObject_CallObject(getPortMeth,0));//new
- _port=PyInt_AsLong(portPy);
+ _port=PyLong_AsLong(portPy);
//
int dummy;
_corbaConfigFileName=GetConfigAndPort(dummy);
PyObject *kernelRootDir(0);// os.environ["KERNEL_ROOT_DIR"]
{
YACS::ENGINE::AutoPyRef environPy(PyObject_GetAttrString(osPy,const_cast<char *>("environ")));//new
- YACS::ENGINE::AutoPyRef kernelRootDirStr(PyString_FromString(const_cast<char *>(KERNEL_ROOT_DIR)));//new
+ YACS::ENGINE::AutoPyRef kernelRootDirStr(PyBytes_FromString(const_cast<char *>(KERNEL_ROOT_DIR)));//new
kernelRootDir=PyObject_GetItem(environPy,kernelRootDirStr);//new
}
{
YACS::ENGINE::AutoPyRef joinPy(PyObject_GetAttrString(pathPy,const_cast<char *>("join")));//new
YACS::ENGINE::AutoPyRef myArgs(PyTuple_New(4));
Py_XINCREF(kernelRootDir); PyTuple_SetItem(myArgs,0,kernelRootDir);
- PyTuple_SetItem(myArgs,1,PyString_FromString(const_cast<char *>("bin")));
- PyTuple_SetItem(myArgs,2,PyString_FromString(const_cast<char *>("salome")));
- PyTuple_SetItem(myArgs,3,PyString_FromString(const_cast<char *>("appliskel")));
+ PyTuple_SetItem(myArgs,1,PyBytes_FromString(const_cast<char *>("bin")));
+ PyTuple_SetItem(myArgs,2,PyBytes_FromString(const_cast<char *>("salome")));
+ PyTuple_SetItem(myArgs,3,PyBytes_FromString(const_cast<char *>("appliskel")));
YACS::ENGINE::AutoPyRef res(PyObject_CallObject(joinPy,myArgs));
- ret=PyString_AsString(res);
+ ret=PyBytes_AsString(res);
}
Py_XDECREF(kernelRootDir);
return ret;
YACS::ENGINE::AutoPyRef osPy(PyImport_ImportModule(const_cast<char *>("os")));//new
YACS::ENGINE::AutoPyRef environPy(PyObject_GetAttrString(osPy,const_cast<char *>("environ")));//new
//
- YACS::ENGINE::AutoPyRef corbaConfigStr(PyString_FromString(const_cast<char *>(CORBA_CONFIG_ENV_VAR_NAME)));//new
+ YACS::ENGINE::AutoPyRef corbaConfigStr(PyBytes_FromString(const_cast<char *>(CORBA_CONFIG_ENV_VAR_NAME)));//new
YACS::ENGINE::AutoPyRef corbaConfigFileNamePy(PyObject_GetItem(environPy,corbaConfigStr));//new
- std::string ret(PyString_AsString(corbaConfigFileNamePy));
+ std::string ret(PyBytes_AsString(corbaConfigFileNamePy));
//
- YACS::ENGINE::AutoPyRef nsPortStr(PyString_FromString(const_cast<char *>(NSPORT_VAR_NAME)));//new
+ YACS::ENGINE::AutoPyRef nsPortStr(PyBytes_FromString(const_cast<char *>(NSPORT_VAR_NAME)));//new
YACS::ENGINE::AutoPyRef nsPortValuePy(PyObject_GetItem(environPy,nsPortStr));//new
- std::string portStr(PyString_AsString(nsPortValuePy));
+ std::string portStr(PyBytes_AsString(nsPortValuePy));
std::istringstream iss(portStr);
iss >> port;
return ret;
const char fetchPyCmd[]="import salome,CORBA\nsalome.salome_init()\nsl=salome.naming_service.Resolve(\"/SalomeLauncher\")\nif not CORBA.is_nil(sl):\n return salome.orb.object_to_string(sl)\nelse:\n raise Exception(\"Impossible to locate salome launcher !\")";
YACS::ENGINE::AutoPyRef func(YACS::ENGINE::evalPy(methName,fetchPyCmd));
YACS::ENGINE::AutoPyRef val(YACS::ENGINE::evalFuncPyWithNoParams(func));
- std::string ior(PyString_AsString(val));
+ std::string ior(PyBytes_AsString(val));
CORBA::Object_var obj(string_to_object(ior));
if(CORBA::is_nil(obj))
throw YACS::Exception("goFetchingSalomeLauncherInNS : fetched ior is NIL !");
for(std::size_t i=0;i<sz;i++)
{
PyObject *elt(PyList_GetItem(obj,i));
- eltCpp[i]=PyInt_AsLong(elt);
+ eltCpp[i]=PyLong_AsLong(elt);
}
YACS::AutoCppPtr<YACSEvalSeqAnyInt> elt(new YACSEvalSeqAnyInt(eltCpp));
return elt.dettach();
//
YACS::ENGINE::AutoPyRef func(YACS::ENGINE::evalPy(EFXGenFileName,EFXGenContent));
YACS::ENGINE::AutoPyRef val(YACS::ENGINE::evalFuncPyWithNoParams(func));
- _locSchemaFile=PyString_AsString(val);
+ _locSchemaFile=PyBytes_AsString(val);
func=YACS::ENGINE::evalPy(EFXGenFileName,EFXGenContent2);
val=YACS::ENGINE::evalFuncPyWithNoParams(func);
- _jobName=PyString_AsString(val);
+ _jobName=PyBytes_AsString(val);
//
static const char LISTPYOBJ_STR[]="list[pyobj]";
if(getBoss()->getOutputsOfInterest().empty())
${PROJECT_SOURCE_DIR}/src/yacsloader_swig
${PROJECT_SOURCE_DIR}/src/evalyfx
${OMNIORB_INCLUDE_DIR}
+ ${OMNIORBPY_INCLUDE_DIR}
${PYTHON_INCLUDE_DIRS}
)
PyObject *o=PyList_GetItem(pyLi,i);
if(PyInt_Check(o))
{
- int val=(int)PyInt_AS_LONG(o);
+ int val=(int)PyLong_AS_LONG(o);
arr[i]=val;
}
else
for(int i=0;i<size;i++)
{
PyObject *o=PyTuple_GetItem(pyLi,i);
- if(PyInt_Check(o))
+ if(PyLong_Check(o))
{
- int val=(int)PyInt_AS_LONG(o);
+ int val=(int)PyLong_AS_LONG(o);
arr[i]=val;
}
else
std::size_t sz(arr.size());
PyObject *ret(PyList_New(sz));
for(std::size_t i=0;i<sz;i++)
- PyList_SetItem(ret,i,PyInt_FromLong(arr[i]));
+ PyList_SetItem(ret,i,PyLong_FromLong(arr[i]));
return ret;
}
std::size_t sz2(zeArr->size());
PyObject *ret2(PyList_New(sz2));
for(std::size_t i2=0;i2<sz2;i2++)
- PyList_SetItem(ret2,i2,PyInt_FromLong((*zeArr)[i2]));
+ PyList_SetItem(ret2,i2,PyLong_FromLong((*zeArr)[i2]));
PyList_SetItem(ret,i,ret2);
}
else
}
else if(PyInt_Check(parameter))
{
- YACSEvalAnyInt tmp((int)PyInt_AsLong(parameter));
+ YACSEvalAnyInt tmp((int)PyLong_AsLong(parameter));
self->setDefaultValue(&tmp);
}
else
PyObject *ret0Py(ret0?Py_True:Py_False);
Py_XINCREF(ret0Py);
PyTuple_SetItem(ret,0,ret0Py);
- PyTuple_SetItem(ret,1,PyInt_FromLong(ret1));
+ PyTuple_SetItem(ret,1,PyLong_FromLong(ret1));
return ret;
}
}
INCLUDE_DIRECTORIES(
${PYTHON_INCLUDE_DIR}
${OMNIORB_INCLUDE_DIR}
+ ${OMNIORBPY_INCLUDE_DIR}
${LIBXML2_INCLUDE_DIR}
${GRAPHVIZ_INCLUDE_DIRS}
${QT_INCLUDES}
void FormContainerDecorator::connectForTyp()
{
connect(_typ->cb_resource,SIGNAL(mousePressed()),this,SLOT(onResMousePressed()));
- connect(_typ->cb_resource,SIGNAL(activated(int)),this,SLOT(onResActivated));
- connect(tb_container,SIGNAL(toggled(bool)),this,SLOT(onContToggled()));
+ connect(_typ->cb_resource,SIGNAL(activated(int)),this,SLOT(onResActivated(int)));
+ connect(tb_container,SIGNAL(toggled(bool)),this,SLOT(onContToggled(bool)));
}
</widget>
</item>
<item>
- <widget class="QComboBox" name="cb_resource">
+ <widget class="ComboBox" name="cb_resource">
<property name="toolTip">
<string>name of the resource hosting container when manually set</string>
</property>
</item>
</layout>
</widget>
+ <customwidgets>
+ <customwidget>
+ <class>ComboBox</class>
+ <extends>QComboBox</extends>
+ <header>FormComponent.hxx</header>
+ </customwidget>
+ </customwidgets>
<resources/>
<connections/>
</ui>
#include <iostream>
#include <fstream>
-#include "ListJobs_GUI.hxx"
#include "RuntimeSALOME.hxx"
+#include "ListJobs_GUI.hxx"
#include "GenericGui.hxx"
#include "QtGuiContext.hxx"
#include "YACSGuiLoader.hxx"
# additional include directories
INCLUDE_DIRECTORIES(
${OMNIORB_INCLUDE_DIR}
+ ${OMNIORBPY_INCLUDE_DIR}
${LIBXML2_INCLUDE_DIR}
${PYTHON_INCLUDE_DIR}
${PROJECT_SOURCE_DIR}/src/bases
void Subject::update(GuiEvent event,int type, Subject* son)
{
- //DEBTRACE("Subject::update " << type << "," << GuiObserver::eventName(event) << "," << son);
+ std::cerr << "Subject::update " << type << "," << GuiObserver::eventName(event) << "," << son << std::endl;
set<GuiObserver*> copySet = _setObs;
for (set<GuiObserver *>::iterator it = copySet.begin(); it != copySet.end(); ++it)
{
- //DEBTRACE("Subject::update " << *it);
+ std::cerr << "Subject::update " << *it << std::endl;
try
{
(*it)->update(event, type, son);
catch(Exception& ex)
{
std::cerr << "Internal error in Subject::update: " << ex.what() << std::endl;
+ std::cerr << "ERREUR ICI" << std::endl;
}
- catch(...)
- {
- std::cerr << "Internal error in Subject::update: " << std::endl;
- }
+ //catch(...)
+ // {
+ // std::cerr << "Internal error in Subject::update: " << std::endl;
+ // std::cerr << "ERREUR OU LA " << std::endl;
+ // }
}
}
INCLUDE_DIRECTORIES(
${PYTHON_INCLUDE_DIR}
+ ${OMNIORBPY_INCLUDE_DIR}
${SALOME_INCL_PATH}
${PROJECT_SOURCE_DIR}/src/bases
${PROJECT_SOURCE_DIR}/src/engine
for(int i=0; i<n; i++)
{
PyObject *elem = PyList_GetItem(pyList,i);
- if(not PyString_Check(elem))
+ if(not PyBytes_Check(elem))
{
std::stringstream message;
message << "List element number " << i << " is not a string.\n";
}
else
{
- const char * portName = PyString_AsString(elem);
+ const char * portName = PyBytes_AsString(elem);
cppList.push_back(portName);
}
}
PyObject *pystr, *module_name, *pyth_module, *pyth_func;
PyErr_Fetch(&ptype, &pvalue, &ptraceback);
pystr = PyObject_Str(pvalue);
- result = PyString_AsString(pystr);
+ result = PyBytes_AsString(pystr);
result += "\n";
Py_DECREF(pystr);
/* See if we can get a full traceback */
if(ptraceback)
{
- module_name = PyString_FromString("traceback");
+ module_name = PyBytes_FromString("traceback");
pyth_module = PyImport_Import(module_name);
Py_DECREF(module_name);
if (pyth_module)
for(int i=0; i<n; i++)
{
pystr = PyList_GetItem(pyList,i);
- result += PyString_AsString(pystr);
+ result += PyBytes_AsString(pystr);
}
Py_DECREF(pyList);
}
// Py_Initialize();
YACS::ENGINE::AutoGIL agil;
- pValue = PyString_FromString(_python_parser_module.c_str());
+ pValue = PyBytes_FromString(_python_parser_module.c_str());
pModule = PyImport_Import(pValue);
Py_DECREF(pValue);
if (pFunc && PyCallable_Check(pFunc))
{
pArgs = PyTuple_New(1);
- pValue = PyString_FromString(python_code.c_str());
+ pValue = PyBytes_FromString(python_code.c_str());
PyTuple_SetItem(pArgs, 0, pValue);
pValue = PyObject_CallObject(pFunc, pArgs);
if(pAttribute = checkAndGetAttribute(fpy, "name", errorMessage))
{
- if(not PyString_Check(pAttribute))
+ if(not PyBytes_Check(pAttribute))
{
errorMessage += "Attribute 'name' should be a string.\n";
Py_DECREF(pAttribute);
{
_functions.push_back(FunctionProperties());
FunctionProperties& fcpp = _functions.back();
- fcpp._name=PyString_AsString(pAttribute);
+ fcpp._name=PyBytes_AsString(pAttribute);
Py_DECREF(pAttribute);
if(pAttribute = checkAndGetAttribute(fpy, "inputs", errorMessage))
INCLUDE_DIRECTORIES(
${OMNIORB_INCLUDE_DIR}
${OMNIORB_ROOT_DIR}/include/omniORB4/internal
+ ${OMNIORBPY_INCLUDE_DIR}
${SALOME_INCL_PATH}
${PROJECT_SOURCE_DIR}/src/bases
${PROJECT_SOURCE_DIR}/src/engine
std::string InputCorbaPort::valToStr()
{
- int isString = PyString_Check(getPyObj());
+ int isString = PyBytes_Check(getPyObj());
PyObject *strPyObj = PyObject_Str(getPyObj());
- string val = PyString_AsString(strPyObj);
+ string val = PyBytes_AsString(strPyObj);
if (isString)
val = "\"" + val + "\"";
Py_DECREF(strPyObj);
std::string OutputCorbaPort::valToStr()
{
PyObject *strPyObj = PyObject_Str(getPyObj());
- string val = PyString_AsString(strPyObj);
+ string val = PyBytes_AsString(strPyObj);
Py_DECREF(strPyObj);
return val;
}
_errorDetails=msg.str();
throw Exception(msg.str());
}
- const char picklizeScript[]="import cPickle\ndef pickleForDistPyth2009(*args,**kws):\n return cPickle.dumps((args,kws),-1)\n\ndef unPickleForDistPyth2009(st):\n args=cPickle.loads(st)\n return args\n";
+ const char picklizeScript[]="import pickle\ndef pickleForDistPyth2009(*args,**kws):\n return pickle.dumps((args,kws),-1)\n\ndef unPickleForDistPyth2009(st):\n args=pickle.loads(st)\n return args\n";
PyObject *res=PyRun_String(picklizeScript,Py_file_input,_context,_context);
if(res == NULL)
{
PyTuple_SetItem(args,pos,ob);
}
PyObject *serializationInput=PyObject_CallObject(_pyfuncSer,args);
- std::string serializationInputC=PyString_AsString(serializationInput);
+ std::string serializationInputC=PyBytes_AsString(serializationInput);
serializationInputCorba=new Engines::pickledArgs;
int len=serializationInputC.length();
serializationInputCorba->length(serializationInputC.length());
{
AutoGIL agil;
args = PyTuple_New(1);
- PyObject* resultPython=PyString_FromString(resultCorbaC);
+ PyObject* resultPython=PyBytes_FromString(resultCorbaC);
delete [] resultCorbaC;
PyTuple_SetItem(args,0,resultPython);
PyObject *finalResult=PyObject_CallObject(_pyfuncUnser,args);
static PyTypeObject PyStdOut_Type = {
/* The ob_type field must be initialized in the module init function
* to be portable to Windows without using C++. */
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "PyOut", /*tp_name*/
- sizeof(PyStdOut), /*tp_basicsize*/
- 0, /*tp_itemsize*/
+ PyVarObject_HEAD_INIT(NULL, 0)
+ /*0,*/ /*ob_size*/
+ "PyOut", /*tp_name*/
+ sizeof(PyStdOut), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
/* methods */
(destructor)PyStdOut_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- PyObject_GenericGetAttr, /*tp_getattro*/
- /* softspace is writable: we must supply tp_setattro */
- PyObject_GenericSetAttr, /* tp_setattro */
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- 0, /*tp_doc*/
- 0, /*tp_traverse*/
- 0, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- PyStdOut_methods, /*tp_methods*/
- PyStdOut_memberlist, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- 0, /*tp_init*/
- 0, /*tp_alloc*/
- 0, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash*/
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ PyObject_GenericGetAttr, /*tp_getattro*/
+ /* softspace is writable: we must supply tp_setattro */
+ PyObject_GenericSetAttr, /* tp_setattro */
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ 0, /*tp_doc*/
+ 0, /*tp_traverse*/
+ 0, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ PyStdOut_methods, /*tp_methods*/
+ PyStdOut_memberlist, /*tp_members*/
+ 0, /*tp_getset*/
+ 0, /*tp_base*/
+ 0, /*tp_dict*/
+ 0, /*tp_descr_get*/
+ 0, /*tp_descr_set*/
+ 0, /*tp_dictoffset*/
+ 0, /*tp_init*/
+ 0, /*tp_alloc*/
+ 0, /*tp_new*/
+ 0, /*tp_free*/
+ 0, /*tp_is_gc*/
};
std::ostringstream oss; oss << "evalPy failed : " << errorDetails;
throw Exception(oss.str());
}
- AutoPyRef res(PyEval_EvalCode(reinterpret_cast<PyCodeObject *>((PyObject *)code),context,context));
+ AutoPyRef res(PyEval_EvalCode((PyObject *)code,context,context));
PyObject *ret(PyDict_GetItemString(context,funcName.c_str())); //borrowed ref
if(!ret)
throw YACS::Exception("evalPy : Error on returned func !");
using namespace YACS::ENGINE;
using namespace std;
-const char PythonEntry::SCRIPT_FOR_SIMPLE_SERIALIZATION[]="import cPickle\n"
+const char PythonEntry::SCRIPT_FOR_SIMPLE_SERIALIZATION[]="import pickle\n"
"def pickleForVarSimplePyth2009(val):\n"
- " return cPickle.dumps(val,-1)\n"
+ " return pickle.dumps(val,-1)\n"
"\n";
const char PythonNode::IMPL_NAME[]="Python";
const char PythonNode::KIND[]="Python";
-const char PythonNode::SCRIPT_FOR_SERIALIZATION[]="import cPickle\n"
+const char PythonNode::SCRIPT_FOR_SERIALIZATION[]="import pickle\n"
"def pickleForDistPyth2009(kws):\n"
- " return cPickle.dumps(((),kws),-1)\n"
+ " return pickle.dumps(((),kws),-1)\n"
"\n"
"def unPickleForDistPyth2009(st):\n"
- " args=cPickle.loads(st)\n"
+ " args=pickle.loads(st)\n"
" return args\n";
const char PythonNode::REMOTE_NAME[]="remote";
const char PythonNode::DPL_INFO_NAME[]="my_dpl_localization";
-const char PyFuncNode::SCRIPT_FOR_SERIALIZATION[]="import cPickle\n"
+const char PyFuncNode::SCRIPT_FOR_SERIALIZATION[]="import pickle\n"
"def pickleForDistPyth2009(*args,**kws):\n"
- " return cPickle.dumps((args,kws),-1)\n"
+ " return pickle.dumps((args,kws),-1)\n"
"\n"
"def unPickleForDistPyth2009(st):\n"
- " args=cPickle.loads(st)\n"
+ " args=pickle.loads(st)\n"
" return args\n";
//The pickled string may contain NULL characters so use PyString_AsStringAndSize
char *serializationInputC(0);
Py_ssize_t len;
- if (PyString_AsStringAndSize(serializationInput, &serializationInputC, &len))
+ if (PyBytes_AsStringAndSize(serializationInput, &serializationInputC, &len))
throw Exception("DistributedPythonNode problem in python pickle");
serializationInputCorba->length(len);
for(int i=0; i < len ; i++)
{
AutoGIL agil;
PyObject *args(0),*ob(0);
- PyObject* resultPython=PyString_FromStringAndSize(resultCorbaC,resultCorba->length());
+ PyObject* resultPython=PyBytes_FromStringAndSize(resultCorbaC,resultCorba->length());
delete [] resultCorbaC;
args = PyTuple_New(1);
PyTuple_SetItem(args,0,resultPython);
PyObject* code=Py_CompileString(_script.c_str(), stream.str().c_str(), Py_file_input);
if(code == NULL)
{
- _errorDetails="";
+ _errorDetails="";
PyObject* new_stderr = newPyStdOut(_errorDetails);
PySys_SetObject((char*)"stderr", new_stderr);
PyErr_Print();
Py_DECREF(new_stderr);
throw Exception("Error during execution");
}
- PyObject *res = PyEval_EvalCode((PyCodeObject *)code, _context, _context);
+ PyObject *res = PyEval_EvalCode( code, _context, _context);
Py_DECREF(code);
Py_XDECREF(res);
{
const std::pair<std::string,int>& p(ret[i]);
PyObject *elt(PyTuple_New(2));
- PyTuple_SetItem(elt,0,PyString_FromString(p.first.c_str()));
+ PyTuple_SetItem(elt,0,PyBytes_FromString(p.first.c_str()));
PyTuple_SetItem(elt,1,PyLong_FromLong(p.second));
PyList_SetItem(ob,i,elt);
}
Py_XDECREF(ob);
char *serializationInputC(0);
Py_ssize_t len;
- if (PyString_AsStringAndSize(serializationInput, &serializationInputC, &len))
+ if (PyBytes_AsStringAndSize(serializationInput, &serializationInputC, &len))
throw Exception("DistributedPythonNode problem in python pickle");
serializationInputCorba->length(len);
for(int i=0; i < len ; i++)
Py_DECREF(new_stderr);
throw Exception("Error during execution");
}
- PyObject *res = PyEval_EvalCode((PyCodeObject *)code, _context, _context);
+ PyObject *res = PyEval_EvalCode( code, _context, _context);
Py_DECREF(code);
Py_XDECREF(res);
//The pickled string may contain NULL characters so use PyString_AsStringAndSize
char *serializationInputC(0);
Py_ssize_t len;
- if (PyString_AsStringAndSize(serializationInput, &serializationInputC, &len))
+ if (PyBytes_AsStringAndSize(serializationInput, &serializationInputC, &len))
throw Exception("DistributedPythonNode problem in python pickle");
serializationInputCorba->length(len);
{
AutoGIL agil;
- PyObject *resultPython(PyString_FromStringAndSize(resultCorbaC,resultCorba->length()));
+ PyObject *resultPython(PyBytes_FromStringAndSize(resultCorbaC,resultCorba->length()));
delete [] resultCorbaC;
PyObject *args(PyTuple_New(1)),*ob(0);
PyTuple_SetItem(args,0,resultPython);
if (PyObject_HasAttrString(data, (char*)"_is_a"))
{
PyObject *result = PyObject_CallMethod(data, (char*)"_is_a", (char*)"s",(char*)"IDL:SALOME/GenericObj:1.0");
- if(result && PyInt_Check(result))
+ if(result && PyLong_Check(result))
{
- if(PyInt_AS_LONG(result))
+ if(PyLong_AS_LONG(result))
{
PyObject* o=PyObject_CallMethod(data, (char*)"Destroy", (char*)"");
if(o)
if (PyObject_HasAttrString(data, (char*)"_is_a"))
{
PyObject *result = PyObject_CallMethod(data, (char*)"_is_a", (char*)"s",(char*)"IDL:SALOME/GenericObj:1.0");
- if(result && PyInt_Check(result))
+ if(result && PyLong_Check(result))
{
- if(PyInt_AS_LONG(result))
+ if(PyLong_AS_LONG(result))
{
PyObject* o= PyObject_CallMethod(data, (char*)"Register", (char*)"") ;
if(o)
if(!ret)
return dump();
std::string retCpp;
- char *val(PyString_AsString(ret));
+ char *val(PyBytes_AsString(ret));
if(val)
retCpp=val;
Py_XDECREF(ret);
std::string InputPyPort::valToStr()
{
- int isString = PyString_Check(getPyObj());
+ int isString = PyBytes_Check(getPyObj());
//DEBTRACE("isString=" << isString);
PyObject *strPyObj = PyObject_Str(getPyObj());
//DEBTRACE(PyString_Size(strPyObj));
- string val = PyString_AsString(strPyObj);
+ string val = PyBytes_AsString(strPyObj);
if (isString)
val = "\"" + val + "\"";
//DEBTRACE(val);
std::string OutputPyPort::valToStr()
{
PyObject *strPyObj = PyObject_Str(getPyObj());
- string val = PyString_AsString(strPyObj);
+ string val = PyBytes_AsString(strPyObj);
Py_DECREF(strPyObj);
return val;
}
Py_InitializeEx(0); // do not install signal handlers
#endif
if (argc > 0 && argv != NULL)
- PySys_SetArgv(argc, argv);
+ {
+ wchar_t **changed_argv = new wchar_t*[argc];
+ for (int i = 0; i < argc; i++)
+ {
+ changed_argv[i] = Py_DecodeLocale(argv[i], NULL);
+ }
+ PySys_SetArgv(argc, changed_argv);
+ }
else
{
int pyArgc = 1;
char* pyArgv[1];
char defaultName[] = "SALOME_YACS_RUNTIME";
+ wchar_t **changed_pyArgv = new wchar_t*[pyArgc];
pyArgv[0] = defaultName;
- PySys_SetArgv(pyArgc, pyArgv);
+ for (int i = 0; i < pyArgc; i++)
+ {
+ changed_pyArgv[i] = Py_DecodeLocale(pyArgv[i], NULL);
+ }
+ PySys_SetArgv(pyArgc, changed_pyArgv);
}
PyEval_InitThreads(); /* Create (and acquire) the interpreter lock (for threads)*/
PyEval_SaveThread(); /* Release the thread state */
{
goto out;
}
- _api = (omniORBpyAPI*)PyCObject_AsVoidPtr(pyapi);
+ _api = (omniORBpyAPI*)PyCapsule_GetPointer(pyapi,"_omnipy.API");
Py_DECREF(pyapi);
res=PyRun_String("\n"
#include <Python.h>
#include <omniORB4/CORBA.h>
+#include <omniORBpy.h>
#include "Runtime.hxx"
#include<string>
#include<set>
-
-//--- from omniORBpy.h (not present on Debian Sarge packages)
-struct omniORBpyAPI
-{
- PyObject* (*cxxObjRefToPyObjRef)(const CORBA::Object_ptr cxx_obj,
- CORBA::Boolean hold_lock);
- // Convert a C++ object reference to a Python object reference.
- // If <hold_lock> is true, caller holds the Python interpreter lock.
-
- CORBA::Object_ptr (*pyObjRefToCxxObjRef)(PyObject* py_obj,
- CORBA::Boolean hold_lock);
- // Convert a Python object reference to a C++ object reference.
- // Raises BAD_PARAM if the Python object is not an object reference.
- // If <hold_lock> is true, caller holds the Python interpreter lock.
-
- PyObject* (*handleCxxSystemException)(const CORBA::SystemException& ex);
- // Sets the Python exception state to reflect the given C++ system
- // exception. Always returns NULL. The caller must hold the Python
- // interpreter lock.
-};
-//--- end of from omniORBpy.h (not present on Debian Sarge packages)
namespace YACS
{
cerr << "---------------SalomePythonNode::load function---------------" << endl;
list<OutputPort *>::iterator iter;
string value2Export=((SalomePythonComponent*)_component)->getStringValueToExportInInterp(this);
- PyObject* ob=PyString_FromString(value2Export.c_str());
+ PyObject* ob=PyBytes_FromString(value2Export.c_str());
PyDict_SetItemString(_context,PLACEMENT_VAR_NAME_IN_INTERP,ob);
for(iter = _setOfOutputPort.begin(); iter != _setOfOutputPort.end(); iter++)
{
${CPPUNIT_INCLUDE_DIRS}
${PYTHON_INCLUDE_DIR}
${OMNIORB_INCLUDE_DIR}
+ ${OMNIORBPY_INCLUDE_DIR}
${KERNEL_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/..
${CMAKE_CURRENT_SOURCE_DIR}/../../bases
INSTALL(TARGETS echo_clt DESTINATION ${LOCAL_TEST_DIR})
INSTALL(FILES CTestTestfileInstall.cmake
DESTINATION ${LOCAL_TEST_DIR}
- RENAME CTestTestfile.cmake)
\ No newline at end of file
+ RENAME CTestTestfile.cmake)
((ElementaryNode*)_nodeMap["Node_10"])->load();
((ElementaryNode*)_nodeMap["Node_10"])->execute();
// CPPUNIT_ASSERT_DOUBLES_EQUAL(10.51, (ElementaryNode*)_nodeMap["Node_10"])
-
+ std::cerr << __LINE__ << std::endl;
DEBTRACE(" --- execution Python Node_11" );
+ std::cerr << __LINE__ << std::endl;
((ElementaryNode*)_nodeMap["Node_11"])->load();
+ std::cerr << __LINE__ << std::endl;
((ElementaryNode*)_nodeMap["Node_11"])->execute();
+ std::cerr << __LINE__ << std::endl;
DEBTRACE(" --- execution Python Node_12" );
((ElementaryNode*)_nodeMap["Node_12"])->load();
((ElementaryNode*)_nodeMap["Node_12"])->execute();
+ std::cerr << __LINE__ << std::endl;
DEBTRACE(" --- execution CORBA Node_16" );
((ElementaryNode*)_nodeMap["Node_16"])->load();
((ElementaryNode*)_nodeMap["Node_16"])->execute();
+ std::cerr << __LINE__ << std::endl;
DEBTRACE(" --- execution CORBA Node_17" );
((ElementaryNode*)_nodeMap["Node_17"])->load();
((ElementaryNode*)_nodeMap["Node_17"])->execute();
+ std::cerr << __LINE__ << std::endl;
DEBTRACE(" --- execution CORBA Node_18" );
((ElementaryNode*)_nodeMap["Node_18"])->load();
((ElementaryNode*)_nodeMap["Node_18"])->execute();
+ std::cerr << __LINE__ << std::endl;
DEBTRACE(" --- execution CORBA Node_19" );
((ElementaryNode*)_nodeMap["Node_19"])->load();
((ElementaryNode*)_nodeMap["Node_19"])->execute();
+ std::cerr << __LINE__ << std::endl;
DEBTRACE(" --- execution CORBA Node_20" );
((ElementaryNode*)_nodeMap["Node_20"])->load();
((ElementaryNode*)_nodeMap["Node_20"])->execute();
+ std::cerr << __LINE__ << std::endl;
DEBTRACE(" --- execution CORBA Node_21" );
((ElementaryNode*)_nodeMap["Node_21"])->load();
((ElementaryNode*)_nodeMap["Node_21"])->execute();
+ std::cerr << __LINE__ << std::endl;
DEBTRACE(" --- execution CORBA Node_29" );
((ElementaryNode*)_nodeMap["Node_29"])->load();
((ElementaryNode*)_nodeMap["Node_29"])->execute();
+ std::cerr << __LINE__ << std::endl;
DEBTRACE(" --- execution Python Node_13" );
((ElementaryNode*)_nodeMap["Node_13"])->load();
((ElementaryNode*)_nodeMap["Node_13"])->execute();
+ std::cerr << __LINE__ << std::endl;
DEBTRACE(" --- execution CORBA Node_22" );
((ElementaryNode*)_nodeMap["Node_22"])->load();
((ElementaryNode*)_nodeMap["Node_22"])->execute();
+ std::cerr << __LINE__ << std::endl;
DEBTRACE(" --- execution CORBA Node_23" );
((ElementaryNode*)_nodeMap["Node_23"])->load();
((ElementaryNode*)_nodeMap["Node_23"])->execute();
+ std::cerr << __LINE__ << std::endl;
DEBTRACE(" --- execution CORBA Node_24" );
((ElementaryNode*)_nodeMap["Node_24"])->load();
((ElementaryNode*)_nodeMap["Node_24"])->execute();
+ std::cerr << __LINE__ << std::endl;
DEBTRACE(" --- execution CORBA Node_27" );
((ElementaryNode*)_nodeMap["Node_27"])->load();
((ElementaryNode*)_nodeMap["Node_27"])->execute();
+ std::cerr << __LINE__ << std::endl;
DEBTRACE(" --- execution CORBA Node_28" );
((ElementaryNode*)_nodeMap["Node_28"])->load();
((ElementaryNode*)_nodeMap["Node_28"])->execute();
+ std::cerr << __LINE__ << std::endl;
DEBTRACE(" --- execution CORBA Node_30" );
((ElementaryNode*)_nodeMap["Node_30"])->load();
((ElementaryNode*)_nodeMap["Node_30"])->execute();
+ std::cerr << __LINE__ << std::endl;
DEBTRACE(" --- execution CORBA Node_32" );
((ElementaryNode*)_nodeMap["Node_32"])->load();
((ElementaryNode*)_nodeMap["Node_32"])->execute();
+ std::cerr << __LINE__ << std::endl;
DEBTRACE(" --- execution CORBA Node_26" );
((ElementaryNode*)_nodeMap["Node_26"])->load();
((ElementaryNode*)_nodeMap["Node_26"])->execute();
+ std::cerr << __LINE__ << std::endl;
DEBTRACE(" --- execution CORBA Node_31" );
((ElementaryNode*)_nodeMap["Node_31"])->load();
((ElementaryNode*)_nodeMap["Node_31"])->execute();
+ std::cerr << __LINE__ << std::endl;
DEBTRACE(" --- execution Python Node_14" );
((ElementaryNode*)_nodeMap["Node_14"])->load();
((ElementaryNode*)_nodeMap["Node_14"])->execute();
+ std::cerr << __LINE__ << std::endl;
DEBTRACE(" --- execution Python Node_15" );
((ElementaryNode*)_nodeMap["Node_15"])->load();
((ElementaryNode*)_nodeMap["Node_15"])->execute();
+ std::cerr << __LINE__ << std::endl;
DEBTRACE(" --- execution XML Node_36" );
((ElementaryNode*)_nodeMap["Node_36"])->load();
((ElementaryNode*)_nodeMap["Node_36"])->execute();
+ std::cerr << __LINE__ << std::endl;
DEBTRACE(" --- execution CORBA Node_33" );
((ElementaryNode*)_nodeMap["Node_33"])->load();
((ElementaryNode*)_nodeMap["Node_33"])->execute();
+ std::cerr << __LINE__ << std::endl;
DEBTRACE(" --- execution CORBA Node_34" );
((ElementaryNode*)_nodeMap["Node_34"])->load();
((ElementaryNode*)_nodeMap["Node_34"])->execute();
+ std::cerr << __LINE__ << std::endl;
DEBTRACE(" --- execution CORBA Node_35" );
((ElementaryNode*)_nodeMap["Node_35"])->load();
((ElementaryNode*)_nodeMap["Node_35"])->execute();
+ std::cerr << __LINE__ << std::endl;
DEBTRACE(" --- end of execution" );
}
double x;
if (PyFloat_Check(o))
x=PyFloat_AS_DOUBLE(o);
- else if (PyInt_Check(o))
- x=PyInt_AS_LONG(o);
else if(PyLong_Check(o))
x=PyLong_AsLong(o);
else
static inline long convert(const TypeCode *t,PyObject* o,void*)
{
long l;
- if (PyInt_Check(o))
- l=PyInt_AS_LONG(o);
- else if(PyLong_Check(o))
+ if(PyLong_Check(o))
l=PyLong_AsLong(o);
else
{
static inline std::string convert(const TypeCode *t,PyObject* o,void*)
{
std::string s;
- if (PyString_Check(o))
- s= PyString_AS_STRING(o);
+ if (PyBytes_Check(o))
+ s= PyBytes_AS_STRING(o);
else
{
stringstream msg;
bool l;
if (PyBool_Check(o))
l=(o==Py_True);
- else if (PyInt_Check(o))
- l=(PyInt_AS_LONG(o)!=0);
else if(PyLong_Check(o))
l=(PyLong_AsLong(o)!=0);
else
{
static inline std::string convert(const TypeCode *t,PyObject* o,void*,int protocol)
{
- if (PyString_Check(o) && strncmp(t->id(),"python",6)!=0)
+ if (PyBytes_Check(o) && strncmp(t->id(),"python",6)!=0)
{
// the objref is used by Python as a string (prefix:value) keep it as a string
- return PyString_AS_STRING(o);
+ return PyBytes_AS_STRING(o);
}
if(strncmp(t->id(),"python",6)==0)
{
// It's a native Python object pickle it
- PyObject* mod=PyImport_ImportModule("cPickle");
+ PyObject* mod=PyImport_ImportModule("pickle");
PyObject *pickled=PyObject_CallMethod(mod,(char *)"dumps",(char *)"Oi",o,protocol);
DEBTRACE(PyObject_REPR(pickled) );
Py_DECREF(mod);
PyErr_Print();
throw YACS::ENGINE::ConversionException("Problem in convertToYacsObjref<PYTHONImpl");
}
- std::string mystr(PyString_AsString(pickled),PyString_Size(pickled));
+ std::string mystr(PyBytes_AsString(pickled),PyBytes_Size(pickled));
Py_DECREF(pickled);
return mystr;
}
PyErr_Print();
throw YACS::ENGINE::ConversionException("Problem in convertToYacsObjref<PYTHONImpl");
}
- std::string mystr=PyString_AsString(pickled);
+ std::string mystr=PyBytes_AsString(pickled);
Py_DECREF(pickled);
return mystr;
}
PyErr_Print();
throw YACS::ENGINE::ConversionException("Problem in convertToYacsObjref<PYTHONImpl");
}
- std::string mystr=PyString_AsString(pystring);
+ std::string mystr=PyBytes_AsString(pystring);
Py_DECREF(pystring);
return mystr;
}
{
static inline PyObject* convert(const TypeCode *t,std::string& o)
{
- return PyString_FromString(o.c_str());
+ return PyBytes_FromString(o.c_str());
}
};
template <>
if(t->isA(Runtime::_tc_file))
{
//It's an objref file. Convert it specially
- return PyString_FromString(o.c_str());
+ return PyBytes_FromString(o.c_str());
}
if(strncmp(t->id(),"python",6)==0)
{
//It's a python pickled object, unpickled it
- PyObject* mod=PyImport_ImportModule("cPickle");
+ PyObject* mod=PyImport_ImportModule("pickle");
PyObject *ob=PyObject_CallMethod(mod,(char *)"loads",(char *)"s#",o.c_str(),o.length());
DEBTRACE(PyObject_REPR(ob));
Py_DECREF(mod);
}
PyGILState_STATE gstate = PyGILState_Ensure();
- PyObject* mod=PyImport_ImportModule("cPickle");
+ PyObject* mod=PyImport_ImportModule("pickle");
PyObject *ob=PyObject_CallMethod(mod,(char *)"loads",(char *)"s#",s,buffer->length());
PyObject *pickled=PyObject_CallMethod(mod,(char *)"dumps",(char *)"Oi",ob,protocol);
DEBTRACE(PyObject_REPR(pickled));
- std::string mystr=PyString_AsString(pickled);
+ std::string mystr=PyBytes_AsString(pickled);
Py_DECREF(mod);
Py_DECREF(ob);
Py_DECREF(pickled);
PyObject *s;
PyGILState_STATE gstate = PyGILState_Ensure();
s=PyObject_Str(ob);
- std::string ss(PyString_AsString(s),PyString_Size(s));
+ std::string ss(PyBytes_AsString(s),PyBytes_Size(s));
Py_DECREF(s);
PyGILState_Release(gstate);
return ss;
{
if (PyFloat_Check(o))
return true;
- else if (PyInt_Check(o))
- return true;
else if(PyLong_Check(o))
return true;
else
template<>
inline bool checkInt<PYTHONImpl,PyObject*,void*>(const TypeCode *t,PyObject* o,void* aux)
{
- if (PyInt_Check(o) || PyLong_Check(o))
+ if (PyLong_Check(o))
return true;
else
{
{
if (PyBool_Check(o))
return true;
- else if (PyInt_Check(o))
- return true;
else if(PyLong_Check(o))
return true;
else
template<>
inline bool checkString<PYTHONImpl,PyObject*,void*>(const TypeCode *t,PyObject* o,void* aux)
{
- if (PyString_Check(o))
+ if (PyBytes_Check(o))
return true;
else
{
template<>
inline bool checkObjref<PYTHONImpl,PyObject*,void*>(const TypeCode *t,PyObject* o,void* aux)
{
- if (PyString_Check(o))
+ if (PyBytes_Check(o))
return true;
if(strncmp(t->id(),"python",6)==0) // a Python object is expected (it's always true)
return true;
${SALOME_INCL_PATH}
${PTHREAD_INCLUDE_DIRS}
${OMNIORB_INCLUDE_DIR}
+ ${OMNIORBPY_INCLUDE_DIR}
${LIBXML2_INCLUDE_DIR}
${PYTHON_INCLUDE_DIRS}
${PROJECT_BINARY_DIR}/idl
if (!omnipy)
{
PyErr_SetString(PyExc_ImportError,(char*)"Cannot import _omnipy");
- return;
+ return NULL;
}
PyObject* pyapi = PyObject_GetAttrString(omnipy, (char*)"API");
- api = (omniORBPYAPI*)PyCObject_AsVoidPtr(pyapi);
+ api = (omniORBpyAPI*)PyCapsule_GetPointer(pyapi,"_omnipy.API");
Py_DECREF(pyapi);
%}
# additional include directories
INCLUDE_DIRECTORIES(
${OMNIORB_INCLUDE_DIR}
+ ${OMNIORBPY_INCLUDE_DIR}
${PYTHON_INCLUDE_DIR}
${PROJECT_SOURCE_DIR}/src/bases
${PROJECT_SOURCE_DIR}/src/engine
${CPPUNIT_INCLUDE_DIRS}
${PYTHON_INCLUDE_DIR}
${OMNIORB_INCLUDE_DIR}
+ ${OMNIORBPY_INCLUDE_DIR}
${KERNEL_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/..
${CMAKE_CURRENT_SOURCE_DIR}/../../bases
if (p)
{
PyObject *data = ((OutputPyPort*)p->nodeMap["node2"]->getOutputPort("p1"))->get();
- char *text = PyString_AsString(data);
+ char *text = PyBytes_AsString(data);
CPPUNIT_ASSERT_EQUAL(string("coucoucoucoucoucoucoucou"), string(text));
delete p;
}
if (p)
{
PyObject *data = ((OutputPyPort*)p->nodeMap["node2"]->getOutputPort("p1"))->get();
- char *text = PyString_AsString(data);;
+ char *text = PyBytes_AsString(data);;
CPPUNIT_ASSERT_EQUAL(string("coucoucoucoucoucoucoucou"), string(text) );
delete p;
}
INCLUDE_DIRECTORIES(
${CPPUNIT_INCLUDE_DIRS}
${PTHREADS_INCLUDE_DIRS}
+ ${OMNIORBPY_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/
${CMAKE_CURRENT_SOURCE_DIR}/..
${CMAKE_CURRENT_SOURCE_DIR}/../../bases
${PROJECT_SOURCE_DIR}/src/yacsloader
${PROJECT_BINARY_DIR}/src/engine_swig
${OMNIORB_INCLUDE_DIR}
+ ${OMNIORBPY_INCLUDE_DIR}
${PYTHON_INCLUDE_DIRS}
)
YACSEvalParamsForCluster& ps(res->getAddParamsForCluster());
_clusterAdvInfo->applyToParams(ps);
}
- emit readyForRunSignal(true);
+ Q_EMIT readyForRunSignal(true);
}
QString YDFXGUIHostParametrizer::getNameOfHost()
ok->setDisabled(!isInterac && !_clusterAdvInfo->isOK());
if(_wasInteractive!=isInterac)
{
- emit interactivityChanged(isInterac);
+ Q_EMIT interactivityChanged(isInterac);
_wasInteractive=isInterac;
}
}
}
bool newOK(isOK());
_wasOK=newOK;
- emit statusOfEntryChanged(newOK);
+ Q_EMIT statusOfEntryChanged(newOK);
}
void YDFXGUIBatchInfo::learnSettings(QSettings& settings) const
void YDFXGUIBatchInfo::somethingChanged()
{
- emit statusOfEntryChanged(isOK());
+ Q_EMIT statusOfEntryChanged(isOK());
}
QString YDFXGUIBatchInfo::NormalizeDuration(const QString& txt)
#include <QThread>
#include <QMutex>
-#include "Python.h"
-
class YACSEvalSession;
class YACSEvalYFXWrap;
class YDFXGUIAllPorts;
{
if(wasKO)
{
- emit statusChanged();
+ Q_EMIT statusChanged();
disconnect(this,SIGNAL(changeLook()),this,SLOT(applyModificationOfLook()));
}
}
bool oldOK(isOK());
bool oldStatus(_inp->isRandomVar());
_inp->declareRandomnessStatus(!oldStatus);
- emit statusChanged(); // always emit because this even if newOK and oldOK are the same the upon status can changed !
+ Q_EMIT statusChanged(); // always Q_EMIT because this even if newOK and oldOK are the same the upon status can changed !
updateGeometry();
update();
return _inp->isRandomVar();
void InputLabel::pressOccured()
{
- emit randomnessStatusChanged();
+ Q_EMIT randomnessStatusChanged();
}
std::vector<ColoredString> InputLabel::textForEmulatedPushButton() const
{
bool oldStatus(_outp->isQOfInterest());
_outp->setQOfInterestStatus(!oldStatus);
- emit clicked();
+ Q_EMIT clicked();
}
std::vector<ColoredString> OutputLabel::textForEmulatedPushButton() const
update();
setWasOKStatus(newStatus);
}
- emit theGlobalStatusChanged(newStatus);// emit signal always because of input ports and sequences definitions.
+ Q_EMIT theGlobalStatusChanged(newStatus);// Q_EMIT signal always because of input ports and sequences definitions.
}
//////////////////
YDFXGUIInputPortValueEditor *childc(qobject_cast<YDFXGUIInputPortValueEditor *>(child));
if(childc)
{
- emit childc->changeLook();
+ Q_EMIT childc->changeLook();
}
}
}
bool step1(_in->isOK() && _out->isOK());
if(!step1)
{
- emit sequencesCanBeDefinedSignal(false);
- emit canBeExecutedSignal(false);
+ Q_EMIT sequencesCanBeDefinedSignal(false);
+ Q_EMIT canBeExecutedSignal(false);
return ;
}
- emit sequencesCanBeDefinedSignal(true);
- emit canBeExecutedSignal(_in->areSeqWellDefined());
+ Q_EMIT sequencesCanBeDefinedSignal(true);
+ Q_EMIT canBeExecutedSignal(_in->areSeqWellDefined());
}
//
// Author : Anthony Geay (EDF R&D)
+#include "YDFXGUIPyThreadSaver.hxx"
#include "YDFXGUIPushButtons.hxx"
#include "YDFXGUIWrap.hxx"
#include "YDFXGUISeqInit.hxx"
-#include "YDFXGUIPyThreadSaver.hxx"
#include "YDFXGUIHostParametrizer.hxx"
#include "YACSEvalSession.hxx"
if(dial.exec())
{
_state=zeWidget->saveState();
- emit sequenceWellDefined(true);
+ Q_EMIT sequenceWellDefined(true);
}
}
std::fill(_items.begin(),_items.end(),0);
_computationInProgress=true;
_mut.unlock();
- emit somethingChanged();
+ Q_EMIT somethingChanged();
}
void YDFXGUIRunInfo::endComputation()
_mut.lock();
_computationInProgress=false;
_mut.unlock();
- emit somethingChanged();
+ Q_EMIT somethingChanged();
}
void YDFXGUIRunInfo::sampleOK(int pos)
_mut.lock();
_items[pos]=1;
_mut.unlock();
- emit somethingChanged();
+ Q_EMIT somethingChanged();
}
void YDFXGUIRunInfo::sampleKO(int pos)
_mut.lock();
_items[pos]=2;
_mut.unlock();
- emit somethingChanged();
+ Q_EMIT somethingChanged();
}
std::vector<char> YDFXGUIRunInfo::getItems() const
#ifndef __YDFXGUIPYTHREADSAVER_HXX__
#define __YDFXGUIPYTHREADSAVER_HXX__
+#include "Python.h"
+
#include "ydfxwidgetsExport.hxx"
-#include "Python.h"
class QThread;
//
// Author : Anthony Geay (EDF R&D)
+#include "Python.h"
#include "YDFXGUISeqInit.hxx"
#include <QFile>
#include <QFileDialog>
#include <QApplication>
-#include "Python.h"
#include "AutoGIL.hxx"
//
if(_fileName.isEmpty())
{
- emit problemDetected(QString("For \"%1\" : no file defined !").arg(zeBossc->getName()));
+ Q_EMIT problemDetected(QString("For \"%1\" : no file defined !").arg(zeBossc->getName()));
return false;
}
QFile file(_fileName);
double v(line2.toDouble(&isOK));
if(!isOK)
{
- emit problemDetected(QString("For \"%1\" : At line %2 it is not a float !").arg(zeBossc->getName()).arg(i));
+ Q_EMIT problemDetected(QString("For \"%1\" : At line %2 it is not a float !").arg(zeBossc->getName()).arg(i));
return false;
}
_vect.push_back(v);
AutoPyRef code(Py_CompileString(txt.c_str(),TMP_FILENAME, Py_file_input));
if(code.get() == NULL)
{
- emit problemDetected(QString("For \"%1\" : python code is invalid !").arg(zeBossc->getName()));
+ Q_EMIT problemDetected(QString("For \"%1\" : python code is invalid !").arg(zeBossc->getName()));
return false;
}
AutoPyRef context(PyDict_New());
PyDict_SetItemString( context, "__builtins__", PyEval_GetBuiltins() );
- AutoPyRef res(PyEval_EvalCode((PyCodeObject *)code.get(), context, context));
+ AutoPyRef res(PyEval_EvalCode(code.get(), context, context));
PyObject *item(PyDict_GetItemString(context,name.c_str()));
//
if(!item)
{
- emit problemDetected(QString("For \"%1\" : Py var %1 is not defined !").arg(zeBossc->getName()));
+ Q_EMIT problemDetected(QString("For \"%1\" : Py var %1 is not defined !").arg(zeBossc->getName()));
return false;
}
if(!PyList_Check(item))
{
- emit problemDetected(QString("For \"%1\" : Py var %1 must be a list !").arg(zeBossc->getName()));
+ Q_EMIT problemDetected(QString("For \"%1\" : Py var %1 must be a list !").arg(zeBossc->getName()));
return false;
}
sz=PyList_Size(item);
PyObject *val(PyList_GetItem(item,i));
if(!PyFloat_Check(val))
{
- emit problemDetected(QString("For \"%1\" : At pos %2 of python list, it is not a float !").arg(zeBossc->getName()).arg(i));
+ Q_EMIT problemDetected(QString("For \"%1\" : At pos %2 of python list, it is not a float !").arg(zeBossc->getName()).arg(i));
return false;
}
_vect[i]=PyFloat_AS_DOUBLE(val);
connect(_combo,SIGNAL(currentIndexChanged(int)),this,SLOT(typeOfAssignmentChanged(int)));
horizontalLayout->addWidget(_setter);
_combo->setCurrentIndex(0);
- emit _combo->currentIndexChanged(0);//to be sure to sync widgets
+ Q_EMIT _combo->currentIndexChanged(0);//to be sure to sync widgets
}
void YDFXGUISeqLine::loadState(const QMap<QString,QString>& state)
{
int sz;
bool verdict(checkConsistency(sz));
- emit configurationIsOK(verdict);
+ Q_EMIT configurationIsOK(verdict);
}
void YDFXGUISeqInitEff::applyOnEFX()
refSz=locSz;
if(locSz!=refSz)
{
- emit line->setter()->problemDetected(QString("Var %1 does not have the same number of elts than others !").arg(line->getName()));
+ Q_EMIT line->setter()->problemDetected(QString("Var %1 does not have the same number of elts than others !").arg(line->getName()));
return false;
}
}
void YACSEvalYFXWrap::unlockAll()
{
_efx->unlockAll();
- emit lockSignal(false);
+ Q_EMIT lockSignal(false);
}
void YACSEvalYFXWrap::lockPortsForEvaluation()
_efx->lockPortsForEvaluation(inps2,outps2);
_efx->giveResources();//do not remove this line to generate resource info
if(!lockedOrNot)
- emit lockSignal(true);
+ Q_EMIT lockSignal(true);
}
int YACSEvalYFXWrap::getNbOfItems() const
void YACSEvalYFXWrap::setRunningStatus(bool status)
{
if(_isRunning!=status)
- emit runSignal(status);
+ Q_EMIT runSignal(status);
_isRunning=status;
}
if(_isSeqOfValsSet!=newStatus)
{
_isSeqOfValsSet=newStatus;
- emit sequencesAreSetSignal(_isSeqOfValsSet);
+ Q_EMIT sequencesAreSetSignal(_isSeqOfValsSet);
}
}