mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 18:17:13 +02:00
Temporary workaround for VSCode's "IOError: PackageManager" issue
This commit is contained in:
@ -21,7 +21,7 @@ from time import mktime
|
|||||||
import click
|
import click
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from platformio import app, util
|
from platformio import util
|
||||||
from platformio.exception import (FDSHASumMismatch, FDSizeMismatch,
|
from platformio.exception import (FDSHASumMismatch, FDSizeMismatch,
|
||||||
FDUnrecognizedStatusCode)
|
FDUnrecognizedStatusCode)
|
||||||
|
|
||||||
@ -70,12 +70,12 @@ class FileDownloader(object):
|
|||||||
return -1
|
return -1
|
||||||
return int(self._request.headers['content-length'])
|
return int(self._request.headers['content-length'])
|
||||||
|
|
||||||
def start(self):
|
def start(self, with_progress=True):
|
||||||
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 app.is_disabled_progressbar() or self.get_size() == -1:
|
if not with_progress or self.get_size() == -1:
|
||||||
click.echo("%s..." % label)
|
click.echo("%s..." % label)
|
||||||
for chunk in itercontent:
|
for chunk in itercontent:
|
||||||
if chunk:
|
if chunk:
|
||||||
@ -86,6 +86,8 @@ class FileDownloader(object):
|
|||||||
for _ in pb:
|
for _ in pb:
|
||||||
f.write(next(itercontent))
|
f.write(next(itercontent))
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
|
if with_progress:
|
||||||
|
return self.start(with_progress=False)
|
||||||
click.secho(
|
click.secho(
|
||||||
"Error: Please read http://bit.ly/package-manager-ioerror",
|
"Error: Please read http://bit.ly/package-manager-ioerror",
|
||||||
fg="red",
|
fg="red",
|
||||||
@ -98,6 +100,8 @@ class FileDownloader(object):
|
|||||||
if self.get_lmtime():
|
if self.get_lmtime():
|
||||||
self._preserve_filemtime(self.get_lmtime())
|
self._preserve_filemtime(self.get_lmtime())
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
def verify(self, sha1=None):
|
def verify(self, sha1=None):
|
||||||
_dlsize = getsize(self._destination)
|
_dlsize = getsize(self._destination)
|
||||||
if self.get_size() != -1 and _dlsize != self.get_size():
|
if self.get_size() != -1 and _dlsize != self.get_size():
|
||||||
|
@ -178,7 +178,7 @@ class PkgInstallerMixin(object):
|
|||||||
return dst_path
|
return dst_path
|
||||||
|
|
||||||
fd = FileDownloader(url, dest_dir)
|
fd = FileDownloader(url, dest_dir)
|
||||||
fd.start()
|
fd.start(with_progress=not app.is_disabled_progressbar())
|
||||||
if sha1:
|
if sha1:
|
||||||
fd.verify(sha1)
|
fd.verify(sha1)
|
||||||
dst_path = fd.get_filepath()
|
dst_path = fd.get_filepath()
|
||||||
|
Reference in New Issue
Block a user