diff options
author | Santhosh Thottingal <santhosh.thottingal@gmail.com> | 2009-04-16 20:48:51 +0530 |
---|---|---|
committer | Santhosh Thottingal <santhosh.thottingal@gmail.com> | 2009-04-16 20:48:51 +0530 |
commit | 35efb56d790b122c6d0f7f588641fc2f15f5122b (patch) | |
tree | 602c8f95706ccde7346ff377ae8f115715a8ff5e /silpa/common | |
parent | 44ccbb9d522f07c9ea31761c5cf050391954b130 (diff) | |
download | AnjaliOldLipi.git-35efb56d790b122c6d0f7f588641fc2f15f5122b.tar.gz AnjaliOldLipi.git-35efb56d790b122c6d0f7f588641fc2f15f5122b.tar.xz AnjaliOldLipi.git-35efb56d790b122c6d0f7f588641fc2f15f5122b.zip |
Module info introspection
Diffstat (limited to 'silpa/common')
-rw-r--r-- | silpa/common/modulemanager.py | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/silpa/common/modulemanager.py b/silpa/common/modulemanager.py index 028c4ae..8f9c79d 100644 --- a/silpa/common/modulemanager.py +++ b/silpa/common/modulemanager.py @@ -9,16 +9,21 @@ class ModuleManager: obj= sys.modules[name] except KeyError: obj = __import__(".".join(parts[:-1])) - print "Loading " , obj if(len(parts)>1): for part in parts[1:]: - obj = getattr(obj,part) + try: + obj = getattr(obj,part) + except: + obj = None return obj def getModuleInstance(self,action): module_name = self.find_module(action) if(module_name): - return self.import_module(module_name).getInstance() + try: + return self.import_module(module_name).getInstance() + except: + print dir(self.import_module(module_name)) else: return None def find_module(self,action): @@ -26,6 +31,15 @@ class ModuleManager: return getModulesList()[action] except: return None + def getModulesInfoAsHTML(self): + module_dict=getModulesList () + response = "<h2>Available Modules</h2></hr>" + response = response+"<table class=\"table1\"><tr><th>Module</th><th>Description</th><th>Status</th></tr>" + for action in module_dict: + module_instance=self.getModuleInstance(action) + response = response+"<tr><td><a href='?action="+ action +"'>"+module_instance.get_module_name()+"</a></td>" + response = response+"<td>"+module_instance.get_info()+"</td><td>OK</td></tr>" + return response+"</table>" if __name__ == '__main__': mm=ModuleManager() print mm.getModuleInstance("lemmatize") |