Be consistent, explicitly instantiate all exceptions
This commit is contained in:
parent
955a756c96
commit
e2f815618b
10
speedtest.py
10
speedtest.py
|
@ -565,7 +565,7 @@ class HTTPUploaderData(object):
|
||||||
self.total.append(len(chunk))
|
self.total.append(len(chunk))
|
||||||
return chunk
|
return chunk
|
||||||
else:
|
else:
|
||||||
raise SpeedtestUploadTimeout
|
raise SpeedtestUploadTimeout()
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
return self.length
|
return self.length
|
||||||
|
@ -874,7 +874,7 @@ class Speedtest(object):
|
||||||
uh, e = catch_request(request)
|
uh, e = catch_request(request)
|
||||||
if e:
|
if e:
|
||||||
errors.append('%s' % e)
|
errors.append('%s' % e)
|
||||||
raise ServersRetrievalError
|
raise ServersRetrievalError()
|
||||||
|
|
||||||
stream = get_response_stream(uh)
|
stream = get_response_stream(uh)
|
||||||
|
|
||||||
|
@ -888,7 +888,7 @@ class Speedtest(object):
|
||||||
uh.close()
|
uh.close()
|
||||||
|
|
||||||
if int(uh.code) != 200:
|
if int(uh.code) != 200:
|
||||||
raise ServersRetrievalError
|
raise ServersRetrievalError()
|
||||||
|
|
||||||
printer(''.encode().join(serversxml), debug=True)
|
printer(''.encode().join(serversxml), debug=True)
|
||||||
|
|
||||||
|
@ -900,7 +900,7 @@ class Speedtest(object):
|
||||||
root = DOM.parseString(''.join(serversxml))
|
root = DOM.parseString(''.join(serversxml))
|
||||||
elements = root.getElementsByTagName('server')
|
elements = root.getElementsByTagName('server')
|
||||||
except (SyntaxError, xml.parsers.expat.ExpatError):
|
except (SyntaxError, xml.parsers.expat.ExpatError):
|
||||||
raise ServersRetrievalError
|
raise ServersRetrievalError()
|
||||||
|
|
||||||
for server in elements:
|
for server in elements:
|
||||||
try:
|
try:
|
||||||
|
@ -936,7 +936,7 @@ class Speedtest(object):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if servers and not self.servers:
|
if servers and not self.servers:
|
||||||
raise NoMatchedServers
|
raise NoMatchedServers()
|
||||||
|
|
||||||
return self.servers
|
return self.servers
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue