mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 10:07:14 +02:00
YAPF
This commit is contained in:
@ -71,18 +71,18 @@ class FileDownloader(object):
|
|||||||
return int(self._request.headers['content-length'])
|
return int(self._request.headers['content-length'])
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
|
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 app.is_disabled_progressbar() or self.get_size() == -1:
|
||||||
click.echo("Downloading...")
|
click.echo("%s..." % label)
|
||||||
for chunk in itercontent:
|
for chunk in itercontent:
|
||||||
if chunk:
|
if chunk:
|
||||||
f.write(chunk)
|
f.write(chunk)
|
||||||
else:
|
else:
|
||||||
chunks = int(ceil(self.get_size() / float(self.CHUNK_SIZE)))
|
chunks = int(ceil(self.get_size() / float(self.CHUNK_SIZE)))
|
||||||
with click.progressbar(
|
with click.progressbar(length=chunks, label=label) as pb:
|
||||||
length=chunks, label="Downloading") as pb:
|
|
||||||
for _ in pb:
|
for _ in pb:
|
||||||
f.write(next(itercontent))
|
f.write(next(itercontent))
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
|
@ -315,8 +315,9 @@ def on_event(category, action, label=None, value=None, screen_name=None):
|
|||||||
def on_exception(e):
|
def on_exception(e):
|
||||||
skip_conditions = [
|
skip_conditions = [
|
||||||
isinstance(e, cls)
|
isinstance(e, cls)
|
||||||
for cls in (IOError, exception.AbortedByUser,
|
for cls in (IOError, exception.ReturnErrorCode,
|
||||||
exception.NotGlobalLibDir, exception.InternetIsOffline,
|
exception.AbortedByUser, exception.NotGlobalLibDir,
|
||||||
|
exception.InternetIsOffline,
|
||||||
exception.NotPlatformIOProject,
|
exception.NotPlatformIOProject,
|
||||||
exception.UserSideException)
|
exception.UserSideException)
|
||||||
]
|
]
|
||||||
|
@ -13,9 +13,10 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from platformio import util
|
from platformio import util
|
||||||
|
|
||||||
|
|
||||||
def test_ping_internet_ips():
|
def test_ping_internet_ips():
|
||||||
for ip in util.PING_INTERNET_IPS:
|
for ip in util.PING_INTERNET_IPS:
|
||||||
requests.get("http://%s" % ip, timeout=2)
|
requests.get("http://%s" % ip, timeout=2)
|
||||||
|
Reference in New Issue
Block a user