Skip to content

Commit

Permalink
Merge pull request dipy#1243 from ghoshbishakh/betterErrors
Browse files Browse the repository at this point in the history
Better fvtk.viz error when no VTK installed
  • Loading branch information
arokem committed Jun 20, 2017
2 parents aae726c + f150870 commit 7ab4142
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions dipy/utils/tests/test_tripwire.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def test_tripwire():
getattr,
silly_module_name,
'do_silly_thing')
assert_raises(TripWireError,
silly_module_name)
# Check AttributeError can be checked too
try:
silly_module_name.__wrapped__
Expand Down
5 changes: 5 additions & 0 deletions dipy/utils/tripwire.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,14 @@ class TripWire(object):
...
TripWireError: We do not have silly_module_name
"""

def __init__(self, msg):
self._msg = msg

def __getattr__(self, attr_name):
''' Raise informative error accessing attributes '''
raise TripWireError(self._msg)

def __call__(self, *args, **kwargs):
''' Raise informative error while calling '''
raise TripWireError(self._msg)
3 changes: 3 additions & 0 deletions dipy/viz/fvtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@
msg = "Python VTK is not installed"
warn(msg)

ren, have_ren, _ = optional_package('dipy.viz.window.ren',
'Python VTK is not installed')


def dots(points, color=(1, 0, 0), opacity=1, dot_size=5):
""" Create one or more 3d points
Expand Down

0 comments on commit 7ab4142

Please sign in to comment.