forked from platformio/platformio-core
Test IPs which used for testing internet connection
This commit is contained in:
@ -575,15 +575,17 @@ def get_api_result(url, params=None, data=None, auth=None, cache_valid=None):
|
||||
"Please try later.")
|
||||
|
||||
|
||||
PING_INTERNET_IPS = [
|
||||
"159.122.18.156", # dl.bintray.com
|
||||
"193.222.52.25" # dl.platformio.org
|
||||
]
|
||||
|
||||
|
||||
@memoized
|
||||
def _internet_on():
|
||||
ips = [
|
||||
"193.222.52.25", # dl.platformio.org
|
||||
"159.122.18.156" # dl.bintray.com
|
||||
]
|
||||
timeout = 2
|
||||
socket.setdefaulttimeout(timeout)
|
||||
for ip in ips:
|
||||
for ip in PING_INTERNET_IPS:
|
||||
try:
|
||||
if os.getenv("HTTP_PROXY", os.getenv("HTTPS_PROXY")):
|
||||
requests.get("http://%s" % ip, timeout=timeout)
|
||||
|
21
tests/test_misc.py
Normal file
21
tests/test_misc.py
Normal file
@ -0,0 +1,21 @@
|
||||
# Copyright (c) 2014-present PlatformIO <contact@platformio.org>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# 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)
|
Reference in New Issue
Block a user