Allow to force to output color ANSI-codes even if the output is a `pipe (not a tty`)

This commit is contained in:
Ivan Kravets
2016-01-19 21:03:49 +02:00
parent 3035d4eeec
commit cc1dec39cf
4 changed files with 18 additions and 2 deletions

View File

@ -15,6 +15,9 @@ 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 to output color ANSI-codes even if the output is a ``pipe``
(not a ``tty``)
(`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>`_)
* Fixed builder for mbed framework and ST STM32 platform * Fixed builder for mbed framework and ST STM32 platform

View File

@ -39,6 +39,11 @@ Currently, PlatformIO uses it to disable prompts.
In other words, ``CI=true`` automatically setup In other words, ``CI=true`` automatically setup
:envvar:`PLATFORMIO_SETTING_ENABLE_PROMPTS=false <PLATFORMIO_SETTING_ENABLE_PROMPTS>`. :envvar:`PLATFORMIO_SETTING_ENABLE_PROMPTS=false <PLATFORMIO_SETTING_ENABLE_PROMPTS>`.
.. 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_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, 7, "2.dev4") VERSION = (2, 7, "2.dev5")
__version__ = ".".join([str(s) for s in VERSION]) __version__ = ".".join([str(s) for s in VERSION])
__title__ = "platformio" __title__ = "platformio"

View File

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from os import listdir from os import getenv, listdir
from os.path import join from os.path import join
from platform import system from platform import system
from sys import exit as sys_exit from sys import exit as sys_exit
@ -94,6 +94,14 @@ def main():
"Invalid installation of Python `requests` package`. See " "Invalid installation of Python `requests` package`. See "
"< https://github.com/platformio/platformio/issues/252 >") "< https://github.com/platformio/platformio/issues/252 >")
# handle PLATFORMIO_FORCE_COLOR
if str(getenv("PLATFORMIO_FORCE_COLOR", "")).lower() == "true":
try:
# pylint: disable=protected-access
click._compat.isatty = lambda stream: True
except: # pylint: disable=bare-except
pass
cli(None, None, None) cli(None, None, None)
except Exception as e: # pylint: disable=W0703 except Exception as e: # pylint: disable=W0703
if not isinstance(e, exception.ReturnErrorCode): if not isinstance(e, exception.ReturnErrorCode):