almost finished install. TODO: fix main_window.progress_bar update

This commit is contained in:
koraynilay 2021-02-05 00:39:22 +01:00
parent 5ecd04abb0
commit 67b347ab14
5 changed files with 50 additions and 26 deletions

View file

@ -8,14 +8,15 @@ class log_dlm:
print(main_window) print(main_window)
return "cli" return "cli"
else: else:
bar = Gtk.ProgressBar()
main_window.login_vbox.pack_end(bar, False, False, 10)
print(main_window) print(main_window)
return bar return main_window.progress_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): def update(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, obj_out):
print("update_choose")
if obj_out == "cli": if obj_out == "cli":
update_cli( self, print("update_cli")
self_log_dlm.update_cli(
self,
perc, perc,
processed_chunks, processed_chunks,
num_chunk_tasks, num_chunk_tasks,
@ -33,7 +34,9 @@ class log_dlm:
w_speed, w_speed,
r_speed) r_speed)
else: else:
update_gui( self, print("update_gui")
self_log_dlm.update_gui(
self,
perc, perc,
processed_chunks, processed_chunks,
num_chunk_tasks, num_chunk_tasks,
@ -53,13 +56,14 @@ class log_dlm:
obj_out) 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): def update_gui(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):
bar.set_fraction(perc) 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}") bar.set_text(f"{dl_speed / 1024 / 1024:.02f} MiB/s - {(perc*100):.02f}% - ETA: {hours:02d}:{minutes:02d}:{seconds:02d}")
print(bar.get_text()) print(bar.get_text())
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): def update_cli(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):
perc *= 100 perc *= 100
print(f"perc: {perc}")
self.log.info(f'= Progress: {perc:.02f}% ({processed_chunks}/{num_chunk_tasks}), ' 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'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}')

View file

@ -138,7 +138,6 @@ class FileWorker(Process):
logger = logging.getLogger(self.name) logger = logging.getLogger(self.name)
logger.setLevel(self.log_level) logger.setLevel(self.log_level)
logger.debug(f'Download worker reporting for duty!') logger.debug(f'Download worker reporting for duty!')
print(f'Download worker reporting for duty! {self.name}')
last_filename = '' last_filename = ''
current_file = None current_file = None
@ -146,9 +145,7 @@ class FileWorker(Process):
while True: while True:
try: try:
try: try:
print(f'j = self.q.get - {self.name}') j = self.q.get(timeout=10.0)
#j = self.q.get(timeout=10.0)
j = self.q.get(timeout=0.5)
except Empty: except Empty:
logger.warning('Writer queue empty!') logger.warning('Writer queue empty!')
continue continue

View file

