diff --git a/HISTORY.rst b/HISTORY.rst index 2f435338..82981189 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -18,8 +18,8 @@ PlatformIO 2.0 and allowed to `change default upload reset method `_ for Espressif development platform (`issue #444 `_) -* Allowed to force output of color ANSI-codes even if the output is a ``pipe`` - (not a ``tty``) +* Allowed to force output of color ANSI-codes or to disable progress bar even + if the output is a ``pipe`` (not a ``tty``) using `Environment variables `__ (`issue #465 `_) * Set 1Mb SPIFFS for Espressif boards by default (`issue #458 `_) diff --git a/docs/envvars.rst b/docs/envvars.rst index f9f037da..f46784bd 100644 --- a/docs/envvars.rst +++ b/docs/envvars.rst @@ -34,16 +34,21 @@ operations/commands. PlatformIO handles ``CI`` variable which is setup by `Continuous Integration `_ (Travis, Circle and etc.) systems. -Currently, PlatformIO uses it to disable prompts. - -In other words, ``CI=true`` automatically setup -:envvar:`PLATFORMIO_SETTING_ENABLE_PROMPTS=false `. +PlatformIO uses it to disable prompts and progress bars. In other words, +``CI=true`` automatically setup :envvar:`PLATFORMIO_SETTING_ENABLE_PROMPTS` to +``false`` and :envvar:`PLATFORMIO_DISABLE_PROGRESSBAR` to ``true``. .. envvar:: PLATFORMIO_FORCE_COLOR Force to output color ANSI-codes even if the output is a ``pipe`` (not a ``tty``). The possible values are ``true`` and ``false``. Default is ``PLATFORMIO_FORCE_COLOR=false``. +.. envvar:: PLATFORMIO_DISABLE_PROGRESSBAR + +Disable progress bar for package/library downloader and uploader. This is +useful when calling PlatformIO from subprocess and output is a ``pipe`` (not a ``tty``). +The possible values are ``true`` and ``false``. Default is ``PLATFORMIO_DISABLE_PROGRESSBAR=false``. + .. envvar:: PLATFORMIO_HOME_DIR Allows to override :ref:`projectconf` option :ref:`projectconf_pio_home_dir`. diff --git a/platformio/__init__.py b/platformio/__init__.py index 7197b8c1..6099e910 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (2, 8, "0.dev0") +VERSION = (2, 8, "0.dev1") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/app.py b/platformio/app.py index 8707f6cd..b7486f68 100644 --- a/platformio/app.py +++ b/platformio/app.py @@ -183,3 +183,10 @@ def get_session_var(name, default=None): def set_session_var(name, value): assert name in SESSION_VARS SESSION_VARS[name] = value + + +def is_disabled_progressbar(): + # tmp hook + if get_session_var("caller_id") == "atom": + return True + return is_ci() or getenv("PLATFORMIO_DISABLE_PROGRESSBAR") == "true" diff --git a/platformio/builder/tools/piomisc.py b/platformio/builder/tools/piomisc.py index 01f70265..2c141211 100644 --- a/platformio/builder/tools/piomisc.py +++ b/platformio/builder/tools/piomisc.py @@ -114,7 +114,10 @@ class InoToCPPConverter(object): def ConvertInoToCpp(env): def delete_tmpcpp_file(file_): - remove(file_) + try: + remove(file_) + except WindowsError: + pass ino_nodes = (env.Glob(join("$PROJECTSRC_DIR", "*.ino")) + env.Glob(join("$PROJECTSRC_DIR", "*.pde"))) diff --git a/platformio/downloader.py b/platformio/downloader.py index a64c1a5f..25e409ae 100644 --- a/platformio/downloader.py +++ b/platformio/downloader.py @@ -20,7 +20,7 @@ from time import mktime import click import requests -from platformio import util +from platformio import app, util from platformio.exception import (FDSHASumMismatch, FDSizeMismatch, FDUnrecognizedStatusCode) @@ -63,7 +63,7 @@ class FileDownloader(object): f = open(self._destination, "wb") chunks = int(ceil(self.get_size() / float(self.CHUNK_SIZE))) - if util.is_ci(): + if app.is_disabled_progressbar(): click.echo("Downloading...") for _ in range(0, chunks): f.write(next(itercontent)) diff --git a/platformio/unpacker.py b/platformio/unpacker.py index f4ef32db..ab8955cd 100644 --- a/platformio/unpacker.py +++ b/platformio/unpacker.py @@ -20,7 +20,7 @@ from zipfile import ZipFile import click -from platformio import util +from platformio import app, util from platformio.exception import UnsupportedArchiveType @@ -92,7 +92,7 @@ class FileUnpacker(object): raise UnsupportedArchiveType(archpath) def start(self): - if util.is_ci(): + if app.is_disabled_progressbar(): click.echo("Unpacking...") for item in self._unpacker.get_items(): self._unpacker.extract_item(item, self._dest_dir)