示例#1
0
def _remove_deploy_tmpdir(args, proc, success=True):
    """Remove temporary files."""

    ctmpdir = getattr(args, "ctmpdir", None)
    stmpdir = getattr(args, "stmpdir", None)

    if args.debug and not success:
        _LOG.debug("preserved the following temporary directories for debugging purposes:")
        if ctmpdir:
            _LOG.debug(" * On the local host: %s", ctmpdir)
        if stmpdir and stmpdir != ctmpdir:
            _LOG.debug(" * On the SUT: %s", stmpdir)
    else:
        if ctmpdir:
            FSHelpers.rm_minus_rf(args.ctmpdir, proc=proc)
        if stmpdir:
            FSHelpers.rm_minus_rf(args.stmpdir, proc=proc)
示例#2
0
    def close(self):
        """Close the statistics collector."""

        acquired = self._close_lock.acquire(timeout=1)  # pylint: disable=consider-using-with
        if not acquired:
            return

        try:
            if getattr(self, "_sock", None):
                if self._start_time:
                    with contextlib.suppress(Exception):
                        self._send_command("stop")
                with contextlib.suppress(Exception):
                    self._send_command("exit")
                with contextlib.suppress(Exception):
                    self._disconnect()
                self._sock = None

            if getattr(self, "_proc", None):
                if self._ssht:
                    with contextlib.suppress(Exception):
                        ProcHelpers.kill_processes(self._ssht_search,
                                                   proc=self._proc)
                    self._ssht = None

                if self._sc:
                    with contextlib.suppress(Exception):
                        ProcHelpers.kill_processes(self._sc_search,
                                                   proc=self._proc)
                    self._sc = None

                # Remove the output directory if we created it.
                if getattr(self, "_outdir_created", None):
                    with contextlib.suppress(Exception):
                        FSHelpers.rm_minus_rf(self.outdir, proc=self._proc)
                    self._outdir_created = None

                self._proc = None
        finally:
            self._close_lock.release()