Ejemplo n.º 1
0
    def add(cls, service: "CoreService") -> None:
        """
        Add a service to manager.

        :param service: service to add
        :return: nothing
        :raises ValueError: when service cannot be loaded
        """
        name = service.name
        logging.debug("loading service: class(%s) name(%s)", service.__name__, name)

        # avoid duplicate services
        if name in cls.services:
            raise ValueError("duplicate service being added: %s" % name)

        # validate dependent executables are present
        for executable in service.executables:
            which(executable, required=True)

        # validate service on load succeeds
        try:
            service.on_load()
        except Exception as e:
            logging.exception("error during service(%s) on load", service.name)
            raise ValueError(e)

        # make service available
        cls.services[name] = service
Ejemplo n.º 2
0
    def add(cls, service):
        """
        Add a service to manager.

        :param CoreService service: service to add
        :return: nothing
        """
        name = service.name
        logging.debug("loading service: class(%s) name(%s)", service.__name__,
                      name)

        # avoid duplicate services
        if name in cls.services:
            raise ValueError("duplicate service being added: %s" % name)

        # validate dependent executables are present
        for executable in service.executables:
            if not which(executable):
                logging.debug("service(%s) missing executable: %s",
                              service.name, executable)
                raise ValueError("service(%s) missing executable: %s" %
                                 (service.name, executable))

        # make service available
        cls.services[name] = service
Ejemplo n.º 3
0
    def add(cls, service):
        """
        Add a service to manager.

        :param CoreService service: service to add
        :return: nothing
        """
        name = service.name
        logger.info("loading service: class(%s) name(%s)", service.__name__, name)

        # avoid duplicate services
        if name in cls.services:
            raise ValueError("duplicate service being added: %s" % name)

        # validate dependent executables are present
        for executable in service.executables:
            if not which(executable):
                logger.warn("service(%s) missing executable: %s", service.name, executable)
                raise ValueError("service(%s) missing executable: %s" % (service.name, executable))

        # make service available
        cls.services[name] = service