Example #1
0
 def __init__( self, services ):
   if type( services ) in ( types.StringType, types.UnicodeType ):
     services = [ services ]
   self.__services = {}
   self.__alive = True
   self.__listeningConnections = {}
   self.__stats = ReactorStats()
   for serviceName in services:
     while serviceName[0] == "/":
       serviceName = serviceName[1:]
     if serviceName == GatewayService.GATEWAY_NAME:
       self.__services[ serviceName ] = GatewayService()
     else:
       self.__services[ serviceName ] = Service( serviceName )
Example #2
0
  def initialize(self, servicesList):
    try:
      servicesList.remove(GatewayService.GATEWAY_NAME)
      self.__services[GatewayService.GATEWAY_NAME] = GatewayService()
    except ValueError:
      # No GW in the service list
      pass

    result = self.__loader.loadModules(servicesList)
    if not result['OK']:
      return result
    self.__serviceModules = self.__loader.getModules()

    for serviceName in self.__serviceModules:
      self.__services[serviceName] = Service(self.__serviceModules[serviceName])

    # Loop again to include the GW in case there is one (included in the __init__)
    for serviceName in self.__services:
      gLogger.info("Initializing %s" % serviceName)
      result = self.__services[serviceName].initialize()
      if not result['OK']:
        return result
    return S_OK()