From 671a8b3c1f597d522e6b5dd34bd1891af9717680 Mon Sep 17 00:00:00 2001 From: koraynilay Date: Fri, 5 Feb 2021 18:24:17 +0100 Subject: [PATCH] 2021-02-05_18-24-17 --- legendary/downloader/log_dlm.py | 30 +++++++++++++++-------------- legendary/gui/gui.py | 34 ++++++++++++++++++++++++++++++--- legendary/gui/manager2.py | 1 + 3 files changed, 48 insertions(+), 17 deletions(-) diff --git a/legendary/downloader/log_dlm.py b/legendary/downloader/log_dlm.py index e17e7d2..98a34d9 100644 --- a/legendary/downloader/log_dlm.py +++ b/legendary/downloader/log_dlm.py @@ -10,9 +10,9 @@ class log_dlm: else: print("bar",main_window.get_title(),main_window) #self.update_gui_setup(dlm=dlm, bar=main_window.progress_bar) - #self.update_gui_setup(dlm, main_window.progress_bar) + self.update_gui_setup(dlm, main_window.progress_bar) print(main_window.progress_bar) - return main_window.username_label + return main_window.progress_bar def update(self, dlm): #perc, processed_chunks, num_chunk_tasks, rt_hours, rt_minutes, rt_seconds, hours, minutes, seconds, total_dl, total_write, total_used, dl_speed, dl_unc_speed, w_speed, r_speed, obj_out): @@ -74,11 +74,11 @@ class log_dlm: # total_dl, total_write, total_used, # dl_speed, dl_unc_speed, w_speed, r_speed, print(f"update_gui_{bar}") - #bar.set_fraction(dlm.perc) + bar.set_fraction(dlm.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_tooltip_text("tooltip") # show all infos that are also in update_cli() print(bar.get_text()) - #return True # since this is a timeout function + return True # since this is a timeout function def update_cli(self, dlm): #perc, @@ -90,16 +90,18 @@ class log_dlm: #): perc = dlm.perc * 100 print(f"perc: {perc}%") - dlm.log.info(f'= Progress: {perc:.02f}% ({dlm.processed_chunks}/{dlm.num_chunk_tasks}), ' - f'Running for {dlm.rt_hours:02d}:{dlm.rt_minutes:02d}:{dlm.rt_seconds:02d}, ' - f'ETA: {dlm.hours:02d}:{dlm.minutes:02d}:{dlm.seconds:02d}') - dlm.log.info(f' - Downloaded: {dlm.total_dl / 1024 / 1024:.02f} MiB, ' - f'Written: {dlm.total_write / 1024 / 1024:.02f} MiB') - dlm.log.info(f' - Cache usage: {dlm.total_used} MiB, active tasks: {dlm.active_tasks}') - dlm.log.info(f' + Download\t- {dlm.dl_speed / 1024 / 1024:.02f} MiB/s (raw) ' - f'/ {dlm.dl_unc_speed / 1024 / 1024:.02f} MiB/s (decompressed)') - dlm.log.info(f' + Disk\t- {dlm.w_speed / 1024 / 1024:.02f} MiB/s (write) / ' - f'{dlm.r_speed / 1024 / 1024:.02f} MiB/s (read)') + print(f"{dlm}") + print(f"hexid:{hex(id(dlm.perc))}") + #dlm.log.info(f'= Progress: {perc:.02f}% ({dlm.processed_chunks}/{dlm.num_chunk_tasks}), ' + # f'Running for {dlm.rt_hours:02d}:{dlm.rt_minutes:02d}:{dlm.rt_seconds:02d}, ' + # f'ETA: {dlm.hours:02d}:{dlm.minutes:02d}:{dlm.seconds:02d}') + #dlm.log.info(f' - Downloaded: {dlm.total_dl / 1024 / 1024:.02f} MiB, ' + # f'Written: {dlm.total_write / 1024 / 1024:.02f} MiB') + #dlm.log.info(f' - Cache usage: {dlm.total_used} MiB, active tasks: {dlm.active_tasks}') + #dlm.log.info(f' + Download\t- {dlm.dl_speed / 1024 / 1024:.02f} MiB/s (raw) ' + # f'/ {dlm.dl_unc_speed / 1024 / 1024:.02f} MiB/s (decompressed)') + #dlm.log.info(f' + Disk\t- {dlm.w_speed / 1024 / 1024:.02f} MiB/s (write) / ' + # f'{dlm.r_speed / 1024 / 1024:.02f} MiB/s (read)') diff --git a/legendary/gui/gui.py b/legendary/gui/gui.py index 36e4cbb..972ab5f 100755 --- a/legendary/gui/gui.py +++ b/legendary/gui/gui.py @@ -12,13 +12,29 @@ from multiprocessing import freeze_support, Queue as MPQueue import gi gi.require_version('Gtk', '3.0') -from gi.repository import Gtk +from gi.repository import Gtk, GLib import legendary.core import legendary.cli core = legendary.core.LegendaryCore() cli = legendary.cli.LegendaryCLI() +def update_gui(dlm, bar): + # perc, + # processed_chunks, num_chunk_tasks, + # rt_hours, rt_minutes, rt_seconds, + # hours, minutes, seconds, + # total_dl, total_write, total_used, + # dl_speed, dl_unc_speed, w_speed, r_speed, + print(f"update_gui_{bar}") + print(f"{dlm}") + print(f"dhexid:{hex(id(dlm.perc))}") + bar.set_fraction(dlm.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_tooltip_text("tooltip") # show all infos that are also in update_cli() + print(bar.get_text()) + return True # since this is a timeout function + class args_obj: base_path = '' game_folder = '' @@ -582,7 +598,7 @@ def install_gtk(app_name, app_title, parent): # TODO: if install_dialog_response != Gtk.ResponseType.OK: return 1 - install_dialog.destroy() + install_dialog.hide() if core.is_installed(app_name): igame = core.get_installed_game(app_name) @@ -738,6 +754,10 @@ def install_gtk(app_name, app_title, parent): 'CTRL-C and resume it using the same command later on.') start_t = time.time() +# GLib.idle_add(dlm_start, args, dlm, start_t) +# +#def dlm_start(args, dlm, start_t): + try: # set up logging stuff (should be moved somewhere else later) @@ -745,8 +765,16 @@ def install_gtk(app_name, app_title, parent): dlm.proc_debug = args.dlm_debug #print("parent:",parent) + dlm.perc = 0 + dlm.dl_speed = 0 + dlm.hours = 0 + 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}") + parent.timeout_id = GLib.timeout_add(1000, update_gui, dlm, parent.progress_bar) + print("timeout_add -",parent.timeout_id) dlm.start() - 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 abff2f5..978452d 100644 --- a/legendary/gui/manager2.py +++ b/legendary/gui/manager2.py @@ -717,6 +717,7 @@ class DLManager(Process): #debug print("loop") print("almost updated obj_out") + self.obj_out = "cli" #if self.obj_out == "cli": log_dlm.update(self) #self.perc,