Exemple #1
0
def _get_installed_platform_data(platform,
                                 with_boards=True,
                                 expose_packages=True):
    p = PlatformFactory.newPlatform(platform)
    data = dict(
        name=p.name,
        title=p.title,
        description=p.description,
        version=p.version,
        homepage=p.homepage,
        repository=p.repository_url,
        url=p.vendor_url,
        docs=p.docs_url,
        license=p.license,
        forDesktop=not p.is_embedded(),
        frameworks=sorted(list(p.frameworks) if p.frameworks else []),
        packages=list(p.packages) if p.packages else [],
    )

    # if dump to API
    # del data['version']
    # return data

    # overwrite VCS version and add extra fields
    manifest = PlatformManager().load_manifest(dirname(p.manifest_path))
    assert manifest
    for key in manifest:
        if key == "version" or key.startswith("__"):
            data[key] = manifest[key]

    if with_boards:
        data["boards"] = [c.get_brief_data() for c in p.get_boards().values()]

    if not data["packages"] or not expose_packages:
        return data

    data["packages"] = []
    installed_pkgs = p.get_installed_packages()
    for name, opts in p.packages.items():
        item = dict(
            name=name,
            type=p.get_package_type(name),
            requirements=opts.get("version"),
            optional=opts.get("optional") is True,
        )
        if name in installed_pkgs:
            for key, value in installed_pkgs[name].items():
                if key not in ("url", "version", "description"):
                    continue
                item[key] = value
                if key == "version":
                    item["originalVersion"] = util.get_original_version(value)
        data["packages"].append(item)

    return data
 def _get_packages_data():
     data = []
     for item in platform.dump_used_packages():
         original_version = util.get_original_version(item["version"])
         info = "%s %s" % (item["name"], item["version"])
         extra = []
         if original_version:
             extra.append(original_version)
         if "src_url" in item and int(ARGUMENTS.get("PIOVERBOSE", 0)):
             extra.append(item["src_url"])
         if extra:
             info += " (%s)" % ", ".join(extra)
         data.append(info)
     if not data:
         return None
     return ["PACKAGES:"] + ["\n - %s" % d for d in sorted(data)]
Exemple #3
0
 def _get_packages_data():
     data = []
     for name, options in platform.packages.items():
         if options.get("optional"):
             continue
         pkg_dir = platform.get_package_dir(name)
         if not pkg_dir:
             continue
         manifest = platform.pm.load_manifest(pkg_dir)
         original_version = util.get_original_version(manifest['version'])
         info = "%s %s" % (manifest['name'], manifest['version'])
         extra = []
         if original_version:
             extra.append(original_version)
         if "__src_url" in manifest and int(ARGUMENTS.get("PIOVERBOSE", 0)):
             extra.append(manifest['__src_url'])
         if extra:
             info += " (%s)" % ", ".join(extra)
         data.append(info)
     return ["PACKAGES:", ", ".join(data)]