mirror of
https://github.com/gogcom/galaxy-integrations-python-api.git
synced 2026-01-02 03:48:16 -05:00
Compare commits
2 Commits
deployed_0
...
0.31
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f2d4127a31 | ||
|
|
07b6edce12 |
2
setup.py
2
setup.py
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="galaxy.plugin.api",
|
name="galaxy.plugin.api",
|
||||||
version="0.30",
|
version="0.31",
|
||||||
description="Galaxy python plugin API",
|
description="Galaxy python plugin API",
|
||||||
author='Galaxy team',
|
author='Galaxy team',
|
||||||
author_email='galaxy@gog.com',
|
author_email='galaxy@gog.com',
|
||||||
|
|||||||
@@ -339,24 +339,28 @@ class Plugin():
|
|||||||
if self._achievements_import_in_progress:
|
if self._achievements_import_in_progress:
|
||||||
raise ImportInProgress()
|
raise ImportInProgress()
|
||||||
|
|
||||||
async def import_games_achievements(game_ids):
|
async def import_games_achievements_task(game_ids):
|
||||||
async def import_game_achievements(game_id):
|
|
||||||
try:
|
|
||||||
achievements = await self.get_unlocked_achievements(game_id)
|
|
||||||
self.game_achievements_import_success(game_id, achievements)
|
|
||||||
except Exception as error:
|
|
||||||
self.game_achievements_import_failure(game_id, error)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
imports = [import_game_achievements(game_id) for game_id in game_ids]
|
await self.import_games_achievements(game_ids)
|
||||||
await asyncio.gather(*imports)
|
|
||||||
finally:
|
finally:
|
||||||
self.achievements_import_finished()
|
self.achievements_import_finished()
|
||||||
self._achievements_import_in_progress = False
|
self._achievements_import_in_progress = False
|
||||||
|
|
||||||
asyncio.create_task(import_games_achievements(game_ids))
|
asyncio.create_task(import_games_achievements_task(game_ids))
|
||||||
self._achievements_import_in_progress = True
|
self._achievements_import_in_progress = True
|
||||||
|
|
||||||
|
async def import_games_achievements(self, game_ids):
|
||||||
|
"""Call game_achievements_import_success/game_achievements_import_failure for each game_id on the list"""
|
||||||
|
async def import_game_achievements(game_id):
|
||||||
|
try:
|
||||||
|
achievements = await self.get_unlocked_achievements(game_id)
|
||||||
|
self.game_achievements_import_success(game_id, achievements)
|
||||||
|
except Exception as error:
|
||||||
|
self.game_achievements_import_failure(game_id, error)
|
||||||
|
|
||||||
|
imports = [import_game_achievements(game_id) for game_id in game_ids]
|
||||||
|
await asyncio.gather(*imports)
|
||||||
|
|
||||||
async def get_local_games(self):
|
async def get_local_games(self):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
@@ -397,28 +401,32 @@ class Plugin():
|
|||||||
if self._game_times_import_in_progress:
|
if self._game_times_import_in_progress:
|
||||||
raise ImportInProgress()
|
raise ImportInProgress()
|
||||||
|
|
||||||
async def import_game_times(game_ids):
|
async def import_game_times_task(game_ids):
|
||||||
try:
|
try:
|
||||||
game_times = await self.get_game_times()
|
await self.import_game_times(game_ids)
|
||||||
game_ids_set = set(game_ids)
|
|
||||||
for game_time in game_times:
|
|
||||||
if game_time.game_id not in game_ids_set:
|
|
||||||
continue
|
|
||||||
self.game_time_import_success(game_time)
|
|
||||||
game_ids_set.discard(game_time.game_id)
|
|
||||||
for game_id in game_ids_set:
|
|
||||||
self.game_time_import_failure(game_id, UnknownError())
|
|
||||||
|
|
||||||
except Exception as error:
|
|
||||||
for game_id in game_ids:
|
|
||||||
self.game_time_import_failure(game_id, error)
|
|
||||||
finally:
|
finally:
|
||||||
self.game_times_import_finished()
|
self.game_times_import_finished()
|
||||||
self._game_times_import_in_progress = False
|
self._game_times_import_in_progress = False
|
||||||
|
|
||||||
asyncio.create_task(import_game_times(game_ids))
|
asyncio.create_task(import_game_times_task(game_ids))
|
||||||
self._game_times_import_in_progress = True
|
self._game_times_import_in_progress = True
|
||||||
|
|
||||||
|
async def import_game_times(self, game_ids):
|
||||||
|
"""Call game_time_import_success/game_time_import_failure for each game_id on the list"""
|
||||||
|
try:
|
||||||
|
game_times = await self.get_game_times()
|
||||||
|
game_ids_set = set(game_ids)
|
||||||
|
for game_time in game_times:
|
||||||
|
if game_time.game_id not in game_ids_set:
|
||||||
|
continue
|
||||||
|
self.game_time_import_success(game_time)
|
||||||
|
game_ids_set.discard(game_time.game_id)
|
||||||
|
for game_id in game_ids_set:
|
||||||
|
self.game_time_import_failure(game_id, UnknownError())
|
||||||
|
except Exception as error:
|
||||||
|
for game_id in game_ids:
|
||||||
|
self.game_time_import_failure(game_id, error)
|
||||||
|
|
||||||
def create_and_run_plugin(plugin_class, argv):
|
def create_and_run_plugin(plugin_class, argv):
|
||||||
if len(argv) < 3:
|
if len(argv) < 3:
|
||||||
logging.critical("Not enough parameters, required: token, port")
|
logging.critical("Not enough parameters, required: token, port")
|
||||||
|
|||||||
Reference in New Issue
Block a user