mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-28 00:30:33 +05:00
INT PAL 0052942: Error of geompy.MakeCurveParametric() is printed to a terminal instead of the Python Console
- Correct fix now
This commit is contained in:
parent
007a4cd246
commit
0138a9d57c
@ -78,105 +78,105 @@
|
|||||||
* =========== PYTHON ==============
|
* =========== PYTHON ==============
|
||||||
* ==================================*/
|
* ==================================*/
|
||||||
|
|
||||||
typedef struct {
|
namespace
|
||||||
PyObject_HEAD
|
{
|
||||||
int softspace;
|
typedef struct {
|
||||||
std::string *out;
|
PyObject_HEAD
|
||||||
|
int softspace;
|
||||||
|
std::string *out;
|
||||||
} PyStdOut;
|
} PyStdOut;
|
||||||
|
|
||||||
|
static void
|
||||||
|
PyStdOut_dealloc(PyStdOut *self)
|
||||||
|
{
|
||||||
|
PyObject_Del(self);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static PyObject*
|
||||||
PyStdOut_dealloc(PyStdOut *self)
|
PyStdOut_write(PyStdOut* self, PyObject* args)
|
||||||
{
|
{
|
||||||
PyObject_Del(self);
|
char *c;
|
||||||
|
int l;
|
||||||
|
if (!PyArg_ParseTuple(args, "t#:write", &c, &l))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
*(self->out) = *(self->out) + c;
|
||||||
|
|
||||||
|
Py_INCREF(Py_None);
|
||||||
|
return Py_None;
|
||||||
|
}
|
||||||
|
|
||||||
|
static PyMethodDef PyStdOut_methods[] = {
|
||||||
|
{"write", (PyCFunction)PyStdOut_write, METH_VARARGS,
|
||||||
|
PyDoc_STR("write(string) -> None")},
|
||||||
|
{NULL, NULL} /* sentinel */
|
||||||
|
};
|
||||||
|
|
||||||
|
static PyMemberDef PyStdOut_memberlist[] = {
|
||||||
|
{(char*)"softspace", T_INT, offsetof(PyStdOut, softspace), 0,
|
||||||
|
(char*)"flag indicating that a space needs to be printed; used by print"},
|
||||||
|
{NULL} /* Sentinel */
|
||||||
|
};
|
||||||
|
|
||||||
|
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*/
|
||||||
|
/* 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*/
|
||||||
|
};
|
||||||
|
|
||||||
|
PyObject* newPyStdOut( std::string& out )
|
||||||
|
{
|
||||||
|
PyStdOut* self = PyObject_New(PyStdOut, &PyStdOut_Type);
|
||||||
|
if (self) {
|
||||||
|
self->softspace = 0;
|
||||||
|
self->out=&out;
|
||||||
|
}
|
||||||
|
return (PyObject*)self;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
|
||||||
PyStdOut_write(PyStdOut *self, PyObject *args)
|
|
||||||
{
|
|
||||||
char *c;
|
|
||||||
int l;
|
|
||||||
if (!PyArg_ParseTuple(args, "t#:write",&c, &l))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
//std::cerr << c ;
|
|
||||||
*(self->out)=*(self->out)+c;
|
|
||||||
|
|
||||||
Py_INCREF(Py_None);
|
|
||||||
return Py_None;
|
|
||||||
}
|
|
||||||
|
|
||||||
static PyMethodDef PyStdOut_methods[] = {
|
|
||||||
{"write", (PyCFunction)PyStdOut_write, METH_VARARGS,
|
|
||||||
PyDoc_STR("write(string) -> None")},
|
|
||||||
{NULL, NULL} /* sentinel */
|
|
||||||
};
|
|
||||||
|
|
||||||
static PyMemberDef PyStdOut_memberlist[] = {
|
|
||||||
{(char*)"softspace", T_INT, offsetof(PyStdOut, softspace), 0,
|
|
||||||
(char*)"flag indicating that a space needs to be printed; used by print"},
|
|
||||||
{NULL} /* Sentinel */
|
|
||||||
};
|
|
||||||
|
|
||||||
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*/
|
|
||||||
/* 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*/
|
|
||||||
};
|
|
||||||
|
|
||||||
PyObject * newPyStdOut( std::string& out )
|
|
||||||
{
|
|
||||||
PyStdOut *self;
|
|
||||||
self = PyObject_New(PyStdOut, &PyStdOut_Type);
|
|
||||||
if (self == NULL)
|
|
||||||
return NULL;
|
|
||||||
self->softspace = 0;
|
|
||||||
self->out=&out;
|
|
||||||
return (PyObject*)self;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////END PYTHON///////////////////////////
|
////////////////////////END PYTHON///////////////////////////
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
/*!
|
/*!
|
||||||
@ -996,7 +996,6 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCurveParametric
|
|||||||
PyObject* main_dict = PyModule_GetDict(main_mod);
|
PyObject* main_dict = PyModule_GetDict(main_mod);
|
||||||
|
|
||||||
PyObject* obj = PyRun_String(aPyScript.ToCString(), Py_file_input, main_dict, NULL);
|
PyObject* obj = PyRun_String(aPyScript.ToCString(), Py_file_input, main_dict, NULL);
|
||||||
printf("%s\n", aPyScript.ToCString());
|
|
||||||
|
|
||||||
if (obj == NULL) {
|
if (obj == NULL) {
|
||||||
SetErrorCode("Error during executing of python script !!!");
|
SetErrorCode("Error during executing of python script !!!");
|
||||||
@ -1022,15 +1021,14 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCurveParametric
|
|||||||
else
|
else
|
||||||
coords = PyObject_CallFunction(func,(char*)"(d, d, d)", theParamMin, theParamMax, theParamStep );
|
coords = PyObject_CallFunction(func,(char*)"(d, d, d)", theParamMin, theParamMax, theParamStep );
|
||||||
|
|
||||||
PyObject* new_stderr = NULL;
|
|
||||||
|
|
||||||
if (coords == NULL){
|
if (coords == NULL){
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
std::string err_description="";
|
std::string err_description="";
|
||||||
new_stderr = newPyStdOut(err_description);
|
PyObject* new_stderr = newPyStdOut(err_description);
|
||||||
|
PyObject* old_stderr = PySys_GetObject((char*)"stderr");
|
||||||
PySys_SetObject((char*)"stderr", new_stderr);
|
PySys_SetObject((char*)"stderr", new_stderr);
|
||||||
PyErr_Print();
|
PyErr_Print();
|
||||||
PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
|
PySys_SetObject((char*)"stderr", old_stderr);
|
||||||
Py_DECREF(new_stderr);
|
Py_DECREF(new_stderr);
|
||||||
MESSAGE("Can't evaluate coordCalculator()" << " error is " << err_description);
|
MESSAGE("Can't evaluate coordCalculator()" << " error is " << err_description);
|
||||||
SetErrorCode("Can't evaluate the expressions, please check them !!!");
|
SetErrorCode("Can't evaluate the expressions, please check them !!!");
|
||||||
|
@ -295,7 +295,7 @@ def ManageTransactions(theOpeName):
|
|||||||
## Raise an Error, containing the Method_name, if Operation is Failed
|
## Raise an Error, containing the Method_name, if Operation is Failed
|
||||||
## @ingroup l1_geomBuilder_auxiliary
|
## @ingroup l1_geomBuilder_auxiliary
|
||||||
def RaiseIfFailed (Method_name, Operation):
|
def RaiseIfFailed (Method_name, Operation):
|
||||||
if Operation.IsDone() == 0 and Operation.GetErrorCode() != "NOT_FOUND_ANY":
|
if not Operation.IsDone() and Operation.GetErrorCode() != "NOT_FOUND_ANY":
|
||||||
raise RuntimeError, Method_name + " : " + Operation.GetErrorCode()
|
raise RuntimeError, Method_name + " : " + Operation.GetErrorCode()
|
||||||
|
|
||||||
## Return list of variables value from salome notebook
|
## Return list of variables value from salome notebook
|
||||||
@ -2414,7 +2414,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
|
|||||||
anObj = self.CurvesOp.MakeCurveParametricNew(thexExpr,theyExpr,thezExpr,theParamMin,theParamMax,theParamStep,theCurveType)
|
anObj = self.CurvesOp.MakeCurveParametricNew(thexExpr,theyExpr,thezExpr,theParamMin,theParamMax,theParamStep,theCurveType)
|
||||||
else:
|
else:
|
||||||
anObj = self.CurvesOp.MakeCurveParametric(thexExpr,theyExpr,thezExpr,theParamMin,theParamMax,theParamStep,theCurveType)
|
anObj = self.CurvesOp.MakeCurveParametric(thexExpr,theyExpr,thezExpr,theParamMin,theParamMax,theParamStep,theCurveType)
|
||||||
RaiseIfFailed("MakeSplineInterpolation", self.CurvesOp)
|
RaiseIfFailed("MakeCurveParametric", self.CurvesOp)
|
||||||
anObj.SetParameters(Parameters)
|
anObj.SetParameters(Parameters)
|
||||||
self._autoPublish(anObj, theName, "curve")
|
self._autoPublish(anObj, theName, "curve")
|
||||||
return anObj
|
return anObj
|
||||||
|
Loading…
Reference in New Issue
Block a user