diff --git a/aiopogo/__init__.py b/aiopogo/__init__.py index 00fa8040..e71616e4 100755 --- a/aiopogo/__init__.py +++ b/aiopogo/__init__.py @@ -13,7 +13,8 @@ raise PleaseInstallProtobufVersion3('Protobuf not found, install it.') if int(protobuf_version[:1]) < 3: - raise PleaseInstallProtobufVersion3('Protobuf 3 needed, you have {}'.format(protobuf_version)) + raise PleaseInstallProtobufVersion3( + 'Protobuf 3 needed, you have {}'.format(protobuf_version)) from os import path import sys @@ -34,10 +35,12 @@ from .rpc_api import RpcApi from .hash_server import HashServer + def close_sessions(): SESSIONS.close() HashServer.close_session() + def activate_hash_server(hash_token, conn_limit=300): HashServer.set_token(hash_token) HashServer.activate_session(conn_limit) diff --git a/aiopogo/auth.py b/aiopogo/auth.py index 4790e25f..35a79f79 100755 --- a/aiopogo/auth.py +++ b/aiopogo/auth.py @@ -4,6 +4,7 @@ from .utilities import get_time_ms + class Auth: loop = get_event_loop() @@ -42,10 +43,10 @@ def is_new_ticket(self, new_ticket_time_ms): def check_ticket(self): if get_time_ms() < (self._ticket_expire - 10000): return True - else: - self.log.debug('Removed expired Session Ticket (%s)', self._ticket_expire) - self._ticket_expire, self._ticket_start, self._ticket_end = 0, None, None - return False + self.log.debug( + 'Removed expired Session Ticket (%s)', self._ticket_expire) + self._ticket_expire, self._ticket_start, self._ticket_end = 0, None, None + return False def get_ticket(self): return self._ticket_expire, self._ticket_start, self._ticket_end diff --git a/aiopogo/auth_google.py b/aiopogo/auth_google.py index 27b70bff..692a561a 100755 --- a/aiopogo/auth_google.py +++ b/aiopogo/auth_google.py @@ -7,9 +7,10 @@ from .auth import Auth from .exceptions import AuthException, InvalidCredentialsException + class AuthGoogle(Auth): GOOGLE_LOGIN_ANDROID_ID = '9774d56d682e549c' - GOOGLE_LOGIN_SERVICE= 'audience:server:client_id:848232511240-7so421jotr2609rmqakceuu1luuq0ptb.apps.googleusercontent.com' + GOOGLE_LOGIN_SERVICE = 'audience:server:client_id:848232511240-7so421jotr2609rmqakceuu1luuq0ptb.apps.googleusercontent.com' GOOGLE_LOGIN_APP = 'com.nianticlabs.pokemongo' GOOGLE_LOGIN_CLIENT_SIG = '321187995bc7cdc2b5fc91b11a96e2baa8602c62' @@ -21,16 +22,24 @@ def __init__(self, proxy=None, refresh_token=None): self._proxy = proxy async def user_login(self, username, password): - self.log.info('Google User Login for: {}'.format(username)) + self.log.info('Google User Login for: %s', username) try: - assert isinstance(self._username, str) and isinstance(self._password, str) + assert (isinstance(username, str) + and isinstance(password, str)) except AssertionError: - raise InvalidCredentialsException("Username/password not correctly specified") + raise InvalidCredentialsException( + "Username/password not correctly specified") + + login = partial( + perform_master_login, + username, + password, + self.GOOGLE_LOGIN_ANDROID_ID, + proxy=self._proxy) - login = partial(perform_master_login, username, password, self.GOOGLE_LOGIN_ANDROID_ID, proxy=self._proxy) - with ThreadPoolExecutor(max_workers=1) as x: - user_login = await self.loop.run_in_executor(x, login) + with ThreadPoolExecutor(max_workers=1) as executor: + user_login = await self.loop.run_in_executor(executor, login) try: self._refresh_token = user_login['Token'] @@ -43,30 +52,31 @@ async def get_access_token(self, force_refresh=False): if not force_refresh and self.check_access_token(): self.log.debug('Using cached Google access token') return self._access_token - else: + + self._access_token = None + self.authenticated = False + self.log.info('Requesting Google access token...') + + oauth = partial(perform_oauth, None, self._refresh_token, + self.GOOGLE_LOGIN_ANDROID_ID, self.GOOGLE_LOGIN_SERVICE, + self.GOOGLE_LOGIN_APP, self.GOOGLE_LOGIN_CLIENT_SIG, + proxy=self._proxy) + with ThreadPoolExecutor(max_workers=1) as executor: + token_data = await self.loop.run_in_executor(executor, oauth) + + try: + self._access_token = token_data['Auth'] + except KeyError: self._access_token = None self.authenticated = False - self.log.info('Requesting Google access token...') - - oauth = partial(perform_oauth, None, self._refresh_token, - self.GOOGLE_LOGIN_ANDROID_ID, self.GOOGLE_LOGIN_SERVICE, - self.GOOGLE_LOGIN_APP, self.GOOGLE_LOGIN_CLIENT_SIG, - proxy=self._proxy) - with ThreadPoolExecutor(max_workers=1) as x: - token_data = await self.loop.run_in_executor(x, oauth) - - try: - self._access_token = token_data['Auth'] - except KeyError: - self._access_token = None - self.authenticated = False - raise AuthException("Could not receive a Google Access Token") - - try: - self._access_token_expiry = token_data['Expiry'] - except KeyError: - self._access_token_expiry = time() + 7200.0 - self.authenticated = True - self.log.info('Google Access Token successfully received.') - self.log.debug('Google Access Token: %s...', self._access_token[:25]) - return self._access_token + raise AuthException("Could not receive a Google Access Token") + + try: + self._access_token_expiry = token_data['Expiry'] + except KeyError: + self._access_token_expiry = time() + 7200.0 + self.authenticated = True + self.log.info('Google Access Token successfully received.') + self.log.debug('Google Access Token: %s...', + self._access_token[:25]) + return self._access_token diff --git a/aiopogo/auth_ptc.py b/aiopogo/auth_ptc.py index f7dae440..8ab7556f 100755 --- a/aiopogo/auth_ptc.py +++ b/aiopogo/auth_ptc.py @@ -9,8 +9,10 @@ from .auth import Auth from .exceptions import ActivationRequiredException, AuthConnectionException, AuthException, AuthTimeoutException, InvalidCredentialsException, ProxyException, SocksError, UnexpectedAuthError + class AuthPtc(Auth): - def __init__(self, username=None, password=None, proxy=None, proxy_auth=None, timeout=None, locale=None): + def __init__(self, username=None, password=None, proxy=None, + proxy_auth=None, timeout=None, locale=None): Auth.__init__(self) self.provider = 'ptc' @@ -28,17 +30,20 @@ async def user_login(self, username=None, password=None): self._password = password or self._password try: - assert isinstance(self._username, str) and isinstance(self._password, str) + assert (isinstance(self._username, str) + and isinstance(self._password, str)) except AssertionError as e: - raise InvalidCredentialsException("Username/password not correctly specified") from e - self.log.info('PTC User Login for: {}'.format(self._username)) + raise InvalidCredentialsException( + "Username/password not correctly specified") from e + self.log.info('PTC User Login for: %s', self._username) try: now = time() async with ClientSession( connector=SESSIONS.get_connector(self.socks), loop=self.loop, - headers=(('User-Agent', 'niantic'), ('Host', 'sso.pokemon.com')), + headers=(('User-Agent', 'niantic'), + ('Host', 'sso.pokemon.com')), skip_auto_headers=('Accept', 'Accept-Encoding'), request_class=ProxyClientRequest if self.socks else ClientRequest, connector_owner=False, @@ -74,11 +79,13 @@ async def user_login(self, username=None, password=None): except (ClientHttpProxyError, ClientProxyConnectionError, SocksError) as e: raise ProxyException('Proxy connection error during user_login.') from e except ClientResponseError as e: - raise AuthConnectionException('Error {} during user_login: {}'.format(e.code, e.message)) + raise AuthConnectionException('Error {} during user_login: {}'.format( + e.code, e.message)) except (TimeoutError, ServerTimeoutError) as e: raise AuthTimeoutException('user_login timeout.') from e except ClientError as e: - raise AuthConnectionException('{} during user_login.'.format(e.__class__.__name__)) from e + raise AuthConnectionException('{} during user_login.'.format( + e.__class__.__name__)) from e except (AssertionError, TypeError, ValueError) as e: raise AuthException('Invalid initial JSON response.') from e @@ -91,8 +98,8 @@ async def get_access_token(self, force_refresh=False): if not force_refresh and self.check_access_token(): self.log.debug('Using cached PTC Access Token') return self._access_token - else: - self._access_token = None - self.authenticated = False - await self.user_login() - return self._access_token + + self._access_token = None + self.authenticated = False + await self.user_login() + return self._access_token diff --git a/aiopogo/exceptions.py b/aiopogo/exceptions.py index 1a4f940d..22fe5ac9 100755 --- a/aiopogo/exceptions.py +++ b/aiopogo/exceptions.py @@ -56,9 +56,6 @@ class ExpiredHashKeyException(HashServerException): class InvalidCredentialsException(AiopogoError, ValueError): """Raised when the username, password, or provider are empty/invalid""" -class InvalidCredentialsException(AiopogoError, ValueError): - """Raised when the username, password, or provider are empty/invalid""" - class MalformedResponseException(AiopogoError): """Raised when the response is empty or not in an expected format""" @@ -134,6 +131,6 @@ class UnexpectedHashResponseException(UnexpectedResponseException, HashServerExc class ServerApiEndpointRedirectException(AiopogoError): """Raised when the API redirects you to another endpoint""" + def __init__(self, endpoint): self.endpoint = endpoint - diff --git a/aiopogo/hash_server.py b/aiopogo/hash_server.py index 43fba93c..5a32497f 100644 --- a/aiopogo/hash_server.py +++ b/aiopogo/hash_server.py @@ -4,13 +4,12 @@ from itertools import cycle from time import time from logging import getLogger -from struct import pack, unpack from aiohttp import ClientSession, ClientError, ClientResponseError, ServerConnectionError, ServerTimeoutError from . import json_dumps, json_loads -from .exceptions import BadHashRequestException, ExpiredHashKeyException, HashingOfflineException, HashingTimeoutException, MalformedHashResponseException, NoHashKeyException, TempHashingBanException, TimeoutException, UnexpectedHashResponseException from .connector import TimedConnector +from .exceptions import BadHashRequestException, ExpiredHashKeyException, HashingOfflineException, HashingTimeoutException, MalformedHashResponseException, NoHashKeyException, TempHashingBanException, UnexpectedHashResponseException from .utilities import f2i @@ -25,7 +24,8 @@ def __init__(self): try: self.instance_token = self.auth_token except AttributeError: - NoHashKeyException('You must provide a hash key before making a request.') + NoHashKeyException( + 'You must provide a hash key before making a request.') async def hash(self, timestamp, latitude, longitude, accuracy, authticket, sessiondata, requests): status = self.key_status @@ -58,12 +58,14 @@ async def hash(self, timestamp, latitude, longitude, accuracy, authticket, sessi for attempt in range(2): try: async with self._session.post("http://pokehash.buddyauth.com/api/v133_1/hash", headers=headers, json=payload) as resp: - if 400 <= resp.status: + if resp.status >= 400: if resp.status == 400: response = await resp.text() if response == 'Unauthorized': if self.multi: - self.log.warning('{:.10}... expired, removing from rotation.'.format(self.instance_token)) + self.log.warning( + '{:.10}... expired, removing from rotation.'.format( + self.instance_token)) self.remove_token(self.instance_token) self.instance_token = self.auth_token if attempt < 1: @@ -85,7 +87,9 @@ async def hash(self, timestamp, latitude, longitude, accuracy, authticket, sessi self.instance_token = self.auth_token return await self.hash(timestamp, latitude, longitude, accuracy, authticket, sessiondata, requests) elif e.code >= 500 or e.code == 404: - raise HashingOfflineException('Hashing server error {}: {}'.format(e.code, e.message)) + raise HashingOfflineException( + 'Hashing server error {}: {}'.format( + e.code, e.message)) else: raise UnexpectedHashResponseException('Unexpected hash code {}: {}'.format(e.code, e.message)) except ValueError as e: diff --git a/aiopogo/pgoapi.py b/aiopogo/pgoapi.py index cbbe9530..6c64fa96 100755 --- a/aiopogo/pgoapi.py +++ b/aiopogo/pgoapi.py @@ -7,7 +7,8 @@ except ImportError: class Socks4Auth(Exception): def __init__(*args, **kwargs): - raise ImportError('You must install aiosocks to use a SOCKS proxy.') + raise ImportError( + 'You must install aiosocks to use a SOCKS proxy.') Socks5Auth = Socks4Auth from . import __title__, __version__ @@ -23,7 +24,7 @@ class PGoApi: log = getLogger(__name__) log.info('%s v%s', __title__, __version__) - def __init__(self, provider=None, lat=None, lon=None, alt=None, proxy=None, device_info=None): + def __init__(self, lat=None, lon=None, alt=None, proxy=None, device_info=None): self.auth_provider = None self.state = RpcState() @@ -39,13 +40,20 @@ def __init__(self, provider=None, lat=None, lon=None, alt=None, proxy=None, devi async def set_authentication(self, provider='ptc', username=None, password=None, timeout=10, locale='en_US', refresh_token=None): if provider == 'ptc': - self.auth_provider = AuthPtc(username, password, proxy=self._proxy, proxy_auth=self.proxy_auth, timeout=timeout) + self.auth_provider = AuthPtc( + username, + password, + proxy=self._proxy, + proxy_auth=self.proxy_auth, + timeout=timeout) elif provider == 'google': - self.auth_provider = AuthGoogle(proxy=proxy, refresh_token=refresh_token) + self.auth_provider = AuthGoogle( + proxy=self._proxy, refresh_token=refresh_token) if refresh_token: return await self.auth_provider.get_access_token() else: - raise InvalidCredentialsException("Invalid authentication provider - only ptc/google available.") + raise InvalidCredentialsException( + "Invalid authentication provider - only ptc/google available.") await self.auth_provider.user_login(username, password) @@ -58,7 +66,8 @@ def set_position(self, lat, lon, alt=None): def create_request(self): return PGoApiRequest(self) - def activate_hash_server(self, hash_token, conn_limit=300): + @staticmethod + def activate_hash_server(hash_token, conn_limit=300): HashServer.set_token(hash_token) HashServer.activate_session(conn_limit) @@ -90,13 +99,16 @@ def proxy(self, proxy): if self._proxy.user: scheme = self._proxy.scheme if scheme == 'http': - self.proxy_auth = BasicAuth(self._proxy.user, self._proxy.password) + self.proxy_auth = BasicAuth( + self._proxy.user, self._proxy.password) elif scheme == 'socks5': - self.proxy_auth = Socks5Auth(self._proxy.user, self._proxy.password) + self.proxy_auth = Socks5Auth( + self._proxy.user, self._proxy.password) elif scheme == 'socks4': self.proxy_auth = Socks4Auth(self._proxy.user) else: - raise ValueError('Proxy protocol must be http, socks5, or socks4.') + raise ValueError( + 'Proxy protocol must be http, socks5, or socks4.') @property def start_time(self): @@ -153,12 +165,14 @@ def list_curr_methods(self): def __getattr__(self, func): func = func.upper() + def function(**kwargs): self.log.debug('Creating a new request...') try: if kwargs: - self._req_method_list.append((RequestType.Value(func), kwargs)) + self._req_method_list.append( + (RequestType.Value(func), kwargs)) self.log.debug("Arguments of '%s': \n\r%s", func, kwargs) else: self._req_method_list.append(RequestType.Value(func)) diff --git a/aiopogo/rpc_api.py b/aiopogo/rpc_api.py index 438a42f5..b47308f3 100755 --- a/aiopogo/rpc_api.py +++ b/aiopogo/rpc_api.py @@ -36,26 +36,37 @@ async def _make_rpc(self, endpoint, proto, proxy, proxy_auth, _sessions=SESSIONS async with _sessions.get(proxy).post(endpoint, data=proto.SerializeToString(), proxy=proxy, proxy_auth=proxy_auth) as resp: return await resp.read() except (ClientHttpProxyError, ClientProxyConnectionError, SocksError) as e: - raise ProxyException('Proxy connection error during RPC request.') from e + raise ProxyException( + 'Proxy connection error during RPC request.') from e except ClientResponseError as e: if e.code == 400: - raise BadRequestException("400: Bad RPC request. {}".format(e.message)) + raise BadRequestException( + "400: Bad RPC request. {}".format( + e.message)) elif e.code == 403: - raise NianticIPBannedException("Seems your IP Address is banned or something else went badly wrong.") + raise NianticIPBannedException( + "Seems your IP Address is banned or something else went badly wrong.") elif e.code >= 500: - raise NianticOfflineException('{} Niantic server error: {}'.format(e.code, e.message)) + raise NianticOfflineException( + '{} Niantic server error: {}'.format( + e.code, e.message)) else: - raise UnexpectedResponseException('Unexpected RPC response: {}, {}'.format(e.code, e.message)) + raise UnexpectedResponseException( + 'Unexpected RPC response: {}, {}'.format( + e.code, e.message)) except (TimeoutError, ServerTimeoutError) as e: raise NianticTimeoutException('RPC request timed out.') from e except ClientError as e: - raise NianticOfflineException('{} during RPC. {}'.format(e.__class__.__name__, e)) from e + raise NianticOfflineException( + '{} during RPC. {}'.format( + e.__class__.__name__, e)) from e @staticmethod def get_request_name(subrequests): try: first = subrequests[0] - return to_camel_case(RequestType.Name(first[0] if isinstance(first, tuple) else first)) + return to_camel_case(RequestType.Name( + first[0] if isinstance(first, tuple) else first)) except IndexError: return 'empty' except (ValueError, TypeError): @@ -88,11 +99,13 @@ async def _build_main_request(self, subrequests, player_position, device_info=No request = self._build_sub_requests(request, subrequests) if self._auth_provider.check_ticket(): - self.log.debug('Found Session Ticket - using this instead of oauth token') + self.log.debug( + 'Found Session Ticket - using this instead of oauth token') request.auth_ticket.expire_timestamp_ms, request.auth_ticket.start, request.auth_ticket.end = self._auth_provider.get_ticket() ticket_serialized = request.auth_ticket.SerializeToString() else: - self.log.debug('No Session Ticket found - using OAUTH Access Token') + self.log.debug( + 'No Session Ticket found - using OAUTH Access Token') request.auth_info.provider = self._auth_provider.provider request.auth_info.token.contents = await self._auth_provider.get_access_token() @@ -100,7 +113,8 @@ async def _build_main_request(self, subrequests, player_position, device_info=No request.auth_info.token.unknown2 = choose_weighted( (4, 19, 22, 26, 30, 44, 45, 50, 57, 58, 59), (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20)) - ticket_serialized = request.auth_info.SerializeToString() # Sig uses this when no auth_ticket available + # Sig uses this when no auth_ticket available + ticket_serialized = request.auth_info.SerializeToString() sig = SignalLog() @@ -111,7 +125,15 @@ async def _build_main_request(self, subrequests, player_position, device_info=No sig.timestamp_ms_since_start = sig.epoch_timestamp_ms - self.state.start_time hash_engine = HashServer() - hashing = HashServer.loop.create_task(hash_engine.hash(sig.epoch_timestamp_ms, request.latitude, request.longitude, request.accuracy, ticket_serialized, sig.field22, request.requests)) + hashing = HashServer.loop.create_task( + hash_engine.hash( + sig.epoch_timestamp_ms, + request.latitude, + request.longitude, + request.accuracy, + ticket_serialized, + sig.field22, + request.requests)) loc = sig.location_updates.add() sen = sig.sensor_updates.add() @@ -136,7 +158,8 @@ async def _build_main_request(self, subrequests, player_position, device_info=No loc.provider_status = 3 loc.location_type = 1 if isinstance(request.accuracy, float): - loc.horizontal_accuracy = choose_weighted((request.accuracy, 65, 200), (50, 90, 100)) + loc.horizontal_accuracy = choose_weighted( + (request.accuracy, 65, 200), (50, 90, 100)) loc.vertical_accuracy = choose_weighted( (-1, 10, 12, 16, 24, 32, 48, 96), (50, 84, 89, 92, 96, 98, 99, 100)) @@ -211,7 +234,8 @@ async def _build_main_request(self, subrequests, player_position, device_info=No sig.location_hash, sig.location_hash_by_token_seed, rh = await hashing sig.request_hashes.extend(rh) sig_request = SendEncryptedSignatureRequest() - sig_request.encrypted_signature = pycrypt(sig.SerializeToString(), sig.timestamp_ms_since_start) + sig_request.encrypted_signature = pycrypt( + sig.SerializeToString(), sig.timestamp_ms_since_start) plat = request.platform_requests.add() plat.type = 6 @@ -237,18 +261,24 @@ def _build_sub_requests(self, mainrequest, subrequest_list): try: class_ = globals()[proto_name] except KeyError: - globals()[proto_name] = class_ = getattr(import_module('pogoprotos.networking.requests.messages.' + proto_name + '_pb2'), to_camel_case(proto_name)) + globals()[proto_name] = class_ = getattr( + import_module( + 'pogoprotos.networking.requests.messages.' + + proto_name + + '_pb2'), + to_camel_case(proto_name)) message = class_() for key, value in entry_content.items(): if isinstance(value, (list, tuple, array)): - self.log.debug("Found sequence: %s - trying as repeated", key) + self.log.debug( + "Found sequence: %s - trying as repeated", key) try: r = getattr(message, key) r.extend(value) except (AttributeError, ValueError) as e: - self.log.warning('Argument %s with value %s unknown inside %s (Exception: %s)', key, i, proto_name, e) + self.log.warning('Unknown argument %s inside %s (Exception: %s)', key, proto_name, e) elif isinstance(value, dict): r = getattr(message, key) for k, v in value.items(): @@ -280,9 +310,12 @@ def _parse_response(self, response_raw, subrequests): try: response_proto.ParseFromString(response_raw) except DecodeError as e: - raise MalformedNianticResponseException('Could not parse response.') from e + raise MalformedNianticResponseException( + 'Could not parse response.') from e - self.log.debug('Protobuf structure of rpc response:\n\r%s', response_proto) + self.log.debug( + 'Protobuf structure of rpc response:\n\r%s', + response_proto) if response_proto.HasField('auth_ticket'): self._auth_provider.set_ticket(response_proto.auth_ticket) @@ -310,7 +343,8 @@ def _parse_response(self, response_raw, subrequests): try: err = StatusCode(status_code).name except ValueError: - raise UnexpectedResponseException("Unknown status_code: {}".format(status_code)) + raise UnexpectedResponseException( + "Unknown status_code: {}".format(status_code)) req_type = self.get_request_name(subrequests) raise InvalidRPCException("{} on {}.".format(err, req_type)) @@ -321,13 +355,20 @@ def _parse_sub_responses(self, subrequests_list, response_proto): for i, subresponse in enumerate(response_proto.returns): request_entry = subrequests_list[i] - entry_name = RequestType.Name(request_entry if isinstance(request_entry, int) else request_entry[0]) + entry_name = RequestType.Name( + request_entry if isinstance( + request_entry, int) else request_entry[0]) proto_name = entry_name.lower() + '_response' try: class_ = globals()[proto_name] except KeyError: - globals()[proto_name] = class_ = getattr(import_module('pogoprotos.networking.responses.' + proto_name + '_pb2'), to_camel_case(proto_name)) + globals()[proto_name] = class_ = getattr( + import_module( + 'pogoprotos.networking.responses.' + + proto_name + + '_pb2'), + to_camel_case(proto_name)) message = class_() message.ParseFromString(subresponse) diff --git a/aiopogo/session.py b/aiopogo/session.py index 012ee2bd..8f1d968b 100644 --- a/aiopogo/session.py +++ b/aiopogo/session.py @@ -1,17 +1,23 @@ -from aiohttp import ClientSession, ClientRequest, TCPConnector from asyncio import get_event_loop +from aiohttp import ClientSession, ClientRequest, TCPConnector + try: from aiosocks.connector import ProxyClientRequest, ProxyConnector except ImportError: class ProxyConnector: - def __init__(s, *args, **kwargs): + def __init__(self, *args, **kwargs): raise ImportError('Install aiosocks to use socks proxies.') ProxyClientRequest = ProxyConnector class SessionManager: - __slots__ = ('loop', 'session', 'connector', 'socks_session', 'socks_connector') + __slots__ = ( + 'loop', + 'session', + 'connector', + 'socks_session', + 'socks_connector') def __init__(self): self.loop = get_event_loop() @@ -46,11 +52,11 @@ def get_connector(self, socks, limit=400): verify_ssl=False, remote_resolve=False) return self.socks_connector - else: - self.connector = TCPConnector(limit=limit, - loop=self.loop, - verify_ssl=False) - return self.connector + + self.connector = TCPConnector(limit=limit, + loop=self.loop, + verify_ssl=False) + return self.connector def close(self): try: @@ -62,4 +68,5 @@ def close(self): except AttributeError: pass + SESSIONS = SessionManager() diff --git a/aiopogo/utilities.py b/aiopogo/utilities.py index 2b599aa4..ed8bb373 100755 --- a/aiopogo/utilities.py +++ b/aiopogo/utilities.py @@ -3,8 +3,8 @@ from struct import pack, unpack -def f2i(f): - return unpack('