Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-10 08:38:58

0001 from pandajedi.jediconfig import jedi_config
0002 from pandajedi.jedicore import Interaction
0003 
0004 
0005 # interface to DDM
0006 class DDMInterface:
0007     # constructor
0008     def __init__(self):
0009         self.interfaceMap = {}
0010 
0011     # setup interface
0012     def setupInterface(self):
0013         # parse config
0014         for configStr in jedi_config.ddm.modConfig.split(","):
0015             configStr = configStr.strip()
0016             items = configStr.split(":")
0017             # check format
0018             active = True
0019             try:
0020                 vo = items[0]
0021                 maxSize = int(items[1])
0022                 moduleName = items[2]
0023                 className = items[3]
0024                 if len(items) >= 5:
0025                     group = items[4]
0026                     if not group:
0027                         group = None
0028                 else:
0029                     group = None
0030                 if len(items) >= 6 and items[5] == "off":
0031                     active = False
0032             except Exception:
0033                 # TODO add config error message
0034                 continue
0035             # add VO interface
0036             if active:
0037                 voIF = Interaction.CommandSendInterface(vo, maxSize, moduleName, className)
0038                 voIF.initialize()
0039             else:
0040                 voIF = None
0041             key = self.get_dict_key(vo, group)
0042             self.interfaceMap[key] = voIF
0043 
0044     # get interface with VO
0045     def getInterface(self, vo, group=None):
0046         # vo + group
0047         key = self.get_dict_key(vo, group)
0048         if key in self.interfaceMap:
0049             return self.interfaceMap[key]
0050         # only vo
0051         key = self.get_dict_key(vo, None)
0052         if key in self.interfaceMap:
0053             return self.interfaceMap[key]
0054         # catchall
0055         cacheAll = self.get_dict_key("any", None)
0056         if cacheAll in self.interfaceMap:
0057             return self.interfaceMap[cacheAll]
0058         # not found
0059         return None
0060 
0061     # get dict key
0062     def get_dict_key(self, vo, group):
0063         return vo, group
0064 
0065 
0066 if __name__ == "__main__":
0067 
0068     def dummyClient(dif):
0069         print("client test")
0070         dif.getInterface("atlas").test()
0071         print("client done")
0072 
0073     dif = DDMInterface()
0074     dif.setupInterface()
0075     print("master test")
0076     atlasIF = dif.getInterface("atlas")
0077     atlasIF.test()
0078     print("master done")
0079     import multiprocessing
0080 
0081     p = multiprocessing.Process(target=dummyClient, args=(dif,))
0082     p.start()
0083     p.join()