2021-02-05_17-25-43

This commit is contained in:
koraynilay 2021-02-05 17:25:43 +01:00
parent 71f24ba4e1
commit 5986a2a792
3 changed files with 71 additions and 67 deletions

View file

@ -3,21 +3,23 @@ gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, GLib
class log_dlm:
def create(self_log_dlm, self, main_window):
def create(self, dlm, main_window):
if main_window == "cli":
print(main_window)
print("cli",main_window.get_title(),main_window)
return "cli"
else:
print(main_window)
self_log_dlm.update_gui_setup(self_log_dlm=self_log_dlm, self=self, bar=main_window.progress_bar)
#return main_window.progress_bar
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)
print(main_window.progress_bar)
return main_window.username_label
def update(self_log_dlm, self):
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):
print("update_choose")
if self.obj_out == "cli":
if dlm.obj_out == "cli":
print("update_cli")
self_log_dlm.update_cli(self)
self.update_cli(dlm)
#perc,
#processed_chunks,
#num_chunk_tasks,
@ -36,8 +38,9 @@ class log_dlm:
#r_speed)
else:
print("update_gui")
#self_log_dlm.update_gui(
# self,
self.update_gui(dlm, dlm.obj_out)
#self.update_gui(
# dlm,
# perc,
# processed_chunks,
# num_chunk_tasks,
@ -56,49 +59,47 @@ class log_dlm:
# r_speed,
# obj_out)
def update_gui_setup(self_log_dlm = None, self = None, bar = None):
GLib.timeout_add(1000, self_log_dlm.update_gui,
self.self, self.perc,
self.processed_chunks, self.num_chunk_tasks,
self.rt_hours, self.rt_minutes, self.rt_seconds,
self.hours, self.minutes, self.seconds,
self.total_dl, self.total_write, self.total_used,
self.dl_speed, self.dl_unc_speed, self.w_speed, self.r_speed,
bar)
#def update_gui_setup(self, dlm = None, bar = None):
def update_gui_setup(self, dlm, bar):
self.timeout_id = GLib.timeout_add(50, self.update_gui, dlm, bar)
print("timeout_add -",self.timeout_id)
#Glib.threads_init()
#print("threads_init")
def update_gui(self_log_dlm, self,
def update_gui(self, 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,
bar):
bar.set_fraction(perc)
bar.set_text(f"{self.dl_speed / 1024 / 1024:.02f} MiB/s - {(self.perc*100):.02f}% - ETA: {self.hours:02d}:{self.minutes:02d}:{self.seconds:02d}")
print(f"update_gui_{bar}")
#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_log_dlm, self)
def update_cli(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):
perc = self.perc * 100
#dl_speed, dl_unc_speed, w_speed, r_speed
#):
perc = dlm.perc * 100
print(f"perc: {perc}%")
self.log.info(f'= Progress: {perc:.02f}% ({self.processed_chunks}/{self.num_chunk_tasks}), '
f'Running for {self.rt_hours:02d}:{self.rt_minutes:02d}:{self.rt_seconds:02d}, '
f'ETA: {self.hours:02d}:{self.minutes:02d}:{self.seconds:02d}')
self.log.info(f' - Downloaded: {self.total_dl / 1024 / 1024:.02f} MiB, '
f'Written: {self.total_write / 1024 / 1024:.02f} MiB')
self.log.info(f' - Cache usage: {self.total_used} MiB, active tasks: {self.active_tasks}')
self.log.info(f' + Download\t- {self.dl_speed / 1024 / 1024:.02f} MiB/s (raw) '
f'/ {self.dl_unc_speed / 1024 / 1024:.02f} MiB/s (decompressed)')
self.log.info(f' + Disk\t- {self.w_speed / 1024 / 1024:.02f} MiB/s (write) / '
f'{self.r_speed / 1024 / 1024:.02f} MiB/s (read)')
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)')
@ -112,15 +113,15 @@ class log_dlm:
#
# self.log.info(f'= Progress: {perc:.02f}% ({processed_chunks}/{num_chunk_tasks}), '
# dlm.log.info(f'= Progress: {perc:.02f}% ({processed_chunks}/{num_chunk_tasks}), '
# f'Running for {rt_hours:02d}:{rt_minutes:02d}:{rt_seconds:02d}, '
# f'ETA: {hours:02d}:{minutes:02d}:{seconds:02d}')
# self.log.info(f' - Downloaded: {total_dl / 1024 / 1024:.02f} MiB, '
# dlm.log.info(f' - Downloaded: {total_dl / 1024 / 1024:.02f} MiB, '
# f'Written: {total_write / 1024 / 1024:.02f} MiB')
# self.log.info(f' - Cache usage: {total_used} MiB, active tasks: {self.active_tasks}')
# self.log.info(f' + Download\t- {dl_speed / 1024 / 1024:.02f} MiB/s (raw) '
# dlm.log.info(f' - Cache usage: {total_used} MiB, active tasks: {dlm.active_tasks}')
# dlm.log.info(f' + Download\t- {dl_speed / 1024 / 1024:.02f} MiB/s (raw) '
# f'/ {dl_unc_speed / 1024 / 1024:.02f} MiB/s (decompressed)')
# self.log.info(f' + Disk\t- {w_speed / 1024 / 1024:.02f} MiB/s (write) / '
# dlm.log.info(f' + Disk\t- {w_speed / 1024 / 1024:.02f} MiB/s (write) / '
# f'{r_speed / 1024 / 1024:.02f} MiB/s (read)')
#task = update_gui_task(self_log_dlm, self, 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, bar)
#task = update_gui_task(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, bar)

