forked from platformio/platformio-core
Fix "ConnectionError" when PlatformIO SF Storage is off-line
This commit is contained in:
@@ -6,6 +6,7 @@ Release History
|
|||||||
|
|
||||||
* Fixed resolving of C/C++ std libs by Eclipse IDE
|
* Fixed resolving of C/C++ std libs by Eclipse IDE
|
||||||
(`issue #220 <https://github.com/platformio/platformio/issues/220>`_)
|
(`issue #220 <https://github.com/platformio/platformio/issues/220>`_)
|
||||||
|
* Fixed "ConnectionError" when PlatformIO SF Storage is off-line
|
||||||
|
|
||||||
2.0.2 (2015-05-27)
|
2.0.2 (2015-05-27)
|
||||||
------------------
|
------------------
|
||||||
|
@@ -25,8 +25,11 @@ class FileDownloader(object):
|
|||||||
self._destination = self._fname
|
self._destination = self._fname
|
||||||
if dest_dir:
|
if dest_dir:
|
||||||
self.set_destination(join(dest_dir, self._fname))
|
self.set_destination(join(dest_dir, self._fname))
|
||||||
self._progressbar = None
|
|
||||||
|
|
||||||
|
self._progressbar = None
|
||||||
|
self._request = None
|
||||||
|
|
||||||
|
# make connection
|
||||||
self._request = requests.get(url, stream=True,
|
self._request = requests.get(url, stream=True,
|
||||||
headers=util.get_request_defheaders())
|
headers=util.get_request_defheaders())
|
||||||
if self._request.status_code != 200:
|
if self._request.status_code != 200:
|
||||||
@@ -93,4 +96,5 @@ class FileDownloader(object):
|
|||||||
util.change_filemtime(self._destination, lmtime)
|
util.change_filemtime(self._destination, lmtime)
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
self._request.close()
|
if self._request:
|
||||||
|
self._request.close()
|
||||||
|
@@ -2,11 +2,12 @@
|
|||||||
# See LICENSE for details.
|
# See LICENSE for details.
|
||||||
|
|
||||||
from os import makedirs, remove
|
from os import makedirs, remove
|
||||||
from os.path import isdir, join
|
from os.path import basename, isdir, isfile, join
|
||||||
from shutil import rmtree
|
from shutil import rmtree
|
||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
import requests
|
||||||
|
|
||||||
from platformio import exception, telemetry, util
|
from platformio import exception, telemetry, util
|
||||||
from platformio.app import get_state_item, set_state_item
|
from platformio.app import get_state_item, set_state_item
|
||||||
@@ -85,7 +86,17 @@ class PackageManager(object):
|
|||||||
if not isdir(pkg_dir):
|
if not isdir(pkg_dir):
|
||||||
makedirs(pkg_dir)
|
makedirs(pkg_dir)
|
||||||
|
|
||||||
dlpath = self.download(info['url'], pkg_dir, info['sha1'])
|
dlpath = None
|
||||||
|
try:
|
||||||
|
dlpath = self.download(info['url'], pkg_dir, info['sha1'])
|
||||||
|
except requests.exceptions.ConnectionError:
|
||||||
|
if info['url'].startswith("http://sourceforge.net"):
|
||||||
|
dlpath = self.download(
|
||||||
|
"http://dl.platformio.org/packages/%s" %
|
||||||
|
basename(info['url']), pkg_dir, info['sha1'])
|
||||||
|
|
||||||
|
assert isfile(dlpath)
|
||||||
|
|
||||||
if self.unpack(dlpath, pkg_dir):
|
if self.unpack(dlpath, pkg_dir):
|
||||||
self._register(name, info['version'])
|
self._register(name, info['version'])
|
||||||
# remove archive
|
# remove archive
|
||||||
|
Reference in New Issue
Block a user