[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

@@ -764,6 +764,8 @@ class ManageWindow(QWidget):
def _finish_uninstall(self, res: dict):
self._finish_action(action_id=ACTION_UNINSTALL)
self._write_operation_logs('uninstall', res['pkg'])
if res['success']:
src_pkg = res['pkg']
if self._can_notify_user():
@@ -1161,8 +1163,9 @@ class ManageWindow(QWidget):
with open(logs_path, 'w+') as f:
f.write(output)
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))
self.textarea_details.appendPlainText('\n* Upgrade summary generated at: {}'.format(UpgradeSelected.SUMMARY_FILE.format(res['id'])))
log_msg = '* ' + self.i18n['console.operation_log'].format(path=f'"{logs_path}"')
self.textarea_details.appendPlainText(log_msg)
except:
traceback.print_exc()
@@ -1246,6 +1249,7 @@ class ManageWindow(QWidget):
def _finish_downgrade(self, res: dict):
self._finish_action()
self._write_operation_logs('downgrade', res['app'])
if res['success']:
self.comp_manager.remove_saved_state(ACTION_DOWNGRADE)
@@ -1384,24 +1388,32 @@ class ManageWindow(QWidget):
self.thread_install.root_pwd = pwd
self.thread_install.start()
def _finish_install(self, res: dict):
self._finish_action(action_id=ACTION_INSTALL)
def _write_operation_logs(self, type_: str, pkg: PackageView):
console_output = self.textarea_details.toPlainText()
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:
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:
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)))
except:
self.textarea_details.appendPlainText("[warning] Could not write install log file to '{}'".format(log_path))
log_msg = '* ' + self.i18n['console.operation_log'].format(path=f'"{log_file}"')
self.textarea_details.appendPlainText(log_msg)
def _finish_install(self, res: dict):
self._finish_action(action_id=ACTION_INSTALL)
self._write_operation_logs('install', res['pkg'])
if res['success']:
if self._can_notify_user():

View File

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

View File

@@ -199,7 +199,7 @@ change=Anwenden
clean=Bereinigen
close=Schließen
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
copy=Kopieren
core.config.backup=Enabled

View File

@@ -201,7 +201,7 @@ change=change
clean=clean
close=close
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
copy=copy
core.config.backup.downgrade=Before downgrading

View File

@@ -200,7 +200,7 @@ change=cambiar
clean=limpiar
close=cerrar
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
copy=copiar
core.config.backup=Habilitada

View File

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

View File

@@ -199,7 +199,7 @@ change=Cambia
clean=pulire
close=vicino
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
copy=copia
core.config.backup=Enabled

View File

@@ -199,7 +199,7 @@ change=alterar
clean=limpar
close=fechar
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
copy=copiar
core.config.backup.downgrade=Antes de reverter versão

View File

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

View File

@@ -199,7 +199,7 @@ change=değiştir
clean=temizle
close=kapat
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
copy=kopyala
core.config.backup.downgrade=Önce sürüm düşürülüyor