Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
26532ffa
Unverified
Commit
26532ffa
authored
May 06, 2020
by
peastman
Committed by
GitHub
May 06, 2020
Browse files
C++ exceptions get translated to Python OpenMMException class (#2672)
parent
fdfdb0f0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
3 deletions
+14
-3
wrappers/python/simtk/openmm/__init__.py
wrappers/python/simtk/openmm/__init__.py
+4
-0
wrappers/python/src/swig_doxygen/swigInputConfig.py
wrappers/python/src/swig_doxygen/swigInputConfig.py
+1
-0
wrappers/python/src/swig_doxygen/swig_lib/python/exceptions.i
...pers/python/src/swig_doxygen/swig_lib/python/exceptions.i
+9
-3
No files found.
wrappers/python/simtk/openmm/__init__.py
View file @
26532ffa
...
@@ -30,3 +30,7 @@ if sys.platform == 'win32':
...
@@ -30,3 +30,7 @@ if sys.platform == 'win32':
os
.
environ
[
'PATH'
]
=
_path
os
.
environ
[
'PATH'
]
=
_path
del
_path
del
_path
__version__
=
Platform
.
getOpenMMVersion
()
__version__
=
Platform
.
getOpenMMVersion
()
class
OpenMMException
(
Exception
):
"""This is the class used for all exceptions thrown by the C++ library."""
pass
wrappers/python/src/swig_doxygen/swigInputConfig.py
View file @
26532ffa
...
@@ -18,6 +18,7 @@ SKIP_METHODS = [('State', 'getPositions'),
...
@@ -18,6 +18,7 @@ SKIP_METHODS = [('State', 'getPositions'),
(
'State'
,
'getForces'
),
(
'State'
,
'getForces'
),
(
'StateBuilder'
,),
(
'StateBuilder'
,),
(
'Vec3'
,),
(
'Vec3'
,),
(
'OpenMMException'
,),
(
'AngleInfo'
,),
(
'AngleInfo'
,),
(
'ApplyAndersenThermostatKernel'
,),
(
'ApplyAndersenThermostatKernel'
,),
(
'ApplyConstraintsKernel'
,),
(
'ApplyConstraintsKernel'
,),
...
...
wrappers/python/src/swig_doxygen/swig_lib/python/exceptions.i
View file @
26532ffa
...
@@ -3,7 +3,9 @@
...
@@ -3,7 +3,9 @@
try
{
try
{
$
action
$
action
}
catch
(
std
::
exception
&
e)
{
}
catch
(
std
::
exception
&
e)
{
PyErr_SetString
(
PyExc_Exception
,
const_cast
<
char
*>
(
e
.
what
()))
;
PyObject
*
mm
=
PyImport_AddModule
(
"simtk.openmm"
)
;
PyObject
*
openmm_exception
=
PyObject_GetAttrString
(
mm
,
"OpenMMException"
)
;
PyErr_SetString
(
openmm_exception
,
const_cast
<
char
*>
(
e
.
what
()))
;
return
NULL
;
return
NULL
;
}
}
}
}
...
@@ -14,7 +16,9 @@
...
@@ -14,7 +16,9 @@
$
action
$
action
}
catch
(
std
::
exception
&
e)
{
}
catch
(
std
::
exception
&
e)
{
PyEval_RestoreThread
(
_savePythonThreadState
)
;
PyEval_RestoreThread
(
_savePythonThreadState
)
;
PyErr_SetString
(
PyExc_Exception
,
const_cast
<
char
*>
(
e
.
what
()))
;
PyObject
*
mm
=
PyImport_AddModule
(
"simtk.openmm"
)
;
PyObject
*
openmm_exception
=
PyObject_GetAttrString
(
mm
,
"OpenMMException"
)
;
PyErr_SetString
(
openmm_exception
,
const_cast
<
char
*>
(
e
.
what
()))
;
return
NULL
;
return
NULL
;
}
}
PyEval_RestoreThread
(
_savePythonThreadState
)
;
PyEval_RestoreThread
(
_savePythonThreadState
)
;
...
@@ -26,7 +30,9 @@
...
@@ -26,7 +30,9 @@
$
action
$
action
}
catch
(
std
::
exception
&
e)
{
}
catch
(
std
::
exception
&
e)
{
PyEval_RestoreThread
(
_savePythonThreadState
)
;
PyEval_RestoreThread
(
_savePythonThreadState
)
;
PyErr_SetString
(
PyExc_Exception
,
const_cast
<
char
*>
(
e
.
what
()))
;
PyObject
*
mm
=
PyImport_AddModule
(
"simtk.openmm"
)
;
PyObject
*
openmm_exception
=
PyObject_GetAttrString
(
mm
,
"OpenMMException"
)
;
PyErr_SetString
(
openmm_exception
,
const_cast
<
char
*>
(
e
.
what
()))
;
return
NULL
;
return
NULL
;
}
}
PyEval_RestoreThread
(
_savePythonThreadState
)
;
PyEval_RestoreThread
(
_savePythonThreadState
)
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment