This commit is contained in:
Gal Golan 2016-09-05 00:29:14 +00:00 committed by GitHub
commit 70e08aab17
2 changed files with 8 additions and 14 deletions

View File

@ -25,8 +25,8 @@ env:
- TOXENV=flake8 - TOXENV=flake8
install: install:
- if [[ $(echo "$TOXENV" | egrep -c "(py2[45]|py31)") != 0 ]]; then pip install virtualenv==1.7.2 tox==1.3; fi; - if [[ $(echo "$TOXENV" | egrep -c "(py2[45]|py31)") != 0 ]]; then pip install virtualenv==1.7.2 tox==1.3 requests; fi;
- if [[ $(echo "$TOXENV" | egrep -c "(py2[45]|py31)") == 0 ]]; then pip install tox; fi; - if [[ $(echo "$TOXENV" | egrep -c "(py2[45]|py31)") == 0 ]]; then pip install tox requests; fi;
script: script:
- tox - tox

View File

@ -21,6 +21,7 @@ import sys
import math import math
import signal import signal
import socket import socket
import requests
import timeit import timeit
import platform import platform
import threading import threading
@ -375,19 +376,12 @@ def getConfig():
we are interested in we are interested in
""" """
request = build_request('://www.speedtest.net/speedtest-config.php') uh = requests.get('http://www.speedtest.net/speedtest-config.php', headers = {'user-agent':user_agent})
uh, e = catch_request(request) configxml = uh.text
if e:
print_('Could not retrieve speedtest.net configuration: %s' % e) if(int(uh.status_code) != 200):
sys.exit(1)
configxml = []
while 1:
configxml.append(uh.read(10240))
if len(configxml[-1]) == 0:
break
if int(uh.code) != 200:
return None return None
uh.close()
try: try:
try: try:
root = ET.fromstring(''.encode().join(configxml)) root = ET.fromstring(''.encode().join(configxml))