How to use the platformio.managers.platform.PlatformFactory.newPlatform function in platformio

To help you get started, we’ve selected a few platformio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github platformio / platformio-core / scripts / docspregen.py View on Github external
def is_compat_platform_and_framework(platform, framework):
    p = PlatformFactory.newPlatform(platform)
    return framework in (p.frameworks or {}).keys()
github platformio / platformio-core / platformio / managers / platform.py View on Github external
def update(  # pylint: disable=arguments-differ
        self, package, requirements=None, only_check=False, only_packages=False
    ):
        if isdir(package):
            pkg_dir = package
        else:
            name, requirements, url = self.parse_pkg_uri(package, requirements)
            pkg_dir = self.get_package_dir(name, requirements, url)

        if not pkg_dir:
            raise exception.UnknownPlatform(package)

        p = PlatformFactory.newPlatform(pkg_dir)
        pkgs_before = list(p.get_installed_packages())

        missed_pkgs = set()
        if not only_packages:
            BasePkgManager.update(self, pkg_dir, requirements, only_check)
            p = PlatformFactory.newPlatform(pkg_dir)
            missed_pkgs = set(pkgs_before) & set(p.packages)
            missed_pkgs -= set(p.get_installed_packages())

        p.update_packages(only_check)
        self.cleanup_packages(list(p.packages))

        if missed_pkgs:
            p.install_packages(
                with_packages=list(missed_pkgs), skip_default_package=True
            )
github platformio / platformio-core / platformio / managers / platform.py View on Github external
def cleanup_packages(self, names):
        self.cache_reset()
        deppkgs = {}
        for manifest in PlatformManager().get_installed():
            p = PlatformFactory.newPlatform(manifest["__pkg_dir"])
            for pkgname, pkgmanifest in p.get_installed_packages().items():
                if pkgname not in deppkgs:
                    deppkgs[pkgname] = set()
                deppkgs[pkgname].add(pkgmanifest["version"])

        pm = PackageManager(self.config.get_optional_dir("packages"))
        for manifest in pm.get_installed():
            if manifest["name"] not in names:
                continue
            if (
                manifest["name"] not in deppkgs
                or manifest["version"] not in deppkgs[manifest["name"]]
            ):
                try:
                    pm.uninstall(manifest["__pkg_dir"], after_update=True)
                except exception.UnknownPackage:
github platformio / platformio-core / platformio / managers / platform.py View on Github external
def cleanup_packages(self, names):
        self.cache_reset()
        deppkgs = {}
        for manifest in PlatformManager().get_installed():
            p = PlatformFactory.newPlatform(manifest['__pkg_dir'])
            for pkgname, pkgmanifest in p.get_installed_packages().items():
                if pkgname not in deppkgs:
                    deppkgs[pkgname] = set()
                deppkgs[pkgname].add(pkgmanifest['version'])

        pm = PackageManager(get_project_packages_dir())
        for manifest in pm.get_installed():
            if manifest['name'] not in names:
                continue
            if (manifest['name'] not in deppkgs
                    or manifest['version'] not in deppkgs[manifest['name']]):
                try:
                    pm.uninstall(manifest['__pkg_dir'], after_update=True)
                except exception.UnknownPackage:
                    pass
github platformio / platformio-core / scripts / docspregen.py View on Github external
def generate_platform(name, rst_dir):
    print("Processing platform: %s" % name)

    compatible_boards = [
        board for board in BOARDS if name == board['platform']
    ]

    lines = []

    lines.append(RST_COPYRIGHT)
    p = PlatformFactory.newPlatform(name)
    assert p.repository_url.endswith(".git")
    github_url = p.repository_url[:-4]

    lines.append(".. _platform_%s:" % p.name)
    lines.append("")

    lines.append(p.title)
    lines.append("=" * len(p.title))
    lines.append("")
    lines.append(":Configuration:")
    lines.append("  :ref:`projectconf_env_platform` = ``%s``" % p.name)
    lines.append("")
    lines.append(p.description)
    lines.append("""
For more detailed information please visit `vendor site <%s>`_.""" %
                 campaign_url(p.vendor_url))
github platformio / platformio-core / platformio / managers / platform.py View on Github external
def install(self,
                name,
                requirements=None,
                with_packages=None,
                without_packages=None,
                skip_default_package=False,
                after_update=False,
                silent=False,
                force=False,
                **_):  # pylint: disable=too-many-arguments, arguments-differ
        platform_dir = BasePkgManager.install(self,
                                              name,
                                              requirements,
                                              silent=silent,
                                              force=force)
        p = PlatformFactory.newPlatform(platform_dir)

        # don't cleanup packages or install them after update
        # we check packages for updates in def update()
        if after_update:
            return True

        p.install_packages(with_packages,
                           without_packages,
                           skip_default_package,
                           silent=silent,
                           force=force)
        return self.cleanup_packages(list(p.packages))
github platformio / platformio-core / platformio / managers / platform.py View on Github external
def get_installed_boards(self):
        boards = []
        for manifest in self.get_installed():
            p = PlatformFactory.newPlatform(manifest['__pkg_dir'])
            for config in p.get_boards().values():
                board = config.get_brief_data()
                if board not in boards:
                    boards.append(board)
        return boards
github platformio / platformio-core / platformio / managers / platform.py View on Github external
def get_installed_boards(self):
        boards = []
        for manifest in self.get_installed():
            p = PlatformFactory.newPlatform(manifest["__pkg_dir"])
            for config in p.get_boards().values():
                board = config.get_brief_data()
                if board not in boards:
                    boards.append(board)
        return boards