Compare commits
1 Commits
master
...
py26-33-tr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3884809fab |
@ -1,7 +1,3 @@
|
||||
#Usage
|
||||
|
||||
$ curl -s https://git.spectre5.com/adamcruz/speedtest-cli-pub/raw/branch/master/speedtest.py | python -
|
||||
|
||||
speedtest-cli
|
||||
=============
|
||||
|
||||
|
||||
29
speedtest.py
29
speedtest.py
@ -36,7 +36,7 @@ except ImportError:
|
||||
gzip = None
|
||||
GZIP_BASE = object
|
||||
|
||||
__version__ = '2.0.2'
|
||||
__version__ = '2.0.1a'
|
||||
|
||||
|
||||
class FakeShutdownEvent(object):
|
||||
@ -85,9 +85,9 @@ except ImportError:
|
||||
HTTPErrorProcessor, OpenerDirector)
|
||||
|
||||
try:
|
||||
from httplib import HTTPConnection, BadStatusLine
|
||||
from httplib import HTTPConnection
|
||||
except ImportError:
|
||||
from http.client import HTTPConnection, BadStatusLine
|
||||
from http.client import HTTPConnection
|
||||
|
||||
try:
|
||||
from httplib import HTTPSConnection
|
||||
@ -266,13 +266,10 @@ try:
|
||||
except AttributeError:
|
||||
CERT_ERROR = tuple()
|
||||
|
||||
HTTP_ERRORS = (
|
||||
(HTTPError, URLError, socket.error, ssl.SSLError, BadStatusLine) +
|
||||
CERT_ERROR
|
||||
)
|
||||
HTTP_ERRORS = ((HTTPError, URLError, socket.error, ssl.SSLError) +
|
||||
CERT_ERROR)
|
||||
except ImportError:
|
||||
ssl = None
|
||||
HTTP_ERRORS = (HTTPError, URLError, socket.error, BadStatusLine)
|
||||
HTTP_ERRORS = (HTTPError, URLError, socket.error)
|
||||
|
||||
|
||||
class SpeedtestException(Exception):
|
||||
@ -423,12 +420,14 @@ if HTTPSConnection:
|
||||
"""
|
||||
def __init__(self, *args, **kwargs):
|
||||
source_address = kwargs.pop('source_address', None)
|
||||
context = kwargs.pop('context', None)
|
||||
timeout = kwargs.pop('timeout', 10)
|
||||
|
||||
HTTPSConnection.__init__(self, *args, **kwargs)
|
||||
|
||||
self.timeout = timeout
|
||||
self.source_address = source_address
|
||||
self._context = context
|
||||
self.timeout = timeout
|
||||
|
||||
def connect(self):
|
||||
"Connect to a host on a given (SSL) port."
|
||||
@ -436,13 +435,9 @@ if HTTPSConnection:
|
||||
SpeedtestHTTPConnection.connect(self)
|
||||
|
||||
kwargs = {}
|
||||
if ssl:
|
||||
if hasattr(ssl, 'SSLContext'):
|
||||
kwargs['server_hostname'] = self.host
|
||||
try:
|
||||
self.sock = self._context.wrap_socket(self.sock, **kwargs)
|
||||
except AttributeError:
|
||||
self.sock = ssl.wrap_socket(self.sock, **kwargs)
|
||||
if hasattr(ssl, 'SSLContext'):
|
||||
kwargs['server_hostname'] = self.host
|
||||
self.sock = self._context.wrap_socket(self.sock, **kwargs)
|
||||
|
||||
|
||||
def _build_connection(connection, source_address, timeout, context=None):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user