From 133e2c71682f81eb05c891f0b67cee141ab2caec Mon Sep 17 00:00:00 2001 From: koraynilay Date: Wed, 24 Feb 2021 12:48:51 +0100 Subject: [PATCH] 2021-02-24_12-48-51 --- legendary/downloader/log_dlm.py | 1 + legendary/gui/gui.py | 22 +++++++++++----------- legendary/gui/manager2.py | 8 ++++++++ 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/legendary/downloader/log_dlm.py b/legendary/downloader/log_dlm.py index 4b6920f..2050b4b 100644 --- a/legendary/downloader/log_dlm.py +++ b/legendary/downloader/log_dlm.py @@ -38,6 +38,7 @@ class log_dlm: #r_speed) else: print("update_gui") + print(f"{dlm.dl_speed / 1024 / 1024:.02f} MiB/s - {(dlm.perc*100):.02f}% - ETA: {dlm.hours:02d}:{dlm.minutes:02d}:{dlm.seconds:02d} - log_dlm") #self.update_gui(dlm, dlm.obj_out) #self.update_gui( # dlm, diff --git a/legendary/gui/gui.py b/legendary/gui/gui.py index 4f5a0e9..caa732e 100755 --- a/legendary/gui/gui.py +++ b/legendary/gui/gui.py @@ -19,7 +19,7 @@ import legendary.cli core = legendary.core.LegendaryCore() cli = legendary.cli.LegendaryCLI() -def update_gui(dlm, bar, perc): +def update_gui(parent, bar): # perc, # processed_chunks, num_chunk_tasks, # rt_hours, rt_minutes, rt_seconds, @@ -29,9 +29,9 @@ def update_gui(dlm, bar, perc): print(f"update_gui_{bar}") #print(f"{dlm}") #print(f"dhexid:{hex(id(dlm.perc))}") - #bar.set_fraction(dlm.perc) - bar.set_fraction(perc) - #bar.set_text(f"{dlm.dl_speed / 1024 / 1024:.02f} MiB/s - {(dlm.perc*100):.02f}% - ETA: {dlm.hours:02d}:{dlm.minutes:02d}:{dlm.seconds:02d}") + bar.set_fraction(parent.dlm.perc) + #bar.set_fraction(perc) + bar.set_text(f"{parent.dlm.dl_speed / 1024 / 1024:.02f} MiB/s - {(parent.dlm.perc*100):.02f}% - ETA: {parent.dlm.hours:02d}:{parent.dlm.minutes:02d}:{parent.dlm.seconds:02d}") bar.set_tooltip_text("tooltip") # show all infos that are also in update_cli() print(bar.get_text()) return True # since this is a timeout function @@ -681,7 +681,7 @@ def install_gtk(app_name, app_title, parent): print('Preparing download...') # todo use status queue to print progress from CLI # This has become a little ridiculous hasn't it? - dlm, analysis, igame = core.prepare_download(game=game, base_game=base_game, base_path=args.base_path, + parent.dlm, analysis, igame = core.prepare_download(game=game, base_game=base_game, base_path=args.base_path, force=args.force, max_shm=args.shared_memory, max_workers=args.max_workers, game_folder=args.game_folder, disable_patching=args.disable_patching, @@ -762,8 +762,8 @@ def install_gtk(app_name, app_title, parent): try: # set up logging stuff (should be moved somewhere else later) - dlm.logging_queue = cli.logging_queue - dlm.proc_debug = args.dlm_debug + parent.dlm.logging_queue = cli.logging_queue + parent.dlm.proc_debug = args.dlm_debug #print("parent:",parent) # dlm.perc = 0 @@ -772,12 +772,12 @@ def install_gtk(app_name, app_title, parent): # dlm.minutes = 0 # dlm.seconds = 0 #bar.set_text(f"{dlm.dl_speed / 1024 / 1024:.02f} MiB/s - {(dlm.perc*100):.02f}% - ETA: {dlm.hours:02d}:{dlm.minutes:02d}:{dlm.seconds:02d}") - dlm.start() + parent.dlm.start() #time.sleep(4) - perch = 0 - parent.timeout_id = GLib.timeout_add(1000, update_gui, dlm, parent.progress_bar, perch) + #perch = 0 + parent.timeout_id = GLib.timeout_add(500, update_gui, parent, parent.progress_bar) print("timeout_add -",parent.timeout_id) - dlm.join() + #dlm.join() except Exception as e: end_t = time.time() #log_gtk(f'Installation failed after {end_t - start_t:.02f} seconds.' diff --git a/legendary/gui/manager2.py b/legendary/gui/manager2.py index 5ac3d67..395b15e 100644 --- a/legendary/gui/manager2.py +++ b/legendary/gui/manager2.py @@ -34,6 +34,14 @@ class DLManager(Process): self.log = logging.getLogger('DLM') self.proc_debug = False + # ### + # self.perc = 1 + # self.dl_speed = 1 + # self.hours = 1 + # self.minutes = 1 + # self.seconds = 1 + # ### + self.base_url = base_url self.dl_dir = download_dir self.cache_dir = cache_dir if cache_dir else os.path.join(download_dir, '.cache')