示例#1
0
def generate_vmimage_distro():
    yaml_path = [
        os.path.join(ROOT_PATH, 'selftests', 'pre_release', 'tests',
                     'vmimage.py.data', 'variants.yml')
    ]
    reference_dir_path = os.path.join(ROOT_PATH, 'docs', 'source', 'guides',
                                      'writer', 'libs', 'data', 'vmimage')
    reference_path = os.path.join(reference_dir_path, 'supported_images.csv')

    config = {'yaml_to_mux.files': yaml_path, 'yaml_to_mux.inject': []}
    varianter = Varianter()
    varianter.parse(config)

    try:
        os.makedirs(reference_dir_path)
    except FileExistsError:
        pass

    with open(reference_path, 'w', encoding='utf-8') as reference:
        reference.write("Provider, Version, Architecture\n")
        for v in varianter.itertests():
            vmimage_params = parameters.AvocadoParams(v['variant'], ['/run/*'])
            vmimage_name = vmimage_params.get('name')
            vmimage_version = vmimage_params.get('version')
            vmimage_arch = vmimage_params.get('arch', path='*/architectures/*')
            distro_arch_path = f'/run/distro/{vmimage_name}/{vmimage_arch}/*'
            vmimage_arch = vmimage_params.get('arch',
                                              path=distro_arch_path,
                                              default=vmimage_arch)
            reference.write(f"{str(vmimage_name)},{str(vmimage_version)},"
                            f"{str(vmimage_arch)}\n")
示例#2
0
 def variants(self):
     if self._variants is None:
         variants = Varianter()
         if not variants.is_parsed():
             try:
                 variants.parse(self.config)
             except (IOError, ValueError) as details:
                 raise OptionValidationError(f"Unable to parse variant: "
                                             f"{details}")
         self._variants = variants
     return self._variants
示例#3
0
    def _get_variants(resultsdir):
        results = []
        variants = Varianter.from_resultsdir(resultsdir)
        if variants is not None:
            for variant in variants:
                results.extend(variant.to_str(variants=2).splitlines())
        else:
            results.append('Not found\n')

        return results
示例#4
0
def generate_vmimage_distro():
    yaml_path = [
        os.path.join(
            ROOT_PATH,
            "selftests",
            "pre_release",
            "tests",
            "vmimage.py.data",
            "variants.yml",
        )
    ]
    reference_dir_path = os.path.join(ROOT_PATH, "docs", "source", "guides",
                                      "writer", "libs", "data", "vmimage")
    reference_path = os.path.join(reference_dir_path, "supported_images.csv")

    config = {"yaml_to_mux.files": yaml_path, "yaml_to_mux.inject": []}
    varianter = Varianter()
    varianter.parse(config)

    try:
        os.makedirs(reference_dir_path)
    except FileExistsError:
        pass

    with open(reference_path, "w", encoding="utf-8") as reference:
        reference.write("Provider, Version, Architecture\n")
        for v in varianter.itertests():
            vmimage_params = parameters.AvocadoParams(v["variant"], ["/run/*"])
            vmimage_name = vmimage_params.get("name")
            vmimage_version = vmimage_params.get("version")
            vmimage_arch = vmimage_params.get("arch", path="*/architectures/*")
            distro_arch_path = f"/run/distro/{vmimage_name}/{vmimage_arch}/*"
            vmimage_arch = vmimage_params.get("arch",
                                              path=distro_arch_path,
                                              default=vmimage_arch)
            reference.write(f"{str(vmimage_name)},{str(vmimage_version)},"
                            f"{str(vmimage_arch)}\n")
示例#5
0
    def run(self, config):
        tree = config.get('variants.tree')
        summary = config.get('variants.summary')
        variants = config.get('variants.variants')
        contents = config.get('variants.contents')
        inherit = config.get('variants.inherit')

        err = None
        if tree and config.get('variants.debug'):
            err = "Option --tree is incompatible with --debug."
        elif not tree and inherit:
            err = "Option --inherit can be only used with --tree"
        if err:
            LOG_UI.error(err)
            sys.exit(exit_codes.AVOCADO_FAIL)
        varianter = Varianter()
        try:
            varianter.parse(config)
        except (IOError, ValueError) as details:
            LOG_UI.error("Unable to parse varianter: %s", details)
            sys.exit(exit_codes.AVOCADO_FAIL)
        use_utf8 = config.get("runner.output.utf8")
        # Parse obsolete options (unsafe to combine them with new args)
        if tree:
            variants = 0
            summary += 1
            if contents:
                summary += 1
            if inherit:
                summary += 2
        else:
            if contents:
                variants += 2

        json_variants_dump = config.get('variants.json_variants_dump')
        # Export the serialized variants
        if json_variants_dump is not None:
            try:
                with open(json_variants_dump, 'w',
                          encoding='utf-8') as variants_file:
                    json.dump(varianter.dump(), variants_file)
            except IOError:
                LOG_UI.error("Cannot write %s", json_variants_dump)
                sys.exit(exit_codes.AVOCADO_FAIL)

        # Produce the output
        lines = varianter.to_str(summary=summary,
                                 variants=variants,
                                 use_utf8=use_utf8)
        for line in lines.splitlines():
            LOG_UI.debug(line)

        sys.exit(exit_codes.AVOCADO_ALL_OK)