Check PIO download storage for "Internet ON"

This commit is contained in:
Ivan Kravets
2017-06-01 19:47:50 +03:00
parent a53a38b5dd
commit e2811a4a28
2 changed files with 10 additions and 9 deletions

2
docs

Submodule docs updated: 89630419d5...1666723f26

View File

@ -540,14 +540,15 @@ def get_api_result(url, params=None, data=None, auth=None, cache_valid=None):
def internet_on(timeout=3):
host = "dl.bintray.com"
port = 443
try:
socket.setdefaulttimeout(timeout)
socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect((host, port))
return True
except: # pylint: disable=bare-except
return False
socket.setdefaulttimeout(timeout)
for host in ("dl.bintray.com", "dl.platformio.org"):
try:
socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect(
(host, 80))
return True
except: # pylint: disable=bare-except
pass
return False
def get_pythonexe_path():