How to use the platformio.util 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 / platformio / telemetry.py View on Github external
def _send_data(self, data):
        if self._http_offline:
            return False
        try:
            r = self._http_session.post(
                "https://ssl.google-analytics.com/collect",
                data=data,
                headers=util.get_request_defheaders(),
                timeout=1,
            )
            r.raise_for_status()
            return True
        except requests.exceptions.HTTPError as e:
            # skip Bad Request
            if 400 >= e.response.status_code < 500:
                return True
        except:  # pylint: disable=W0702
            pass
        self._http_offline = True
        return False
github platformio / platformio-core / platformio / commands / check / command.py View on Github external
def print_processing_footer(result):
    is_failed = not result.get("succeeded")
    util.print_labeled_bar(
        "[%s] Took %.2f seconds"
        % (
            (
                click.style("FAILED", fg="red", bold=True)
                if is_failed
                else click.style("PASSED", fg="green", bold=True)
            ),
            result["duration"],
        ),
        is_error=is_failed,
    )
github bq / bitbloq-offline / app / res / web2board / darwin / Web2Board.app / Contents / Resources / platformio / libmanager.py View on Github external
def get_latest_versions(self):
        lib_ids = [str(item['id']) for item in self.get_installed().values()]
        if not lib_ids:
            return None
        return util.get_api_result("/lib/version/" + str(",".join(lib_ids)))
github platformio / platformio-core / platformio / builder / tools / piolib.py View on Github external
def is_platforms_compatible(self, platforms):
        items = self._manifest.get("platforms")
        if not items:
            return LibBuilderBase.is_platforms_compatible(self, platforms)
        return util.items_in_list(platforms, items)
github bq / bitbloq-offline / app / res / web2board / darwin / Web2Board.app / Contents / Resources / platformio / platforms / linux_arm.py View on Github external
def __init__(self):
        if "linux_arm" in util.get_systype():
            del self.PACKAGES['toolchain-gccarmlinuxgnueabi']
        BasePlatform.__init__(self)
github platformio / platformio-core / platformio / commands / check / command.py View on Github external
tabulate(
            tabular_data,
            headers=[
                click.style(s, bold=True)
                for s in ("Environment", "Tool", "Status", "Duration")
            ],
        ),
        err=failed_nums,
    )

    util.print_labeled_bar(
        "%s%d succeeded in %s"
        % (
            "%d failed, " % failed_nums if failed_nums else "",
            succeeded_nums,
            util.humanize_duration_time(duration),
        ),
        is_error=failed_nums,
        fg="red" if failed_nums else "green",
    )
github platformio / platformio-core / platformio / downloader.py View on Github external
def _preserve_filemtime(self, lmdate):
        timedata = parsedate_tz(lmdate)
        lmtime = mktime(timedata[:9])
        util.change_filemtime(self._destination, lmtime)
github platformio / platformio-core / platformio / managers / platform.py View on Github external
""".format(
            filename=filename,
            filename_styled=click.style(filename, fg="cyan"),
            link=click.style(
                "https://platformio.org/lib/search?query=header:%s"
                % quote(filename, safe=""),
                fg="blue",
            ),
            dots="*" * (56 + len(filename)),
        )
        click.echo(banner, err=True)


class PlatformBase(PlatformPackagesMixin, PlatformRunMixin):

    PIO_VERSION = semantic_version.Version(util.pepver_to_semver(__version__))
    _BOARDS_CACHE = {}

    def __init__(self, manifest_path):
        self.manifest_path = manifest_path
        self.silent = False
        self.verbose = False

        self._BOARDS_CACHE = {}
        self._manifest = fs.load_json(manifest_path)
        self._custom_packages = None

        self.config = ProjectConfig.get_instance()
        self.pm = PackageManager(
            self.config.get_optional_dir("packages"), self.package_repositories
        )
        # if self.engines and "platformio" in self.engines: