From 877c5e476943c4b235c671d71266ae7b78eadf1e Mon Sep 17 00:00:00 2001 From: FriendsOfGalaxy Date: Tue, 26 Nov 2019 02:30:32 -0800 Subject: [PATCH] version 0.32 --- src/backend.py | 24 ++++++++++++------------ src/plugin.py | 17 +++++++++-------- src/version.py | 2 +- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/backend.py b/src/backend.py index 584f7a6..dd6f813 100755 --- a/src/backend.py +++ b/src/backend.py @@ -108,8 +108,8 @@ async def _get_access_token(self): data = await response.json(content_type=None) self._access_token = data["access_token"] except (ValueError, KeyError) as e: - logging.exception("Can not parse access token from backend response") - raise UnknownBackendResponse(str(e)) + logging.exception("Can not parse access token from backend response %s", repr(e)) + raise UnknownBackendResponse() class OriginBackendClient: @@ -139,8 +139,8 @@ async def get_identity(self): return str(user_id), str(persona_id), str(user_name) except (ET.ParseError, AttributeError) as e: - logging.exception("Can not parse backend response: %s", content) - raise UnknownBackendResponse(str(e)) + logging.exception("Can not parse backend response: %s, error %s", content, repr(e)) + raise UnknownBackendResponse() async def get_entitlements(self, user_id): url = "{}/ecommerce2/consolidatedentitlements/{}?machine_hash=1".format( @@ -155,8 +155,8 @@ async def get_entitlements(self, user_id): data = await response.json() return data["entitlements"] except (ValueError, KeyError) as e: - logging.exception("Can not parse backend response: %s", await response.text()) - raise UnknownBackendResponse(str(e)) + logging.exception("Can not parse backend response: %s, error %s", await response.text(), repr(e)) + raise UnknownBackendResponse() async def get_offer(self, offer_id): url = "{}/ecommerce2/public/supercat/{}/{}".format( @@ -168,8 +168,8 @@ async def get_offer(self, offer_id): try: return await response.json() except ValueError as e: - logging.exception("Can not parse backend response: %s", await response.text()) - raise UnknownBackendResponse(str(e)) + logging.exception("Can not parse backend response: %s, error %s", await response.text, repr(e)) + raise UnknownBackendResponse() async def get_achievements(self, persona_id: str, achievement_set: str = None) \ -> Dict[AchievementSet, List[Achievement]]: @@ -214,8 +214,8 @@ def parser(json_data: Dict) -> List[Achievement]: } except (ValueError, KeyError) as e: - logging.exception("Can not parse achievements from backend response") - raise UnknownBackendResponse(str(e)) + logging.exception("Can not parse achievements from backend response %s", repr(e)) + raise UnknownBackendResponse() async def get_game_time(self, user_id, master_title_id, multiplayer_id): url = "{}/atom/users/{}/games/{}/usage".format( @@ -254,8 +254,8 @@ def parse_last_played_time(lastplayed_timestamp) -> Optional[int]: return total_play_time, parse_last_played_time(xml_response.find("lastSessionEndTimeStamp")) except (ET.ParseError, AttributeError, ValueError) as e: - logging.exception("Can not parse backend response: %s", await response.text()) - raise UnknownBackendResponse(str(e)) + logging.exception("Can not parse backend response: %s, %s", await response.text(), repr(e)) + raise UnknownBackendResponse() async def get_friends(self, user_id): response = await self._http_client.get( diff --git a/src/plugin.py b/src/plugin.py index ddda294..d7054ee 100755 --- a/src/plugin.py +++ b/src/plugin.py @@ -88,7 +88,7 @@ def tick(self): def _check_authenticated(self): if not self._http_client.is_authenticated(): logging.exception("Plugin not authenticated") - raise AuthenticationRequired("Plugin not authenticated") + raise AuthenticationRequired() async def _do_authenticate(self, cookies): try: @@ -98,8 +98,8 @@ async def _do_authenticate(self, cookies): return Authentication(self._user_id, user_name) except (AccessDenied, InvalidCredentials) as e: - logging.exception("Failed to authenticate") - raise InvalidCredentials(str(e)) + logging.exception("Failed to authenticate %s", repr(e)) + raise InvalidCredentials() async def authenticate(self, stored_credentials=None): stored_cookies = stored_credentials.get("cookies") if stored_credentials else None @@ -144,7 +144,7 @@ async def get_unlocked_achievements(self, game_id: str, context: AchievementsImp achievements_set = context.owned_games[game_id].achievement_set except (KeyError, AttributeError): logging.exception("Game '{}' not found amongst owned".format(game_id)) - raise UnknownBackendResponse + raise UnknownBackendResponse() if not achievements_set: return [] @@ -161,7 +161,7 @@ async def get_unlocked_achievements(self, game_id: str, context: AchievementsImp except KeyError: logging.exception("Failed to parse achievements for game {}".format(game_id)) - raise UnknownBackendResponse + raise UnknownBackendResponse() async def _get_offers(self, offer_ids): """ @@ -295,7 +295,8 @@ async def get_game_time(self, game_id: OfferId, last_played_games: Any) -> GameT try: offer = self._offer_id_cache.get(game_id) if offer is None: - raise UnknownError("Internal cache out of sync") + logging.exception("Internal cache out of sync") + raise UnknownError() master_title_id: MasterTitleId = offer["masterTitleId"] multiplayer_id: Optional[MultiplayerId] = self._get_multiplayer_id(offer) @@ -308,8 +309,8 @@ async def get_game_time(self, game_id: OfferId, last_played_games: Any) -> GameT ) except KeyError as e: - logging.exception("Failed to import game times") - raise UnknownBackendResponse(str(e)) + logging.exception("Failed to import game times %s", repr(e)) + raise UnknownBackendResponse() async def prepare_game_library_settings_context(self, game_ids: List[str]) -> Any: self._check_authenticated() diff --git a/src/version.py b/src/version.py index 98195c0..caf4bc3 100755 --- a/src/version.py +++ b/src/version.py @@ -1 +1 @@ -__version__ = "0.31" +__version__ = "0.32" \ No newline at end of file