2021-02-04_16-22-20

This commit is contained in:
koraynilay 2021-02-04 16:22:20 +01:00
parent d328e6f4c5
commit 736983992c
4 changed files with 102 additions and 28 deletions

View file

@ -705,7 +705,7 @@ class LegendaryCore:
dl_optimizations: bool = False, dl_timeout: int = 10,
repair: bool = False, repair_use_latest: bool = False,
disable_delta: bool = False, override_delta_manifest: str = '',
egl_guid: str = '') -> (DLManager, AnalysisResult, ManifestMeta):
egl_guid: str = '', main_window="cli") -> (DLManager, AnalysisResult, ManifestMeta):
# load old manifest
old_manifest = None
@ -832,7 +832,7 @@ class LegendaryCore:
dlm = DLManager(install_path, base_url, resume_file=resume_file, status_q=status_q,
max_shared_memory=max_shm * 1024 * 1024, max_workers=max_workers,
dl_timeout=dl_timeout)
dl_timeout=dl_timeout, main_window=main_window)
anlres = dlm.run_analysis(manifest=new_manifest, old_manifest=old_manifest,
patch=not disable_patching, resume=not force,
file_prefix_filter=file_prefix_filter,

View file

@ -1,6 +1,58 @@
class log_dlm:
def __init__(self,
def log_dlm_cli(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):
def create(main_window):
if main_window == "cli":
return "cli"
else:
bar = Gtk.ProgressBar()
main_window.login_vbox.pack_end(bar, False, False, 10)
return bar
def update(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, obj_out):
if obj_out == "cli":
update_cli( 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)
else:
update_gui( 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,
obj_out)
def update_gui(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):
bar.set_fraction(perc)
bar.set_text(f"{dl_speed / 1024 / 1024:.02f} MiB/s - {(perc*100):.02f}% - ETA: {hours:02d}:{minutes:02d}:{seconds:02d}")
def update_cli(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):
perc *= 100
self.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}')
@ -12,7 +64,9 @@ class log_dlm:
self.log.info(f' + Disk\t- {w_speed / 1024 / 1024:.02f} MiB/s (write) / '
f'{r_speed / 1024 / 1024:.02f} MiB/s (read)')
class log_dlm_gui:
def init(parent):
bar = Gtk.ProgressBar()
parent.login_vbox.pack_end(bar, False, False, 10)
@ -29,3 +83,20 @@ class log_dlm:
f'/ {dl_unc_speed / 1024 / 1024:.02f} MiB/s (decompressed)')
f' + Disk\t- {w_speed / 1024 / 1024:.02f} MiB/s (write) / '
f'{r_speed / 1024 / 1024:.02f} MiB/s (read)')
self.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, '
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) '
f'/ {dl_unc_speed / 1024 / 1024:.02f} MiB/s (decompressed)')
self.log.info(f' + Disk\t- {w_speed / 1024 / 1024:.02f} MiB/s (write) / '
f'{r_speed / 1024 / 1024:.02f} MiB/s (read)')

View file

@ -662,7 +662,8 @@ def install_gtk(app_name, app_title, parent):
repair=args.repair_mode,
repair_use_latest=args.repair_and_update,
disable_delta=args.disable_delta,
override_delta_manifest=args.override_delta_manifest)
override_delta_manifest=args.override_delta_manifest
main_window=parent)
# game is either up to date or hasn't changed, so we have nothing to do
if not analysis.dl_size:

View file

@ -22,7 +22,7 @@ from legendary.models.manifest import ManifestComparison, Manifest
class DLManager(Process):
def __init__(self, download_dir, base_url, cache_dir=None, status_q=None,
max_workers=0, update_interval=1.0, dl_timeout=10, resume_file=None,
max_shared_memory=1024 * 1024 * 1024, is_gui):
max_shared_memory=1024 * 1024 * 1024, main_window="cli"):
super().__init__(name='DLManager')
self.log = logging.getLogger('DLM')
self.proc_debug = False
@ -577,7 +577,7 @@ class DLManager(Process):
self.log.info(f'Download Manager running with process-id: {os.getpid()}')
try:
self.run_real(is_gui)
self.run_real(main_window)
except KeyboardInterrupt:
self.log.warning('Immediate exit requested!')
self.running = False
@ -604,7 +604,7 @@ class DLManager(Process):
q.close()
q.join_thread()
def run_real(self, is_gui):
def run_real(self, main_window):
self.shared_memory = SharedMemory(create=True, size=self.max_shared_memory)
self.log.debug(f'Created shared memory of size: {self.shared_memory.size / 1024 / 1024:.02f} MiB')
@ -660,6 +660,8 @@ class DLManager(Process):
self.threads.append(Thread(target=self.dl_results_handler, args=(task_cond,)))
self.threads.append(Thread(target=self.fw_results_handler, args=(shm_cond,)))
obj_out = log_dlm.create(main_window)
for t in self.threads:
t.start()
@ -690,7 +692,7 @@ class DLManager(Process):
self.bytes_decompressed_since_last = self.num_tasks_processed_since_last = 0
last_update = time.time()
perc = (processed_chunks / num_chunk_tasks) * 100
perc = (processed_chunks / num_chunk_tasks)
runtime = time.time() - s_time
total_avail = len(self.sms)
total_used = (num_shared_memory_segments - total_avail) * (self.analysis.biggest_chunk / 1024 / 1024)
@ -707,24 +709,24 @@ class DLManager(Process):
hours = minutes = seconds = 0
rt_hours = rt_minutes = rt_seconds = 0
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,
is_gui
log_dlm.update( 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,
obj_out
)
# send status update to back to instantiator (if queue exists)