Package iceprod :: Package modules :: Module i3
[hide private]
[frames] | no frames]

Source Code for Module iceprod.modules.i3

 1   
 2  #!/bin/env python 
 3  # 
 4  """ 
 5   Interface for configuring and running python filtering scripts  
 6   
 7   copyright  (c) 2005 the icecube collaboration 
 8   
 9   @version: $Revision: $ 
10   @date: $Date: $ 
11   @author: Juan Carlos Diaz Velez <juancarlos@icecube.wisc.edu> 
12  """ 
13   
14  import os 
15  import re 
16  import sys 
17  import string 
18  import os.path 
19  import iceprod.modules 
20  from ipmodule import IPBaseClass 
21  from iceprod.core import odict,functions 
22  import logging 
23   
24 -class IceTray(IPBaseClass):
25 """ 26 This class provides an interface for preprocessing files in iceprod 27 """ 28
29 - def __init__(self):
30 IPBaseClass.__init__(self) 31 self.AddParameter('IPModuleURL','SVN URL of python script', '') 32 self.AddParameter('IPModuleRevision','SVN revision of python script',0) 33 self.AddParameter('IPModuleClass','class to load','') 34 self.AddParameter('IPModuleCache','should cache downloads',True) 35 self.logger = logging.getLogger('iceprod::IPIceTray') 36 37 self.child_parameters = odict.OrderedDict()
38
39 - def SetParameter(self, param, value):
40 """ 41 Overload SetParameter in order to allow for undefined parameters 42 """ 43 if param in ('IPModuleURL','IPModuleRevision','IPModuleClass'): 44 IPBaseClass.SetParameter(self,param,value) 45 else: 46 self.child_parameters[param] = value
47 48
49 - def Execute(self,stats):
50 if not IPBaseClass.Execute(self,stats): return 0 51 52 # set python path 53 sys.path.insert(0,os.getcwd()) 54 55 url = self.GetParameter('IPModuleURL') 56 classname = self.GetParameter('IPModuleClass') 57 cache_src = self.GetParameter('IPModuleCache') 58 filt = os.path.basename(url) 59 60 if functions.wget(url,cache=cache_src): 61 raise Exception, "Failed to retrieve i3filter from '%s'" % url 62 63 mod = iceprod.modules.get_plugin(classname)() 64 mod.SetParser(self.parser) 65 66 # Pass parameters to module 67 for name,value in self.child_parameters.items(): 68 mod.SetParameter(name,value) 69 70 return mod.Execute(stats)
71