MCPcopy Create free account
hub / github.com/SimpleITK/SimpleITK / Execute

Method Execute

Wrapping/Python/sitkPyCommand.cxx:95–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95void
96PyCommand::Execute()
97{
98 // if null do nothing
99 if (!this->m_Object)
100 {
101 return;
102 }
103
104 // make sure that the CommandCallable is in fact callable
105 if (!PyCallable_Check(this->m_Object))
106 {
107 // we throw a standard ITK exception: this makes it possible for
108 // our standard CableSwig exception handling logic to take this
109 // through to the invoking Python process
110 sitkExceptionMacro(<< "Python Callable is not a callable Python object, "
111 << "or it has not been set.");
112 }
113 else
114 {
115 PyGILStateEnsure gil;
116
117 PyObject * result;
118
119 result = PyObject_CallObject(this->m_Object, (PyObject *)NULL);
120
121 if (result)
122 {
123 Py_DECREF(result);
124 }
125 else
126 {
127 // there was a Python error. Clear the error by printing to stdout
128 PyErr_Print();
129 // make sure the invoking Python code knows there was a problem
130 // by raising an exception
131 sitkExceptionMacro(<< "There was an error executing the "
132 << "Python Callable.");
133 }
134 }
135}
136
137
138} // namespace simple

Callers 8

MinimumMaximumFunction · 0.45
_r_imageFunction · 0.45
_rFunction · 0.45
DiscreteGaussianFunction · 0.45
test_procedure_resampleFunction · 0.45

Calls

no outgoing calls