tvtk module optional - sphere - GPU-based 3D discrete element method algorithm with optional fluid coupling
 (HTM) git clone git://src.adamsgaard.dk/sphere
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
 (DIR) commit 3b79a5ef5d587c082856f945e4aacb8247ae20b1
 (DIR) parent e37744f1b9fdd39f371ad2930b341ba01b37e894
 (HTM) Author: Anders Damsgaard <anders.damsgaard@geo.au.dk>
       Date:   Sun, 22 Jun 2014 10:40:08 +0200
       
       vtk module optional
       
       Diffstat:
         M python/sphere.py                    |      14 +++++++++++++-
       
       1 file changed, 13 insertions(+), 1 deletion(-)
       ---
 (DIR) diff --git a/python/sphere.py b/python/sphere.py
       t@@ -6,7 +6,13 @@ matplotlib.use('Agg')
        import matplotlib.pyplot as plt
        from matplotlib.font_manager import FontProperties
        import subprocess
       -import vtk
       +try:
       +    import vtk
       +except ImportError:
       +    print('Warning: Could not find "vtk" python module. VTK calls unavailable')
       +    py_vtk = False
       +else:
       +    py_vtk = True
        
        numpy.seterr(all='warn', over='raise')
        
       t@@ -1158,6 +1164,8 @@ class sim:
                :param verbose: Show diagnostic information (default = True)
                :type verbose: bool
                '''
       +        if py_vtk == False:
       +            raise Exception('Error: vtk module not found.')
        
                lastfile = status(self.sid)
                sb = sim(fluid = self.fluid)
       t@@ -1218,6 +1226,8 @@ class sim:
                :param verbose: Show diagnostic information (default = True)
                :type verbose: bool
                '''
       +        if py_vtk == False:
       +            raise Exception('Error: vtk module not found.')
        
                fh = None
                try :
       t@@ -1475,6 +1485,8 @@ class sim:
                :param verbose: Show diagnostic information (default = True)
                :type verbose: bool
                '''
       +        if py_vtk == False:
       +            raise Exception('Error: vtk module not found.')
        
                filename = folder + '/fluid-' + self.sid + '.vti' # image grid