Package PyFoam :: Package Paraview :: Module ServermanagerWrapper
[hide private]
[frames] | no frames]

Source Code for Module PyFoam.Paraview.ServermanagerWrapper

 1  #  ICE Revision: $Id: ServermanagerWrapper.py 9908 2009-01-19 19:42:27Z bgschaid $  
 2  """ Wrapper class for the paraview servermanager 
 3   
 4  Sets up the servermanager to be used with OpenFOAM-Data. Especially makes sure that 
 5  the plugins for the OpenFOAM-Data are loaded""" 
 6   
 7  from math import sqrt 
 8  from paraview import servermanager 
 9   
10  from os import environ,path,uname 
11   
12  from PyFoam.Error import error 
13   
14 -class ServermanagerWrapper(object):
15 """Wrapper class for the servermanager 16 17 Load the plugins and build a connection""" 18
19 - def __init__(self):
20 """Sets up the Servermanager in such a way that it is usable 21 with OpenFoAM-data.""" 22 23 self.con=servermanager.Connect() 24 25 dyExt="so" 26 if uname()[0]=="Darwin": 27 dyExt="dylib" 28 elif uname()[0]=="Linux": 29 try: 30 import ctypes 31 lib=ctypes.CDLL(path.join(environ["FOAM_LIBBIN"],"libPV3FoamReader.so"),mode=ctypes.RTLD_GLOBAL) 32 except ImportError: 33 error("The Workaround for Linux-Systems won'T work because there is no ctypes library") 34 35 plug1="libPV3FoamReader."+dyExt 36 plug2="libPV3FoamReader_SM."+dyExt 37 38 loaded=False 39 for p in environ["PV_PLUGIN_PATH"].split(":"): 40 if path.exists(path.join(p,plug1)): 41 servermanager.LoadPlugin(path.join(p,plug1)) 42 servermanager.LoadPlugin(path.join(p,plug2)) 43 loaded=True 44 break 45 46 if not loaded: 47 error("The plugin",plug1,"was not found in the PV_PLUGIN_PATH",environ["PV_PLUGIN_PATH"]) 48 if not "PV3FoamReader" in dir(servermanager.sources): 49 error("The plugin was not properly loaded. PV3FoamReader not found in the list of sources")
50
51 - def __getattr__(self,attr):
52 """Delegate Attributes to the servermanager-module""" 53 54 return getattr(servermanager,attr)
55
56 - def __setattr__(self,attr,val):
57 """Delegate Attributes to the servermanager-module""" 58 59 return setattr(servermanager,attr,val)
60
61 - def module(self):
62 """Return the actual module (for developing)""" 63 return servermanager
64