🎨 Improved structure / added debug info
This commit is contained in:
@@ -123,6 +123,8 @@ class Importer:
|
||||
if pipeline is not None:
|
||||
logging.info("Imported %s (%s)", game.name, game.game_id)
|
||||
pipeline.connect("manager-done", self.manager_done_callback)
|
||||
pipeline.connect("manager-started", self.manager_started_callback)
|
||||
self.game_pipelines.add(pipeline)
|
||||
|
||||
def update_progressbar(self):
|
||||
"""Update the progressbar to show the percentage of game pipelines done"""
|
||||
@@ -134,8 +136,17 @@ class Importer:
|
||||
logging.debug("Import done for source %s", source.id)
|
||||
self.n_source_tasks_done += 1
|
||||
|
||||
def manager_started_callback(self, pipeline: Pipeline, manager: Manager):
|
||||
"""Callback called when a game manager has started"""
|
||||
logging.debug(
|
||||
"Manager %s for %s started", manager.__class__.__name__, pipeline.game.name
|
||||
)
|
||||
|
||||
def manager_done_callback(self, pipeline: Pipeline, manager: Manager):
|
||||
"""Callback called when a pipeline for a game has advanced"""
|
||||
logging.debug(
|
||||
"Manager %s for %s done", manager.__class__.__name__, pipeline.game.name
|
||||
)
|
||||
if pipeline.is_done:
|
||||
self.n_pipelines_done += 1
|
||||
self.update_progressbar()
|
||||
|
||||
14
src/main.py
14
src/main.py
@@ -84,12 +84,7 @@ class CartridgesApplication(Adw.Application):
|
||||
shared.store = Store()
|
||||
shared.store.add_manager(DisplayManager())
|
||||
|
||||
# Load games from disk
|
||||
if shared.games_dir.exists():
|
||||
for game_file in shared.games_dir.iterdir():
|
||||
data = json.load(game_file.open())
|
||||
game = Game(data, allow_side_effects=False)
|
||||
shared.store.add_game(game)
|
||||
self.load_games_from_disk()
|
||||
|
||||
# Add rest of the managers for game imports
|
||||
shared.store.add_manager(SteamAPIManager())
|
||||
@@ -135,6 +130,13 @@ class CartridgesApplication(Adw.Application):
|
||||
|
||||
self.win.present()
|
||||
|
||||
def load_games_from_disk(self):
|
||||
if shared.games_dir.exists():
|
||||
for game_file in shared.games_dir.iterdir():
|
||||
data = json.load(game_file.open())
|
||||
game = Game(data, allow_side_effects=False)
|
||||
shared.store.add_game(game)
|
||||
|
||||
def on_about_action(self, *_args):
|
||||
about = Adw.AboutWindow(
|
||||
transient_for=self.win,
|
||||
|
||||
Reference in New Issue
Block a user