Skip to content

Commit

Permalink
ConnectionError needs to be imported from requests
Browse files Browse the repository at this point in the history
  • Loading branch information
liampauling committed Dec 18, 2016
1 parent 36277f3 commit fea4ad5
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 7 deletions.
3 changes: 2 additions & 1 deletion betfairlightweight/endpoints/baseendpoint.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
from requests import ConnectionError

from ..exceptions import APIError
from ..utils import check_status_code
Expand Down Expand Up @@ -27,7 +28,7 @@ def request(self, method, params, session):
try:
response = session.post(self.url, data=request, headers=self.client.request_headers,
timeout=(self.connect_timeout, self.read_timeout))
except session.ConnectionError:
except ConnectionError:
raise APIError(None, method, params, 'ConnectionError')
except Exception as e:
raise APIError(None, method, params, e)
Expand Down
3 changes: 2 additions & 1 deletion betfairlightweight/endpoints/inplayservice.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import datetime
from requests import ConnectionError

from ..exceptions import APIError
from ..utils import check_status_code
Expand Down Expand Up @@ -36,7 +37,7 @@ def request(self, method=None, params=None, session=None, url=None):
session = session or self.client.session
try:
response = session.get(url, params=params, headers=self.headers)
except session.ConnectionError:
except ConnectionError:
raise APIError(None, method, params, 'ConnectionError')
except Exception as e:
raise APIError(None, method, params, e)
Expand Down
4 changes: 3 additions & 1 deletion betfairlightweight/endpoints/keepalive.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from requests import ConnectionError

from .baseendpoint import BaseEndpoint
from ..exceptions import KeepAliveError, APIError
from ..utils import check_status_code
Expand All @@ -17,7 +19,7 @@ def request(self, payload=None, params=None, session=None):
session = session or self.client.session
try:
response = session.post(self.url, headers=self.client.keep_alive_headers, cert=self.client.cert)
except session.ConnectionError:
except ConnectionError:
raise APIError(None, exception='ConnectionError')
except Exception as e:
raise APIError(None, exception=e)
Expand Down
4 changes: 3 additions & 1 deletion betfairlightweight/endpoints/login.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from requests import ConnectionError

from .baseendpoint import BaseEndpoint
from ..exceptions import LoginError, APIError
from ..utils import check_status_code
Expand All @@ -17,7 +19,7 @@ def request(self, method=None, params=None, session=None):
session = session or self.client.session
try:
response = session.post(self.url, data=self.data, headers=self.client.login_headers, cert=self.client.cert)
except session.ConnectionError:
except ConnectionError:
raise APIError(None, exception='ConnectionError')
except Exception as e:
raise APIError(None, exception=e)
Expand Down
4 changes: 3 additions & 1 deletion betfairlightweight/endpoints/logout.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from requests import ConnectionError

from .baseendpoint import BaseEndpoint
from ..exceptions import LogoutError, APIError
from ..utils import check_status_code
Expand All @@ -17,7 +19,7 @@ def request(self, payload=None, params=None, session=None):
session = session or self.client.session
try:
response = session.post(self.url, headers=self.client.keep_alive_headers, cert=self.client.cert)
except session.ConnectionError:
except ConnectionError:
raise APIError(None, exception='ConnectionError')
except Exception as e:
raise APIError(None, exception=e)
Expand Down
4 changes: 3 additions & 1 deletion betfairlightweight/endpoints/navigation.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from requests import ConnectionError

from ..exceptions import APIError
from ..utils import check_status_code
from .baseendpoint import BaseEndpoint
Expand All @@ -13,7 +15,7 @@ def request(self, method=None, params=None, session=None):
try:
response = session.get(self.url, headers=self.client.request_headers,
timeout=(self.connect_timeout, self.read_timeout))
except session.ConnectionError:
except ConnectionError:
raise APIError(None, method, params, 'ConnectionError')
except Exception as e:
raise APIError(None, method, params, e)
Expand Down
3 changes: 2 additions & 1 deletion betfairlightweight/endpoints/racecard.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import re
import datetime
from requests import ConnectionError

from ..exceptions import APIError, RaceCardError
from ..utils import check_status_code
Expand Down Expand Up @@ -33,7 +34,7 @@ def request(self, method=None, params=None, session=None):
try:
response = session.get(self.url, params=self.create_req(method, params),
headers=self.headers)
except session.ConnectionError:
except ConnectionError:
raise APIError(None, method, params, 'ConnectionError')
except Exception as e:
raise APIError(None, method, params, e)
Expand Down

0 comments on commit fea4ad5

Please sign in to comment.