2021-02-24_12-48-51

This commit is contained in:
koraynilay 2021-02-24 12:48:51 +01:00
parent 9bef34b1b0
commit 133e2c7168
3 changed files with 20 additions and 11 deletions

View file

@ -38,6 +38,7 @@ class log_dlm:
#r_speed)
else:
print("update_gui")
print(f"{dlm.dl_speed / 1024 / 1024:.02f} MiB/s - {(dlm.perc*100):.02f}% - ETA: {dlm.hours:02d}:{dlm.minutes:02d}:{dlm.seconds:02d} - log_dlm")
#self.update_gui(dlm, dlm.obj_out)
#self.update_gui(
# dlm,

View file

@ -19,7 +19,7 @@ import legendary.cli
core = legendary.core.LegendaryCore()
cli = legendary.cli.LegendaryCLI()
def update_gui(dlm, bar, perc):
def update_gui(parent, bar):
# perc,
# processed_chunks, num_chunk_tasks,
# rt_hours, rt_minutes, rt_seconds,
@ -29,9 +29,9 @@ def update_gui(dlm, bar, perc):
print(f"update_gui_{bar}")
#print(f"{dlm}")
#print(f"dhexid:{hex(id(dlm.perc))}")
#bar.set_fraction(dlm.perc)
bar.set_fraction(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_fraction(parent.dlm.perc)
#bar.set_fraction(perc)
bar.set_text(f"{parent.dlm.dl_speed / 1024 / 1024:.02f} MiB/s - {(parent.dlm.perc*100):.02f}% - ETA: {parent.dlm.hours:02d}:{parent.dlm.minutes:02d}:{parent.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
@ -681,7 +681,7 @@ def install_gtk(app_name, app_title, parent):
print('Preparing download...')
# todo use status queue to print progress from CLI
# This has become a little ridiculous hasn't it?
dlm, analysis, igame = core.prepare_download(game=game, base_game=base_game, base_path=args.base_path,
parent.dlm, analysis, igame = core.prepare_download(game=game, base_game=base_game, base_path=args.base_path,
force=args.force, max_shm=args.shared_memory,
max_workers=args.max_workers, game_folder=args.game_folder,
disable_patching=args.disable_patching,
@ -762,8 +762,8 @@ def install_gtk(app_name, app_title, parent):
try:
# set up logging stuff (should be moved somewhere else later)
dlm.logging_queue = cli.logging_queue
dlm.proc_debug = args.dlm_debug
parent.dlm.logging_queue = cli.logging_queue
parent.dlm.proc_debug = args.dlm_debug
#print("parent:",parent)
# dlm.perc = 0
@ -772,12 +772,12 @@ def install_gtk(app_name, app_title, parent):
# 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}")
dlm.start()
parent.dlm.start()
#time.sleep(4)
perch = 0
parent.timeout_id = GLib.timeout_add(1000, update_gui, dlm, parent.progress_bar, perch)
#perch = 0
parent.timeout_id = GLib.timeout_add(500, update_gui, parent, parent.progress_bar)
print("timeout_add -",parent.timeout_id)
dlm.join()
#dlm.join()
except Exception as e:
end_t = time.time()
#log_gtk(f'Installation failed after {end_t - start_t:.02f} seconds.'

View file

@ -34,6 +34,14 @@ class DLManager(Process):
self.log = logging.getLogger('DLM')
self.proc_debug = False
# ###
# self.perc = 1
# self.dl_speed = 1
# self.hours = 1
# self.minutes = 1
# self.seconds = 1
# ###
self.base_url = base_url
self.dl_dir = download_dir
self.cache_dir = cache_dir if cache_dir else os.path.join(download_dir, '.cache')