2021-02-05_18-24-17

This commit is contained in:
koraynilay 2021-02-05 18:24:17 +01:00
parent 5986a2a792
commit 671a8b3c1f
3 changed files with 48 additions and 17 deletions

View file

@ -10,9 +10,9 @@ class log_dlm:
else: else:
print("bar",main_window.get_title(),main_window) print("bar",main_window.get_title(),main_window)
#self.update_gui_setup(dlm=dlm, bar=main_window.progress_bar) #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) print(main_window.progress_bar)
return main_window.username_label return main_window.progress_bar
def update(self, dlm): 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): #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, # total_dl, total_write, total_used,
# dl_speed, dl_unc_speed, w_speed, r_speed, # dl_speed, dl_unc_speed, w_speed, r_speed,
print(f"update_gui_{bar}") 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_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() bar.set_tooltip_text("tooltip") # show all infos that are also in update_cli()
print(bar.get_text()) 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): def update_cli(self, dlm):
#perc, #perc,
@ -90,16 +90,18 @@ class log_dlm:
#): #):
perc = dlm.perc * 100 perc = dlm.perc * 100
print(f"perc: {perc}%") print(f"perc: {perc}%")
dlm.log.info(f'= Progress: {perc:.02f}% ({dlm.processed_chunks}/{dlm.num_chunk_tasks}), ' print(f"{dlm}")
f'Running for {dlm.rt_hours:02d}:{dlm.rt_minutes:02d}:{dlm.rt_seconds:02d}, ' print(f"hexid:{hex(id(dlm.perc))}")
f'ETA: {dlm.hours:02d}:{dlm.minutes:02d}:{dlm.seconds:02d}') #dlm.log.info(f'= Progress: {perc:.02f}% ({dlm.processed_chunks}/{dlm.num_chunk_tasks}), '
dlm.log.info(f' - Downloaded: {dlm.total_dl / 1024 / 1024:.02f} MiB, ' # f'Running for {dlm.rt_hours:02d}:{dlm.rt_minutes:02d}:{dlm.rt_seconds:02d}, '
f'Written: {dlm.total_write / 1024 / 1024:.02f} MiB') # f'ETA: {dlm.hours:02d}:{dlm.minutes:02d}:{dlm.seconds:02d}')
dlm.log.info(f' - Cache usage: {dlm.total_used} MiB, active tasks: {dlm.active_tasks}') #dlm.log.info(f' - Downloaded: {dlm.total_dl / 1024 / 1024:.02f} MiB, '
dlm.log.info(f' + Download\t- {dlm.dl_speed / 1024 / 1024:.02f} MiB/s (raw) ' # f'Written: {dlm.total_write / 1024 / 1024:.02f} MiB')
f'/ {dlm.dl_unc_speed / 1024 / 1024:.02f} MiB/s (decompressed)') #dlm.log.info(f' - Cache usage: {dlm.total_used} MiB, active tasks: {dlm.active_tasks}')
dlm.log.info(f' + Disk\t- {dlm.w_speed / 1024 / 1024:.02f} MiB/s (write) / ' #dlm.log.info(f' + Download\t- {dlm.dl_speed / 1024 / 1024:.02f} MiB/s (raw) '
f'{dlm.r_speed / 1024 / 1024:.02f} MiB/s (read)') # 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)')

View file

@ -12,13 +12,29 @@ from multiprocessing import freeze_support, Queue as MPQueue
import gi import gi
gi.require_version('Gtk', '3.0') gi.require_version('Gtk', '3.0')
from gi.repository import Gtk from gi.repository import Gtk, GLib
import legendary.core import legendary.core
import legendary.cli import legendary.cli
core = legendary.core.LegendaryCore() core = legendary.core.LegendaryCore()
cli = legendary.cli.LegendaryCLI() 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: class args_obj:
base_path = '' base_path = ''
game_folder = '' game_folder = ''
@ -582,7 +598,7 @@ def install_gtk(app_name, app_title, parent):
# TODO: # TODO:
if install_dialog_response != Gtk.ResponseType.OK: if install_dialog_response != Gtk.ResponseType.OK:
return 1 return 1
install_dialog.destroy() install_dialog.hide()
if core.is_installed(app_name): if core.is_installed(app_name):
igame = core.get_installed_game(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.') 'CTRL-C and resume it using the same command later on.')
start_t = time.time() start_t = time.time()
# GLib.idle_add(dlm_start, args, dlm, start_t)
#
#def dlm_start(args, dlm, start_t):
try: try:
# set up logging stuff (should be moved somewhere else later) # 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 dlm.proc_debug = args.dlm_debug
#print("parent:",parent) #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.start()
dlm.join() #dlm.join()
except Exception as e: except Exception as e:
end_t = time.time() end_t = time.time()
#log_gtk(f'Installation failed after {end_t - start_t:.02f} seconds.' #log_gtk(f'Installation failed after {end_t - start_t:.02f} seconds.'

View file

@ -717,6 +717,7 @@ class DLManager(Process):
#debug print("loop") #debug print("loop")
print("almost updated obj_out") print("almost updated obj_out")
self.obj_out = "cli"
#if self.obj_out == "cli": #if self.obj_out == "cli":
log_dlm.update(self) log_dlm.update(self)
#self.perc, #self.perc,