示例#1
0
文件: handler.py 项目: hdeweirdt/imp
 def __init__(self, agent, io = None):
     self._agent = agent
     
     if io is None:
         self._io = get_io(self._agent.remote)
     else:
         self._io = io
示例#2
0
文件: handler.py 项目: hdeweirdt/imp
 def get_provider(cls, agent, resource_id):
     """
         Return a provider to handle the given resource
     """
     resource_type = resource_id.entity_type
     io = get_io(agent.remote)
     
     if resource_type in cls.__command_functions:
         for hndlr in cls.__command_functions[resource_type].values():
             if hndlr.is_available(io):
                 h = hndlr(agent, io)
                 cls.__handlers.append(h)
                 return h
     
     raise Exception("No resource handler registered for resource of type %s" % resource_type)