Ejemplo n.º 1
0
    def start(self):
        """
        Start process.

        .. note::

            Process will be considered started, when defined banner will appear
            in process output.
        """
        Executor.start(self)

        # get a polling object
        self.poll_obj = select.poll()

        # register a file descriptor
        # POLLIN because we will wait for data to read
        self.poll_obj.register(self.output(), select.POLLIN)

        try:
            self.wait_for(self._wait_for_output)

            # unregister the file descriptor and delete the polling object
            self.poll_obj.unregister(self.output())
        finally:
            del self.poll_obj
Ejemplo n.º 2
0
    def __init__(self, command, banner, shell=False, timeout=None, sleep=0.1):
        """
        Initialize OutputExecutor executor.

        :param str command: command to run to start service
        :param str banner: string that has to appear in process output -
            should compile to regular expression.
        :param bool shell: see `subprocess.Popen`
        :param int timeout: time to wait for process to start or stop.
            if None, wait indefinitely.
        :param float sleep: how often to check for start/stop condition
        """
        Executor.__init__(self, command, shell, timeout, sleep)
        self._banner = re.compile(banner)