mirror of
https://github.com/derrod/legendary.git
synced 2025-08-28 04:21:01 +00:00
2021-02-05_17-25-43
This commit is contained in:
parent
71f24ba4e1
commit
5986a2a792
|
@ -3,21 +3,23 @@ gi.require_version('Gtk', '3.0')
|
||||||
from gi.repository import Gtk, GLib
|
from gi.repository import Gtk, GLib
|
||||||
|
|
||||||
class log_dlm:
|
class log_dlm:
|
||||||
def create(self_log_dlm, self, main_window):
|
def create(self, dlm, main_window):
|
||||||
if main_window == "cli":
|
if main_window == "cli":
|
||||||
print(main_window)
|
print("cli",main_window.get_title(),main_window)
|
||||||
return "cli"
|
return "cli"
|
||||||
else:
|
else:
|
||||||
print(main_window)
|
print("bar",main_window.get_title(),main_window)
|
||||||
self_log_dlm.update_gui_setup(self_log_dlm=self_log_dlm, self=self, bar=main_window.progress_bar)
|
#self.update_gui_setup(dlm=dlm, bar=main_window.progress_bar)
|
||||||
#return 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):
|
#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")
|
print("update_choose")
|
||||||
if self.obj_out == "cli":
|
if dlm.obj_out == "cli":
|
||||||
print("update_cli")
|
print("update_cli")
|
||||||
self_log_dlm.update_cli(self)
|
self.update_cli(dlm)
|
||||||
#perc,
|
#perc,
|
||||||
#processed_chunks,
|
#processed_chunks,
|
||||||
#num_chunk_tasks,
|
#num_chunk_tasks,
|
||||||
|
@ -36,8 +38,9 @@ class log_dlm:
|
||||||
#r_speed)
|
#r_speed)
|
||||||
else:
|
else:
|
||||||
print("update_gui")
|
print("update_gui")
|
||||||
#self_log_dlm.update_gui(
|
self.update_gui(dlm, dlm.obj_out)
|
||||||
# self,
|
#self.update_gui(
|
||||||
|
# dlm,
|
||||||
# perc,
|
# perc,
|
||||||
# processed_chunks,
|
# processed_chunks,
|
||||||
# num_chunk_tasks,
|
# num_chunk_tasks,
|
||||||
|
@ -56,49 +59,47 @@ class log_dlm:
|
||||||
# r_speed,
|
# r_speed,
|
||||||
# obj_out)
|
# obj_out)
|
||||||
|
|
||||||
def update_gui_setup(self_log_dlm = None, self = None, bar = None):
|
#def update_gui_setup(self, dlm = None, bar = None):
|
||||||
GLib.timeout_add(1000, self_log_dlm.update_gui,
|
def update_gui_setup(self, dlm, bar):
|
||||||
self.self, self.perc,
|
self.timeout_id = GLib.timeout_add(50, self.update_gui, dlm, bar)
|
||||||
self.processed_chunks, self.num_chunk_tasks,
|
print("timeout_add -",self.timeout_id)
|
||||||
self.rt_hours, self.rt_minutes, self.rt_seconds,
|
#Glib.threads_init()
|
||||||
self.hours, self.minutes, self.seconds,
|
#print("threads_init")
|
||||||
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(self_log_dlm, self,
|
def update_gui(self, dlm, bar):
|
||||||
# perc,
|
# perc,
|
||||||
# processed_chunks, num_chunk_tasks,
|
# processed_chunks, num_chunk_tasks,
|
||||||
# rt_hours, rt_minutes, rt_seconds,
|
# rt_hours, rt_minutes, rt_seconds,
|
||||||
# hours, minutes, seconds,
|
# hours, minutes, seconds,
|
||||||
# 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,
|
||||||
bar):
|
print(f"update_gui_{bar}")
|
||||||
bar.set_fraction(perc)
|
#bar.set_fraction(dlm.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}")
|
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_log_dlm, self)
|
def update_cli(self, dlm):
|
||||||
#perc,
|
#perc,
|
||||||
#processed_chunks, num_chunk_tasks,
|
#processed_chunks, num_chunk_tasks,
|
||||||
#rt_hours, rt_minutes, rt_seconds,
|
#rt_hours, rt_minutes, rt_seconds,
|
||||||
#hours, minutes, seconds,
|
#hours, minutes, seconds,
|
||||||
#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
|
||||||
perc = self.perc * 100
|
#):
|
||||||
|
perc = dlm.perc * 100
|
||||||
print(f"perc: {perc}%")
|
print(f"perc: {perc}%")
|
||||||
self.log.info(f'= Progress: {perc:.02f}% ({self.processed_chunks}/{self.num_chunk_tasks}), '
|
dlm.log.info(f'= Progress: {perc:.02f}% ({dlm.processed_chunks}/{dlm.num_chunk_tasks}), '
|
||||||
f'Running for {self.rt_hours:02d}:{self.rt_minutes:02d}:{self.rt_seconds:02d}, '
|
f'Running for {dlm.rt_hours:02d}:{dlm.rt_minutes:02d}:{dlm.rt_seconds:02d}, '
|
||||||
f'ETA: {self.hours:02d}:{self.minutes:02d}:{self.seconds:02d}')
|
f'ETA: {dlm.hours:02d}:{dlm.minutes:02d}:{dlm.seconds:02d}')
|
||||||
self.log.info(f' - Downloaded: {self.total_dl / 1024 / 1024:.02f} MiB, '
|
dlm.log.info(f' - Downloaded: {dlm.total_dl / 1024 / 1024:.02f} MiB, '
|
||||||
f'Written: {self.total_write / 1024 / 1024:.02f} MiB')
|
f'Written: {dlm.total_write / 1024 / 1024:.02f} MiB')
|
||||||
self.log.info(f' - Cache usage: {self.total_used} MiB, active tasks: {self.active_tasks}')
|
dlm.log.info(f' - Cache usage: {dlm.total_used} MiB, active tasks: {dlm.active_tasks}')
|
||||||
self.log.info(f' + Download\t- {self.dl_speed / 1024 / 1024:.02f} MiB/s (raw) '
|
dlm.log.info(f' + Download\t- {dlm.dl_speed / 1024 / 1024:.02f} MiB/s (raw) '
|
||||||
f'/ {self.dl_unc_speed / 1024 / 1024:.02f} MiB/s (decompressed)')
|
f'/ {dlm.dl_unc_speed / 1024 / 1024:.02f} MiB/s (decompressed)')
|
||||||
self.log.info(f' + Disk\t- {self.w_speed / 1024 / 1024:.02f} MiB/s (write) / '
|
dlm.log.info(f' + Disk\t- {dlm.w_speed / 1024 / 1024:.02f} MiB/s (write) / '
|
||||||
f'{self.r_speed / 1024 / 1024:.02f} MiB/s (read)')
|
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'Running for {rt_hours:02d}:{rt_minutes:02d}:{rt_seconds:02d}, '
|
||||||
# f'ETA: {hours:02d}:{minutes:02d}:{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')
|
# f'Written: {total_write / 1024 / 1024:.02f} MiB')
|
||||||
# self.log.info(f' - Cache usage: {total_used} MiB, active tasks: {self.active_tasks}')
|
# dlm.log.info(f' - Cache usage: {total_used} MiB, active tasks: {dlm.active_tasks}')
|
||||||
# self.log.info(f' + Download\t- {dl_speed / 1024 / 1024:.02f} MiB/s (raw) '
|
# dlm.log.info(f' + Download\t- {dl_speed / 1024 / 1024:.02f} MiB/s (raw) '
|
||||||
# f'/ {dl_unc_speed / 1024 / 1024:.02f} MiB/s (decompressed)')
|
# 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)')
|
# 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)
|
||||||
|
|
|
@ -551,7 +551,6 @@ def install_gtk(app_name, app_title, parent):
|
||||||
args.disable_delta = disable_delta_manifest_check_button.get_active()
|
args.disable_delta = disable_delta_manifest_check_button.get_active()
|
||||||
args.reset_sdl = reset_sdl_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}",
|
print( f"base_path:\t\t {args.base_path}",
|
||||||
f"game_folder:\t\t {args.game_folder}",
|
f"game_folder:\t\t {args.game_folder}",
|
||||||
f"max_shm:\t\t {args.shared_memory}",
|
f"max_shm:\t\t {args.shared_memory}",
|
||||||
|
@ -583,6 +582,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()
|
||||||
|
|
||||||
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)
|
||||||
|
@ -847,6 +847,7 @@ class main_window(Gtk.Window):
|
||||||
|
|
||||||
# Proress Bar for downloads
|
# Proress Bar for downloads
|
||||||
self.progress_bar = Gtk.ProgressBar()
|
self.progress_bar = Gtk.ProgressBar()
|
||||||
|
self.progress_bar.set_show_text(True)
|
||||||
self.login_vbox.pack_end(self.progress_bar, False, False, 10)
|
self.login_vbox.pack_end(self.progress_bar, False, False, 10)
|
||||||
|
|
||||||
self.box.pack_start(self.login_vbox, False, False, 20)
|
self.box.pack_start(self.login_vbox, False, False, 20)
|
||||||
|
|
|
@ -640,16 +640,16 @@ class DLManager(Process):
|
||||||
self.children.append(writer_p)
|
self.children.append(writer_p)
|
||||||
writer_p.start()
|
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_dl_tasks = len(self.chunks_to_dl)
|
||||||
num_tasks = len(self.tasks)
|
num_tasks = len(self.tasks)
|
||||||
num_shared_memory_segments = len(self.sms)
|
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
|
# active downloader tasks
|
||||||
self.active_tasks = 0
|
self.active_tasks = 0
|
||||||
self.processed_chunks = 0
|
self.processed_chunks = 0
|
||||||
self.processed_tasks = 0
|
processed_tasks = 0
|
||||||
self.total_dl = 0
|
self.total_dl = 0
|
||||||
self.total_write = 0
|
self.total_write = 0
|
||||||
|
|
||||||
|
@ -668,9 +668,10 @@ class DLManager(Process):
|
||||||
t.start()
|
t.start()
|
||||||
|
|
||||||
self.obj_out = log_dlm.create(self, main_window)
|
self.obj_out = log_dlm.create(self, main_window)
|
||||||
print("created obj_out")
|
print("created obj_out:", self.obj_out)
|
||||||
|
|
||||||
last_update = time.time()
|
last_update = time.time()
|
||||||
|
print("before loop")
|
||||||
|
|
||||||
while processed_tasks < num_tasks:
|
while processed_tasks < num_tasks:
|
||||||
delta = time.time() - last_update
|
delta = time.time() - last_update
|
||||||
|
@ -715,25 +716,26 @@ class DLManager(Process):
|
||||||
self.rt_hours = self.rt_minutes = self.rt_seconds = 0
|
self.rt_hours = self.rt_minutes = self.rt_seconds = 0
|
||||||
|
|
||||||
#debug print("loop")
|
#debug print("loop")
|
||||||
log_dlm.update( self,
|
print("almost updated obj_out")
|
||||||
self.perc,
|
#if self.obj_out == "cli":
|
||||||
self.processed_chunks,
|
log_dlm.update(self)
|
||||||
self.num_chunk_tasks,
|
#self.perc,
|
||||||
self.rt_hours,
|
#self.processed_chunks,
|
||||||
self.rt_minutes,
|
#self.num_chunk_tasks,
|
||||||
self.rt_seconds,
|
#self.rt_hours,
|
||||||
self.hours,
|
#self.rt_minutes,
|
||||||
self.minutes,
|
#self.rt_seconds,
|
||||||
self.seconds,
|
#self.hours,
|
||||||
self.total_dl,
|
#self.minutes,
|
||||||
self.total_write,
|
#self.seconds,
|
||||||
self.total_used,
|
#self.total_dl,
|
||||||
self.dl_speed,
|
#self.total_write,
|
||||||
self.dl_unc_speed,
|
#self.total_used,
|
||||||
self.w_speed,
|
#self.dl_speed,
|
||||||
self.r_speed,
|
#self.dl_unc_speed,
|
||||||
self.obj_out
|
#self.w_speed,
|
||||||
)
|
#self.r_speed,
|
||||||
|
#self.obj_out
|
||||||
print("updated obj_out")
|
print("updated obj_out")
|
||||||
|
|
||||||
# send status update to back to instantiator (if queue exists)
|
# send status update to back to instantiator (if queue exists)
|
||||||
|
|
Loading…
Reference in a new issue