mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 01:57:13 +02:00
Allow to call Downloader API in silent mode
This commit is contained in:
@ -74,13 +74,14 @@ class FileDownloader(object):
|
|||||||
return -1
|
return -1
|
||||||
return int(self._request.headers["content-length"])
|
return int(self._request.headers["content-length"])
|
||||||
|
|
||||||
def start(self, with_progress=True):
|
def start(self, with_progress=True, silent=False):
|
||||||
label = "Downloading"
|
label = "Downloading"
|
||||||
itercontent = self._request.iter_content(chunk_size=self.CHUNK_SIZE)
|
itercontent = self._request.iter_content(chunk_size=self.CHUNK_SIZE)
|
||||||
f = open(self._destination, "wb")
|
f = open(self._destination, "wb")
|
||||||
try:
|
try:
|
||||||
if not with_progress or self.get_size() == -1:
|
if not with_progress or self.get_size() == -1:
|
||||||
click.echo("%s..." % label)
|
if not silent:
|
||||||
|
click.echo("%s..." % label)
|
||||||
for chunk in itercontent:
|
for chunk in itercontent:
|
||||||
if chunk:
|
if chunk:
|
||||||
f.write(chunk)
|
f.write(chunk)
|
||||||
|
Reference in New Issue
Block a user