From de594188e52d0a89d4a77c59a397a4dec1586c4a Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Mon, 10 Mar 2014 11:28:22 -0500 Subject: [PATCH] Move exception classes higher in the file --- speedtest_cli.py | 113 +++++++++++++++++++++++++---------------------- 1 file changed, 60 insertions(+), 53 deletions(-) diff --git a/speedtest_cli.py b/speedtest_cli.py index c38e1b7..256790e 100755 --- a/speedtest_cli.py +++ b/speedtest_cli.py @@ -197,6 +197,66 @@ def print_dots(current, total, start=False, end=False): sys.stdout.flush() +class SpeedtestException(Exception): + """Base exception for this module""" + pass + + +class ConfigRetrievalError(SpeedtestException): + """Could not retrieve config.php""" + pass + + +class ServersRetrievalError(SpeedtestException): + """Could not retrieve speedtest-servers.php""" + pass + + +class InvalidServerIDType(SpeedtestException): + """Server ID used for filtering was not an integer""" + pass + + +class NoMatchedServers(SpeedtestException): + """No servers matched when filtering""" + pass + + +class SpeedtestMiniConnectFailure(SpeedtestException): + """Could not connect to the provided speedtest mini server""" + pass + + +class InvalidSpeedtestMiniServer(SpeedtestException): + """Server provided as a speedtest mini server does not actually appear + to be a speedtest mini server + + """ + pass + + +class ShareResultsConnectFailure(SpeedtestException): + """Could not connect to speedtest.net API to POST results""" + pass + + +class ShareResultsSubmitFailure(SpeedtestException): + """Unable to successfully POST results to speedtest.net API after + connection + + """ + pass + + +class SpeedtestUploadTimeout(SpeedtestException): + """testlength configuration reached during upload + + Used to ensure the upload halts when no additional data should be sent + + """ + pass + + class HTTPDownloader(threading.Thread): """Thread class for retrieving a URL""" @@ -225,10 +285,6 @@ class HTTPDownloader(threading.Thread): pass -class SpeedtestUploadTimeout(Exception): - pass - - class HTTPUploaderData(object): def __init__(self, length, start, timeout): self.length = length @@ -283,55 +339,6 @@ class HTTPUploader(threading.Thread): self.result = sum(self.data.total) -class SpeedtestException(Exception): - """Base exception for this module""" - pass - - -class ConfigRetrievalError(SpeedtestException): - """Could not retrieve config.php""" - pass - - -class ServersRetrievalError(SpeedtestException): - """Could not retrieve speedtest-servers.php""" - pass - - -class InvalidServerIDType(SpeedtestException): - """Server ID used for filtering was not an integer""" - pass - - -class NoMatchedServers(SpeedtestException): - """No servers matched when filtering""" - pass - - -class SpeedtestMiniConnectFailure(SpeedtestException): - """Could not connect to the provided speedtest mini server""" - pass - - -class InvalidSpeedtestMiniServer(SpeedtestException): - """Server provided as a speedtest mini server does not actually appear - to be a speedtest mini server - """ - pass - - -class ShareResultsConnectFailure(SpeedtestException): - """Could not connect to speedtest.net API to POST results""" - pass - - -class ShareResultsSubmitFailure(SpeedtestException): - """Unable to successfully POST results to speedtest.net API after - connection - """ - pass - - class SpeedtestResults(object): """Class for holding the results of a speedtest, including: