mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 18:17:13 +02:00
Disable progress bar for Continuous Integration Systems
This commit is contained in:
@ -3,11 +3,11 @@
|
||||
|
||||
from email.utils import parsedate_tz
|
||||
from math import ceil
|
||||
from os.path import getsize, join
|
||||
from os.path import environ, getsize, join
|
||||
from time import mktime
|
||||
|
||||
from click import progressbar
|
||||
from requests import get
|
||||
import click
|
||||
import requests
|
||||
|
||||
from platformio import util
|
||||
from platformio.exception import (FDSHASumMismatch, FDSizeMismatch,
|
||||
@ -27,8 +27,8 @@ class FileDownloader(object):
|
||||
self.set_destination(join(dest_dir, self._fname))
|
||||
self._progressbar = None
|
||||
|
||||
self._request = get(url, stream=True,
|
||||
headers=util.get_request_defheaders())
|
||||
self._request = requests.get(url, stream=True,
|
||||
headers=util.get_request_defheaders())
|
||||
if self._request.status_code != 200:
|
||||
raise FDUnrecognizedStatusCode(self._request.status_code, url)
|
||||
|
||||
@ -49,9 +49,14 @@ class FileDownloader(object):
|
||||
f = open(self._destination, "wb")
|
||||
chunks = int(ceil(self.get_size() / float(self.CHUNK_SIZE)))
|
||||
|
||||
with progressbar(length=chunks, label="Downloading") as pb:
|
||||
for _ in pb:
|
||||
if environ.get("CI") == "true":
|
||||
click.echo("Downloading...")
|
||||
for _ in range(0, chunks):
|
||||
f.write(next(itercontent))
|
||||
else:
|
||||
with click.progressbar(length=chunks, label="Downloading") as pb:
|
||||
for _ in pb:
|
||||
f.write(next(itercontent))
|
||||
f.close()
|
||||
self._request.close()
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
# Copyright (C) Ivan Kravets <me@ikravets.com>
|
||||
# See LICENSE for details.
|
||||
|
||||
from os import chmod
|
||||
from os import chmod, environ
|
||||
from os.path import join, splitext
|
||||
from tarfile import open as tarfile_open
|
||||
from time import mktime
|
||||
from zipfile import ZipFile
|
||||
|
||||
from click import progressbar
|
||||
import click
|
||||
|
||||
from platformio.exception import UnsupportedArchiveType
|
||||
from platformio.util import change_filemtime
|
||||
@ -81,7 +81,13 @@ class FileUnpacker(object):
|
||||
raise UnsupportedArchiveType(archpath)
|
||||
|
||||
def start(self):
|
||||
with progressbar(self._unpacker.get_items(), label="Unpacking") as pb:
|
||||
for item in pb:
|
||||
if environ.get("CI") == "true":
|
||||
click.echo("Unpacking...")
|
||||
for item in self._unpacker.get_items():
|
||||
self._unpacker.extract_item(item, self._dest_dir)
|
||||
else:
|
||||
with click.progressbar(self._unpacker.get_items(),
|
||||
label="Unpacking") as pb:
|
||||
for item in pb:
|
||||
self._unpacker.extract_item(item, self._dest_dir)
|
||||
return True
|
||||
|
Reference in New Issue
Block a user