Skip to content

Commit

Permalink
version 0.32
Browse files Browse the repository at this point in the history
  • Loading branch information
FriendsOfGalaxy committed Nov 26, 2019
1 parent 3a7f508 commit 877c5e4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
24 changes: 12 additions & 12 deletions src/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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]]:
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
17 changes: 9 additions & 8 deletions src/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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 []
Expand All @@ -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):
"""
Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.31"
__version__ = "0.32"

0 comments on commit 877c5e4

Please sign in to comment.