@ -1,5 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# TODO: fix progress bar
import sys import sys
# insert at 1, 0 is the script path (or '' in REPL) # insert at 1, 0 is the script path (or '' in REPL)
sys.path.insert(1, '../..') sys.path.insert(1, '../..')
@ -85,7 +87,7 @@ def update_avail(app_name):
else: else:
return "" return ""
# TODO: actual install # TODO: finish actual install
def install_gtk(app_name, app_title, parent): def install_gtk(app_name, app_title, parent):
install_dialog = Gtk.MessageDialog( parent=parent, install_dialog = Gtk.MessageDialog( parent=parent,
destroy_with_parent=True, destroy_with_parent=True,
@ -592,7 +594,8 @@ def install_gtk(app_name, app_title, parent):
repair_file = os.path.join(core.lgd.get_tmp_path(), f'{app_name}.repair') repair_file = os.path.join(core.lgd.get_tmp_path(), f'{app_name}.repair')
if not core.login(): if not core.login():
log_gtk('Login failed! Cannot continue with download process.') #log_gtk('Login failed! Cannot continue with download process.')
print('Login failed! Cannot continue with download process.')
exit(1) exit(1)
if args.file_prefix or args.file_exclude_prefix or args.install_tag: if args.file_prefix or args.file_exclude_prefix or args.install_tag:
@ -600,7 +603,8 @@ def install_gtk(app_name, app_title, parent):
if args.update_only: if args.update_only:
if not core.is_installed(app_name): if not core.is_installed(app_name):
log_gtk(f'Update requested for "{app_name}", but app not installed!') #log_gtk(f'Update requested for "{app_name}", but app not installed!')
print(f'Update requested for "{app_name}", but app not installed!')
exit(1) exit(1)
if args.platform_override: if args.platform_override:
@ -609,19 +613,23 @@ def install_gtk(app_name, app_title, parent):
game = core.get_game(app_name, update_meta=True) game = core.get_game(app_name, update_meta=True)
if not game: if not game:
log_gtk(f'Could not find "{app_name}" in list of available games,' #log_gtk(f'Could not find "{app_name}" in list of available games,'
# f'did you type the name correctly?')
print(f'Could not find "{app_name}" in list of available games,'
f'did you type the name correctly?') f'did you type the name correctly?')
exit(1) exit(1)
if game.is_dlc: if game.is_dlc:
log_gtk('Install candidate is DLC') #log_gtk('Install candidate is DLC')
print('Install candidate is DLC')
app_name = game.metadata['mainGameItem']['releaseInfo'][0]['appId'] app_name = game.metadata['mainGameItem']['releaseInfo'][0]['appId']
base_game = core.get_game(app_name) base_game = core.get_game(app_name)
# check if base_game is actually installed # check if base_game is actually installed
if not core.is_installed(app_name): if not core.is_installed(app_name):
# download mode doesn't care about whether or not something's installed # download mode doesn't care about whether or not something's installed
if not args.no_install: if not args.no_install:
log_gtk(f'Base game "{app_name}" is not installed!') #log_gtk(f'Base game "{app_name}" is not installed!')
print(f'Base game "{app_name}" is not installed!')
exit(1) exit(1)
else: else:
base_game = None base_game = None
@ -678,19 +686,22 @@ def install_gtk(app_name, app_title, parent):
# game is either up to date or hasn't changed, so we have nothing to do # game is either up to date or hasn't changed, so we have nothing to do
if not analysis.dl_size: if not analysis.dl_size:
old_igame = core.get_installed_game(game.app_name) old_igame = core.get_installed_game(game.app_name)
log_gtk('Download size is 0, the game is either already up to date or has not changed. Exiting...') #log_gtk('Download size is 0, the game is either already up to date or has not changed. Exiting...')
print('Download size is 0, the game is either already up to date or has not changed. Exiting...')
if old_igame and args.repair_mode and os.path.exists(repair_file): if old_igame and args.repair_mode and os.path.exists(repair_file):
if old_igame.needs_verification: if old_igame.needs_verification:
old_igame.needs_verification = False old_igame.needs_verification = False
core.install_game(old_igame) core.install_game(old_igame)
log_gtk('Removing repair file.') #log_gtk('Removing repair file.')
print('Removing repair file.')
os.remove(repair_file) os.remove(repair_file)
# check if install tags have changed, if they did; try deleting files that are no longer required. # check if install tags have changed, if they did; try deleting files that are no longer required.
if old_igame and old_igame.install_tags != igame.install_tags: if old_igame and old_igame.install_tags != igame.install_tags:
old_igame.install_tags = igame.install_tags old_igame.install_tags = igame.install_tags
log_gtk('Deleting now untagged files.') #log_gtk('Deleting now untagged files.')
print('Deleting now untagged files.')
core.uninstall_tag(old_igame) core.uninstall_tag(old_igame)
core.install_game(old_igame) core.install_game(old_igame)
@ -708,15 +719,18 @@ def install_gtk(app_name, app_title, parent):
ignore_space_req=args.ignore_space) ignore_space_req=args.ignore_space)
if res.warnings or res.failures: if res.warnings or res.failures:
log_gtk('Installation requirements check returned the following results:') #log_gtk('Installation requirements check returned the following results:')
print('Installation requirements check returned the following results:')
if res.warnings: if res.warnings:
for warn in sorted(res.warnings): for warn in sorted(res.warnings):
log_gtk(warn) #log_gtk(warn)
print(warn)
if res.failures: if res.failures:
for msg in sorted(res.failures): for msg in sorted(res.failures):
log_gtk(msg) #log_gtk(msg)
print(msg)
log_gtk('Installation cannot proceed, exiting.') log_gtk('Installation cannot proceed, exiting.')
exit(1) exit(1)
@ -735,7 +749,11 @@ def install_gtk(app_name, app_title, parent):
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.'
# f'The following exception occurred while waiting for the downloader to finish: {e!r}. '
# f'Try restarting the process, the resume file will be used to start where it failed. '
# f'If it continues to fail please open an issue on GitHub.')
print(f'Installation failed after {end_t - start_t:.02f} seconds.'
f'The following exception occurred while waiting for the downloader to finish: {e!r}. ' f'The following exception occurred while waiting for the downloader to finish: {e!r}. '
f'Try restarting the process, the resume file will be used to start where it failed. ' f'Try restarting the process, the resume file will be used to start where it failed. '
f'If it continues to fail please open an issue on GitHub.') f'If it continues to fail please open an issue on GitHub.')
@ -827,6 +845,10 @@ class main_window(Gtk.Window):
self.login_vbox.pack_end(self.button_logout, False, False, 10) self.login_vbox.pack_end(self.button_logout, False, False, 10)
self.login_vbox.pack_end(self.username_label, False, False, 0) self.login_vbox.pack_end(self.username_label, False, False, 0)
# Proress Bar for downloads
self.progress_bar = Gtk.ProgressBar()
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)
# Games # Games

View file

@ -620,7 +620,7 @@ class DLManager(Process):
self.log.debug(f'Created {len(self.sms)} shared memory segments.') self.log.debug(f'Created {len(self.sms)} shared memory segments.')
obj_out = log_dlm.create(main_window) obj_out = log_dlm.create("cli")
print("created obj_out") print("created obj_out")
# Create queues # Create queues
@ -716,6 +716,7 @@ class DLManager(Process):
hours = minutes = seconds = 0 hours = minutes = seconds = 0
rt_hours = rt_minutes = rt_seconds = 0 rt_hours = rt_minutes = rt_seconds = 0
print("loop")
log_dlm.update( self, log_dlm.update( self,
perc, perc,
processed_chunks, processed_chunks,