This commit is contained in:
Ivan Kravets
2017-12-14 22:01:59 +02:00
parent 736c6a9a1e
commit 0bd103a46d
3 changed files with 8 additions and 6 deletions

View File

@ -71,18 +71,18 @@ class FileDownloader(object):
return int(self._request.headers['content-length'])
def start(self):
label = "Downloading"
itercontent = self._request.iter_content(chunk_size=self.CHUNK_SIZE)
f = open(self._destination, "wb")
try:
if app.is_disabled_progressbar() or self.get_size() == -1:
click.echo("Downloading...")
click.echo("%s..." % label)
for chunk in itercontent:
if chunk:
f.write(chunk)
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=label) as pb:
for _ in pb:
f.write(next(itercontent))
except IOError as e:

View File

@ -315,8 +315,9 @@ def on_event(category, action, label=None, value=None, screen_name=None):
def on_exception(e):
skip_conditions = [
isinstance(e, cls)
for cls in (IOError, exception.AbortedByUser,
exception.NotGlobalLibDir, exception.InternetIsOffline,
for cls in (IOError, exception.ReturnErrorCode,
exception.AbortedByUser, exception.NotGlobalLibDir,
exception.InternetIsOffline,
exception.NotPlatformIOProject,
exception.UserSideException)
]

View File

@ -13,9 +13,10 @@
# limitations under the License.
import requests
from platformio import util
def test_ping_internet_ips():
for ip in util.PING_INTERNET_IPS:
requests.get("http://%s" % ip, timeout=2)
requests.get("http://%s" % ip, timeout=2)