Skip to content

Commit

Permalink
Update hash endpoint, catch SocksError explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
Noctem committed Mar 7, 2017
1 parent e19c992 commit 4eed591
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
8 changes: 6 additions & 2 deletions aiopogo/auth_ptc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
from asyncio import get_event_loop, TimeoutError, CancelledError

from aiohttp import TCPConnector, ClientSession, ClientError, DisconnectedError, HttpProcessingError
try:
from aiosocks.errors import SocksError
except ImportError:
class SocksError(Exception): pass

from .session import socks_connector, CONN_TIMEOUT
from .auth import Auth
Expand Down Expand Up @@ -110,7 +114,7 @@ async def user_login(self, username=None, password=None, retry=True):
raise AuthConnectionException('Error {} during user_login: {}'.format(e.code, e.message))
except (TimeoutError, TimeoutException) as e:
raise AuthTimeoutException('user_login timeout.') from e
except ProxyException as e:
except (ProxyException, SocksError) as e:
raise ProxyException('Proxy connection error during user_login.') from e
except jexc as e:
raise AuthException('Unable to parse user_login response.') from e
Expand Down Expand Up @@ -183,7 +187,7 @@ async def get_access_token(self, force_refresh=False):
raise AuthConnectionException('Error {} while fetching access token: {}'.format(e.code, e.message))
except (TimeoutError, TimeoutException) as e:
raise AuthTimeoutException('Access token request timed out.') from e
except ProxyException as e:
except (ProxyException, SocksError) as e:
raise ProxyException('Proxy connection error while fetching access token.') from e
except (ClientError, DisconnectedError) as e:
raise AuthConnectionException('{} while fetching access token.'.format(e.__class__.__name__)) from e
Expand Down
6 changes: 1 addition & 5 deletions aiopogo/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
from aiohttp import ProxyConnectionError
from asyncio import TimeoutError
try:
from aiosocks import SocksError
except ImportError:
class SocksError(Exception): pass


class AiopogoError(Exception):
Expand All @@ -12,7 +8,7 @@ class AiopogoError(Exception):
class HashServerException(AiopogoError):
"""Parent class of all hashing server errors"""

class ProxyException(ProxyConnectionError, SocksError):
class ProxyException(ProxyConnectionError):
"""Raised when there is an error connecting to a proxy server."""

class TimeoutException(AiopogoError, TimeoutError):
Expand Down
2 changes: 1 addition & 1 deletion aiopogo/hash_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


class HashServer:
endpoint = "https://pokehash.buddyauth.com/api/v127_3/hash"
endpoint = "https://pokehash.buddyauth.com/api/v127_4/hash"
status = {}
_session = None
loop = get_event_loop()
Expand Down
6 changes: 5 additions & 1 deletion aiopogo/rpc_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
from protobuf_to_dict import protobuf_to_dict
from aiohttp import ClientError, DisconnectedError, HttpProcessingError
from pycrypt import pycrypt
try:
from aiosocks.errors import SocksError
except ImportError:
class SocksError(Exception): pass

from .exceptions import *
from .utilities import to_camel_case, get_time_ms, get_lib_path, IdGenerator, CustomRandom
Expand Down Expand Up @@ -90,7 +94,7 @@ async def _make_rpc(self, endpoint, request_proto_plain):
raise NianticOfflineException('{} Niantic server error: {}'.format(e.code, e.message))
else:
raise UnexpectedResponseException('Unexpected RPC response: {}, '.format(e.code, e.message))
except ProxyException as e:
except (ProxyException, SocksError) as e:
raise ProxyException('Proxy connection error during RPC request.') from e
except (TimeoutException, TimeoutError) as e:
raise NianticTimeoutException('RPC request timed out.') from e
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
author = 'David Christenson',
author_email='mail@noctem.xyz',
description = 'Asynchronous Pokemon API lib',
version = '1.3.4',
version = '1.3.5',
url = 'https://github.com/Noctem/aiopogo',
packages = find_packages(),
install_requires = [
Expand Down

0 comments on commit 4eed591

Please sign in to comment.