Allow to disable progress bar for package/library downloader and uploader

This commit is contained in:
Ivan Kravets
2016-01-24 16:45:04 +02:00
parent a0d3a180e4
commit 0cecd955c5
7 changed files with 27 additions and 12 deletions

View File

@ -18,8 +18,8 @@ PlatformIO 2.0
and allowed to `change default upload reset method <http://docs.platformio.org/en/latest/platforms/espressif.html#custom-reset-method>`_ and allowed to `change default upload reset method <http://docs.platformio.org/en/latest/platforms/espressif.html#custom-reset-method>`_
for Espressif development platform for Espressif development platform
(`issue #444 <https://github.com/platformio/platformio/issues/444>`_) (`issue #444 <https://github.com/platformio/platformio/issues/444>`_)
* Allowed to force output of color ANSI-codes even if the output is a ``pipe`` * Allowed to force output of color ANSI-codes or to disable progress bar even
(not a ``tty``) if the output is a ``pipe`` (not a ``tty``) using `Environment variables <http://docs.platformio.org/en/latest/envvars.html>`__
(`issue #465 <https://github.com/platformio/platformio/issues/465>`_) (`issue #465 <https://github.com/platformio/platformio/issues/465>`_)
* Set 1Mb SPIFFS for Espressif boards by default * Set 1Mb SPIFFS for Espressif boards by default
(`issue #458 <https://github.com/platformio/platformio/issues/458>`_) (`issue #458 <https://github.com/platformio/platformio/issues/458>`_)

View File

@ -34,16 +34,21 @@ operations/commands.
PlatformIO handles ``CI`` variable which is setup by PlatformIO handles ``CI`` variable which is setup by
`Continuous Integration <http://en.wikipedia.org/wiki/Continuous_integration>`_ `Continuous Integration <http://en.wikipedia.org/wiki/Continuous_integration>`_
(Travis, Circle and etc.) systems. (Travis, Circle and etc.) systems.
Currently, PlatformIO uses it to disable prompts. PlatformIO uses it to disable prompts and progress bars. In other words,
``CI=true`` automatically setup :envvar:`PLATFORMIO_SETTING_ENABLE_PROMPTS` to
In other words, ``CI=true`` automatically setup ``false`` and :envvar:`PLATFORMIO_DISABLE_PROGRESSBAR` to ``true``.
:envvar:`PLATFORMIO_SETTING_ENABLE_PROMPTS=false <PLATFORMIO_SETTING_ENABLE_PROMPTS>`.
.. envvar:: PLATFORMIO_FORCE_COLOR .. envvar:: PLATFORMIO_FORCE_COLOR
Force to output color ANSI-codes even if the output is a ``pipe`` (not a ``tty``). 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``. 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 .. envvar:: PLATFORMIO_HOME_DIR
Allows to override :ref:`projectconf` option :ref:`projectconf_pio_home_dir`. Allows to override :ref:`projectconf` option :ref:`projectconf_pio_home_dir`.

View File

@ -14,7 +14,7 @@
import sys import sys
VERSION = (2, 8, "0.dev0") VERSION = (2, 8, "0.dev1")
__version__ = ".".join([str(s) for s in VERSION]) __version__ = ".".join([str(s) for s in VERSION])
__title__ = "platformio" __title__ = "platformio"

View File

@ -183,3 +183,10 @@ def get_session_var(name, default=None):
def set_session_var(name, value): def set_session_var(name, value):
assert name in SESSION_VARS assert name in SESSION_VARS
SESSION_VARS[name] = value 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"

View File

@ -114,7 +114,10 @@ class InoToCPPConverter(object):
def ConvertInoToCpp(env): def ConvertInoToCpp(env):
def delete_tmpcpp_file(file_): def delete_tmpcpp_file(file_):
remove(file_) try:
remove(file_)
except WindowsError:
pass
ino_nodes = (env.Glob(join("$PROJECTSRC_DIR", "*.ino")) + ino_nodes = (env.Glob(join("$PROJECTSRC_DIR", "*.ino")) +
env.Glob(join("$PROJECTSRC_DIR", "*.pde"))) env.Glob(join("$PROJECTSRC_DIR", "*.pde")))

View File

@ -20,7 +20,7 @@ from time import mktime
import click import click
import requests import requests
from platformio import util from platformio import app, util
from platformio.exception import (FDSHASumMismatch, FDSizeMismatch, from platformio.exception import (FDSHASumMismatch, FDSizeMismatch,
FDUnrecognizedStatusCode) FDUnrecognizedStatusCode)
@ -63,7 +63,7 @@ class FileDownloader(object):
f = open(self._destination, "wb") f = open(self._destination, "wb")
chunks = int(ceil(self.get_size() / float(self.CHUNK_SIZE))) chunks = int(ceil(self.get_size() / float(self.CHUNK_SIZE)))
if util.is_ci(): if app.is_disabled_progressbar():
click.echo("Downloading...") click.echo("Downloading...")
for _ in range(0, chunks): for _ in range(0, chunks):
f.write(next(itercontent)) f.write(next(itercontent))

View File

@ -20,7 +20,7 @@ from zipfile import ZipFile
import click import click
from platformio import util from platformio import app, util
from platformio.exception import UnsupportedArchiveType from platformio.exception import UnsupportedArchiveType
@ -92,7 +92,7 @@ class FileUnpacker(object):
raise UnsupportedArchiveType(archpath) raise UnsupportedArchiveType(archpath)
def start(self): def start(self):
if util.is_ci(): if app.is_disabled_progressbar():
click.echo("Unpacking...") click.echo("Unpacking...")
for item in self._unpacker.get_items(): for item in self._unpacker.get_items():
self._unpacker.extract_item(item, self._dest_dir) self._unpacker.extract_item(item, self._dest_dir)