forked from platformio/platformio-core
Fix "KeyError: 'content-length'" in PlatformIO Download Manager // Resolve #591
This commit is contained in:
@ -26,6 +26,9 @@ PlatformIO 2.0
|
|||||||
(`issue #571 <https://github.com/platformio/platformio/issues/571>`_)
|
(`issue #571 <https://github.com/platformio/platformio/issues/571>`_)
|
||||||
* Fixed invalid board parameters (reset method and baudrate) for a few
|
* Fixed invalid board parameters (reset method and baudrate) for a few
|
||||||
ESP8266 based boards
|
ESP8266 based boards
|
||||||
|
* Fixed "KeyError: 'content-length'" in PlatformIO Download Manager
|
||||||
|
(`issue #591 <https://github.com/platformio/platformio/issues/591>`_)
|
||||||
|
|
||||||
|
|
||||||
2.8.5 (2016-03-07)
|
2.8.5 (2016-03-07)
|
||||||
~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~
|
||||||
|
@ -309,7 +309,7 @@ Intelligent Code Autocompletion
|
|||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
PlatformIO IDE uses `clang <http://clang.llvm.org>`_ for the Intelligent Code Autocompletion.
|
PlatformIO IDE uses `clang <http://clang.llvm.org>`_ for the Intelligent Code Autocompletion.
|
||||||
To install it or check if it exists, please follow to step
|
To install it or check if it is already installed, please follow to step
|
||||||
:ref:`ide_atom_installation_clang` from Installation guide.
|
:ref:`ide_atom_installation_clang` from Installation guide.
|
||||||
|
|
||||||
.. warning::
|
.. warning::
|
||||||
|
@ -56,18 +56,21 @@ class FileDownloader(object):
|
|||||||
return self._request.headers['last-modified']
|
return self._request.headers['last-modified']
|
||||||
|
|
||||||
def get_size(self):
|
def get_size(self):
|
||||||
|
if "content-length" not in self._request.headers:
|
||||||
|
return -1
|
||||||
return int(self._request.headers['content-length'])
|
return int(self._request.headers['content-length'])
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
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")
|
||||||
chunks = int(ceil(self.get_size() / float(self.CHUNK_SIZE)))
|
|
||||||
|
|
||||||
if app.is_disabled_progressbar():
|
if app.is_disabled_progressbar() or self.get_size() == -1:
|
||||||
click.echo("Downloading...")
|
click.echo("Downloading...")
|
||||||
for _ in range(0, chunks):
|
for chunk in itercontent:
|
||||||
f.write(next(itercontent))
|
if chunk:
|
||||||
|
f.write(chunk)
|
||||||
else:
|
else:
|
||||||
|
chunks = int(ceil(self.get_size() / float(self.CHUNK_SIZE)))
|
||||||
with click.progressbar(length=chunks, label="Downloading") as pb:
|
with click.progressbar(length=chunks, label="Downloading") as pb:
|
||||||
for _ in pb:
|
for _ in pb:
|
||||||
f.write(next(itercontent))
|
f.write(next(itercontent))
|
||||||
@ -78,7 +81,7 @@ class FileDownloader(object):
|
|||||||
|
|
||||||
def verify(self, sha1=None):
|
def verify(self, sha1=None):
|
||||||
_dlsize = getsize(self._destination)
|
_dlsize = getsize(self._destination)
|
||||||
if _dlsize != self.get_size():
|
if self.get_size() != -1 and _dlsize != self.get_size():
|
||||||
raise FDSizeMismatch(_dlsize, self._fname, self.get_size())
|
raise FDSizeMismatch(_dlsize, self._fname, self.get_size())
|
||||||
|
|
||||||
if not sha1:
|
if not sha1:
|
||||||
|
Reference in New Issue
Block a user