[view] fix: uninstall and downgrade logs are not available

This commit is contained in:
Vinicius Moreira
2022-04-08 10:45:43 -03:00
parent 73a93965dd
commit 581f5b9d46
11 changed files with 32 additions and 19 deletions

View File

@@ -31,6 +31,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Fixes ### Fixes
- General - General
- not properly converting bit based sizes (KiB, MiB, etc...) to byte based - not properly converting bit based sizes (KiB, MiB, etc...) to byte based
- uninstall and downgrade logs are not available [#255](https://github.com/vinifmor/bauh/issues/255)
- Debian - Debian
- info: crashing when the package size has unexpected symbols [#251](https://github.com/vinifmor/bauh/issues/251) - info: crashing when the package size has unexpected symbols [#251](https://github.com/vinifmor/bauh/issues/251)

View File

@@ -764,6 +764,8 @@ class ManageWindow(QWidget):
def _finish_uninstall(self, res: dict): def _finish_uninstall(self, res: dict):
self._finish_action(action_id=ACTION_UNINSTALL) self._finish_action(action_id=ACTION_UNINSTALL)
self._write_operation_logs('uninstall', res['pkg'])
if res['success']: if res['success']:
src_pkg = res['pkg'] src_pkg = res['pkg']
if self._can_notify_user(): if self._can_notify_user():
@@ -1161,8 +1163,9 @@ class ManageWindow(QWidget):
with open(logs_path, 'w+') as f: with open(logs_path, 'w+') as f:
f.write(output) f.write(output)
self.textarea_details.appendPlainText('\n*Upgrade summary generated at: {}'.format(UpgradeSelected.SUMMARY_FILE.format(res['id']))) self.textarea_details.appendPlainText('\n* Upgrade summary generated at: {}'.format(UpgradeSelected.SUMMARY_FILE.format(res['id'])))
self.textarea_details.appendPlainText('*Upgrade logs generated at: {}'.format(logs_path)) log_msg = '* ' + self.i18n['console.operation_log'].format(path=f'"{logs_path}"')
self.textarea_details.appendPlainText(log_msg)
except: except:
traceback.print_exc() traceback.print_exc()
@@ -1246,6 +1249,7 @@ class ManageWindow(QWidget):
def _finish_downgrade(self, res: dict): def _finish_downgrade(self, res: dict):
self._finish_action() self._finish_action()
self._write_operation_logs('downgrade', res['app'])
if res['success']: if res['success']:
self.comp_manager.remove_saved_state(ACTION_DOWNGRADE) self.comp_manager.remove_saved_state(ACTION_DOWNGRADE)
@@ -1384,24 +1388,32 @@ class ManageWindow(QWidget):
self.thread_install.root_pwd = pwd self.thread_install.root_pwd = pwd
self.thread_install.start() self.thread_install.start()
def _finish_install(self, res: dict): def _write_operation_logs(self, type_: str, pkg: PackageView):
self._finish_action(action_id=ACTION_INSTALL)
console_output = self.textarea_details.toPlainText() console_output = self.textarea_details.toPlainText()
if console_output: if console_output:
log_path = f"{LOGS_DIR}/install/{res['pkg'].model.get_type()}/{res['pkg'].model.name}" log_path = f"{LOGS_DIR}/{type_}/{pkg.model.get_type()}/{pkg.model.name}"
try: try:
Path(log_path).mkdir(parents=True, exist_ok=True) Path(log_path).mkdir(parents=True, exist_ok=True)
except OSError:
self.textarea_details.appendPlainText(f"[error] Could not create the operation log directory '{log_path}'")
return
log_file = f'{log_path}/{int(time.time())}.log' log_file = f'{log_path}/{int(time.time())}.log'
try:
with open(log_file, 'w+') as f: with open(log_file, 'w+') as f:
f.write(console_output) f.write(console_output)
except OSError:
self.textarea_details.appendPlainText(f"[error] Could not write the operation log to file '{log_file}'")
return
self.textarea_details.appendPlainText(self.i18n['console.install_logs.path'].format('"{}"'.format(log_file))) log_msg = '* ' + self.i18n['console.operation_log'].format(path=f'"{log_file}"')
except: self.textarea_details.appendPlainText(log_msg)
self.textarea_details.appendPlainText("[warning] Could not write install log file to '{}'".format(log_path))
def _finish_install(self, res: dict):
self._finish_action(action_id=ACTION_INSTALL)
self._write_operation_logs('install', res['pkg'])
if res['success']: if res['success']:
if self._can_notify_user(): if self._can_notify_user():

View File

@@ -200,7 +200,7 @@ change=modifica
clean=netejar clean=netejar
close=tanca close=tanca
confirmation=confirmació confirmation=confirmació
console.install_logs.path=Trobareu registres dinstal·lació a {} console.operation_log=The operation logs can be found at {path}
continue=continua continue=continua
copy=copia copy=copia
core.config.backup=Enabled core.config.backup=Enabled

View File

@@ -199,7 +199,7 @@ change=Anwenden
clean=Bereinigen clean=Bereinigen
close=Schließen close=Schließen
confirmation=Bestätigung confirmation=Bestätigung
console.install_logs.path=Die Installationslogs befinden sich unter {} console.operation_log=The operation logs can be found at {path}
continue=Fortfahren continue=Fortfahren
copy=Kopieren copy=Kopieren
core.config.backup=Enabled core.config.backup=Enabled

View File

@@ -201,7 +201,7 @@ change=change
clean=clean clean=clean
close=close close=close
confirmation=confirmation confirmation=confirmation
console.install_logs.path=Installation logs can be found at {} console.operation_log=The operation logs can be found at {path}
continue=continue continue=continue
copy=copy copy=copy
core.config.backup.downgrade=Before downgrading core.config.backup.downgrade=Before downgrading

View File

@@ -200,7 +200,7 @@ change=cambiar
clean=limpiar clean=limpiar
close=cerrar close=cerrar
confirmation=confirmación confirmation=confirmación
console.install_logs.path=Los registros de instalación pueden encontrarse en {} console.operation_log=Los registros de la operación se encuentran en {path}
continue=continuar continue=continuar
copy=copiar copy=copiar
core.config.backup=Habilitada core.config.backup=Habilitada

View File

@@ -199,7 +199,7 @@ change=changement
clean=vider clean=vider
close=fermer close=fermer
confirmation=confirmation confirmation=confirmation
console.install_logs.path=Logs d'installation disponibles à {} console.operation_log=The operation logs can be found at {path}
continue=continuer continue=continuer
copy=copier copy=copier
core.config.backup.downgrade=Avant de downgrader core.config.backup.downgrade=Avant de downgrader

View File

@@ -199,7 +199,7 @@ change=Cambia
clean=pulire clean=pulire
close=vicino close=vicino
confirmation=conferma confirmation=conferma
console.install_logs.path=I registri di installazione sono disponibili all'indirizzo {} console.operation_log=The operation logs can be found at {path}
continue=continua continue=continua
copy=copia copy=copia
core.config.backup=Enabled core.config.backup=Enabled

View File

@@ -199,7 +199,7 @@ change=alterar
clean=limpar clean=limpar
close=fechar close=fechar
confirmation=confirmação confirmation=confirmação
console.install_logs.path=Os registros de instalação podem ser encontrados em {} console.operation_log=Os registros da operação podem ser encontrados em {path}
continue=continuar continue=continuar
copy=copiar copy=copiar
core.config.backup.downgrade=Antes de reverter versão core.config.backup.downgrade=Antes de reverter versão

View File

@@ -199,7 +199,7 @@ change=Изменить
clean=Очистка clean=Очистка
close=Закрыть close=Закрыть
confirmation=Подтверждение confirmation=Подтверждение
console.install_logs.path=Журналы установки можно найти по адресу {} console.operation_log=The operation logs can be found at {path}
continue=Продолжить continue=Продолжить
copy=Копировать copy=Копировать
core.config.backup=Enabled core.config.backup=Enabled

View File

@@ -199,7 +199,7 @@ change=değiştir
clean=temizle clean=temizle
close=kapat close=kapat
confirmation=onayla confirmation=onayla
console.install_logs.path=Kurulum günlüklerini {} adresinde bulabilirsiniz console.operation_log=The operation logs can be found at {path}
continue=devam continue=devam
copy=kopyala copy=kopyala
core.config.backup.downgrade=Önce sürüm düşürülüyor core.config.backup.downgrade=Önce sürüm düşürülüyor