View file

@ -551,7 +551,6 @@ def install_gtk(app_name, app_title, parent):
args.disable_delta = disable_delta_manifest_check_button.get_active()
args.reset_sdl = reset_sdl_check_button.get_active()
install_dialog.destroy()
print( f"base_path:\t\t {args.base_path}",
f"game_folder:\t\t {args.game_folder}",
f"max_shm:\t\t {args.shared_memory}",
@ -583,6 +582,7 @@ def install_gtk(app_name, app_title, parent):
# TODO:
if install_dialog_response != Gtk.ResponseType.OK:
return 1
install_dialog.destroy()
if core.is_installed(app_name):
igame = core.get_installed_game(app_name)
@ -847,6 +847,7 @@ class main_window(Gtk.Window):
# Proress Bar for downloads
self.progress_bar = Gtk.ProgressBar()
self.progress_bar.set_show_text(True)
self.login_vbox.pack_end(self.progress_bar, False, False, 10)
self.box.pack_start(self.login_vbox, False, False, 20)

View file

@ -640,16 +640,16 @@ class DLManager(Process):
self.children.append(writer_p)
writer_p.start()
num_chunk_tasks = sum(isinstance(t, ChunkTask) for t in self.tasks)
self.num_chunk_tasks = sum(isinstance(t, ChunkTask) for t in self.tasks)
num_dl_tasks = len(self.chunks_to_dl)
num_tasks = len(self.tasks)
num_shared_memory_segments = len(self.sms)
self.log.debug(f'Chunks to download: {num_dl_tasks}, File tasks: {num_tasks}, Chunk tasks: {num_chunk_tasks}')
self.log.debug(f'Chunks to download: {num_dl_tasks}, File tasks: {num_tasks}, Chunk tasks: {self.num_chunk_tasks}')
# active downloader tasks
self.active_tasks = 0
self.processed_chunks = 0
self.processed_tasks = 0
processed_tasks = 0
self.total_dl = 0
self.total_write = 0
@ -668,9 +668,10 @@ class DLManager(Process):
t.start()
self.obj_out = log_dlm.create(self, main_window)
print("created obj_out")
print("created obj_out:", self.obj_out)
last_update = time.time()
print("before loop")
while processed_tasks < num_tasks:
delta = time.time() - last_update
@ -715,25 +716,26 @@ class DLManager(Process):
self.rt_hours = self.rt_minutes = self.rt_seconds = 0
#debug print("loop")
log_dlm.update( self,
self.perc,
self.processed_chunks,
self.num_chunk_tasks,
self.rt_hours,
self.rt_minutes,
self.rt_seconds,
self.hours,
self.minutes,
self.seconds,
self.total_dl,
self.total_write,
self.total_used,
self.dl_speed,
self.dl_unc_speed,
self.w_speed,
self.r_speed,
self.obj_out
)
print("almost updated obj_out")
#if self.obj_out == "cli":
log_dlm.update(self)
#self.perc,
#self.processed_chunks,
#self.num_chunk_tasks,
#self.rt_hours,
#self.rt_minutes,
#self.rt_seconds,
#self.hours,
#self.minutes,
#self.seconds,
#self.total_dl,
#self.total_write,
#self.total_used,
#self.dl_speed,
#self.dl_unc_speed,
#self.w_speed,
#self.r_speed,
#self.obj_out
print("updated obj_out")
# send status update to back to instantiator (if queue exists)