showing console details when upgrading fails

This commit is contained in:
Vinicius Moreira
2019-07-12 14:33:14 -03:00
parent 1b8cf8a2f3
commit 9af8b73e23
3 changed files with 28 additions and 6 deletions

View File

@@ -99,7 +99,7 @@ def update_and_stream(app_ref: str):
:param app_ref:
:return:
"""
return system.stream_cmd([BASE_CMD, 'update', '-y', app_ref])
return system.cmd_to_subprocess([BASE_CMD, 'update', '-y', app_ref])
def uninstall_and_stream(app_ref: str):

View File

@@ -15,7 +15,7 @@ from fpakman.view.qt.view_model import ApplicationView
class UpdateSelectedApps(QThread):
signal_finished = pyqtSignal()
signal_finished = pyqtSignal(bool)
signal_output = pyqtSignal(str)
def __init__(self, manager: ApplicationManager, apps_to_update: List[ApplicationView] = None):
@@ -25,13 +25,31 @@ class UpdateSelectedApps(QThread):
def run(self):
error = False
for app in self.apps_to_update:
for output in self.manager.update_and_stream(app.model):
subproc = self.manager.update_and_stream(app.model)
self.signal_output.emit(' '.join(subproc.args) + '\n')
for output in subproc.stdout:
line = output.decode().strip()
if line:
self.signal_output.emit(line)
self.signal_finished.emit()
for output in subproc.stderr:
line = output.decode().strip()
if line:
error = True
self.signal_output.emit(line)
self.signal_output.emit('\n')
if error:
break
self.signal_finished.emit(not error)
class RefreshApps(QThread):

View File

@@ -373,10 +373,14 @@ class ManageWindow(QWidget):
self.thread_update.apps_to_update = to_update
self.thread_update.start()
def _finish_update_selected(self):
def _finish_update_selected(self, success: bool):
self.finish_action()
self._release_lock()
self.refresh()
if success:
self.refresh()
else:
self.checkbox_console.setChecked(True)
def _update_action_output(self, output: str):
self.textarea_output.appendPlainText(output)