예제 #1
0
    def prepare(self):
        modules = self.engine.config.get("modules")
        problems = []
        include_set = self._parse_module_filter(
            self.settings.get("include", []))
        exclude_set = self._parse_module_filter(
            self.settings.get("exclude", []))
        for mod_name in modules:
            if include_set and mod_name not in include_set:
                continue
            if exclude_set and mod_name in exclude_set:
                continue

            try:
                self._check_module(mod_name)
            except KeyboardInterrupt:
                raise  # let the engine handle it
            except BaseException as exc:
                self.log.error("Failed to instantiate module %s", mod_name)
                self.log.debug("%s", get_stacktrace(exc))
                problems.append(mod_name)

        if problems:
            raise ToolError(
                "There were errors while checking for installed tools for %s, see details above"
                % problems)

        raise NormalShutdown(
            "Done checking for tools installed, will exit now")
예제 #2
0
    def __dump_locations_if_needed(self):
        if self.settings.get("dump-locations", False):
            locations = {}
            for loc in self._workspaces.locations(include_private=True):
                locations[loc['id']] = loc

            data = [("ID", "Name")]
            for location_id in sorted(locations):
                location = locations[location_id]
                data.append((location_id, location['title']))
            table = SingleTable(data) if sys.stdout and sys.stdout.isatty() else AsciiTable(data)
            self.log.warning("Dumping available locations instead of running the test:\n%s", table.table)
            raise NormalShutdown("Done listing locations")
예제 #3
0
    def prepare(self):
        modules = self.engine.config.get("modules")
        failure = None
        for mod_name in modules.keys():
            try:
                self._check_module(mod_name)
            except BaseException as exc:
                self.log.error("Failed to instantiate module %s", mod_name)
                self.log.debug("%s", get_stacktrace(exc))
                failure = exc if not failure else failure

        if failure:
            raise ToolError("There were errors while checking for installed tools, see messages above")

        raise NormalShutdown("Done checking for tools installed, will exit now")
예제 #4
0
    def prepare(self):
        modules = self.engine.config.get("modules")
        problems = []
        for mod_name in modules.keys():
            try:
                self._check_module(mod_name)
            except KeyboardInterrupt:
                raise  # let the engine handle it
            except BaseException as exc:
                self.log.error("Failed to instantiate module %s", mod_name)
                self.log.debug("%s", get_stacktrace(exc))
                problems.append(mod_name)

        if problems:
            raise ToolError("There were errors while checking for installed tools for %s, see details above" % problems)

        raise NormalShutdown("Done checking for tools installed, will exit now")
예제 #5
0
    def __lint_config(self):
        settings = self.engine.config.get(CLI.CLI_SETTINGS).get("linter")
        self.log.debug("Linting config")
        self.warn_on_unfamiliar_fields = settings.get("warn-on-unfamiliar-fields", True)
        config_copy = copy.deepcopy(self.engine.config)
        ignored_warnings = settings.get("ignored-warnings", [])
        self.linter = ConfigurationLinter(config_copy, ignored_warnings, self.log)
        self.linter.register_checkers()
        self.linter.lint()
        warnings = self.linter.get_warnings()
        for warning in warnings:
            self.log.warning(str(warning))

        if settings.get("lint-and-exit", False):
            if warnings:
                raise TaurusConfigError("Errors were found in the configuration")
            else:
                raise NormalShutdown("Linting has finished, no errors were found")
예제 #6
0
    def prepare(self):
        if self.settings.get("disable", False):
            return
        self.log.info("Linting config")
        self.warn_on_unfamiliar_fields = self._get_conf_option("warn-on-unfamiliar-fields", True)
        config_copy = copy.deepcopy(self.engine.config)
        checkers_repo = self.settings.get("checkers")
        checkers_enabled = self.settings.get("checkers-enabled", [])
        ignored_warnings = self.settings.get("ignore-warnings", [])
        self.linter = ConfigurationLinter(config_copy, ignored_warnings, self.log)
        self.linter.register_checkers(checkers_repo, checkers_enabled)
        self.linter.lint()
        warnings = self.linter.get_warnings()
        for warning in warnings:
            self.log.warning(str(warning))

        if self._get_conf_option("lint-and-exit", False):
            if warnings:
                raise TaurusConfigError("There were a few errors found in the configuration.")
            else:
                raise NormalShutdown("Linting finished. No errors found.")
예제 #7
0
 def _extract(self, marker1):
     while self.loglines:
         line = self.loglines.pop(0)
         if "Shutting down..." in line:
             raise NormalShutdown()
         if marker1 in line:
             self.log.debug("Found: %s", line)
             while self.loglines:
                 line = self.loglines.pop(0)
                 if "Response [200]" in line:
                     self.log.debug("Found: %s", line)
                     buf = "{"
                     while self.loglines:
                         line = self.loglines.pop(0)
                         if len(line) < 5:
                             pass
                         if line.startswith("}"):
                             return json.loads(buf + "}")['result']
                         else:
                             buf += line
     # return []
     raise AssertionError("Failed to find: %s", marker1)