mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-09 14:24:16 +02:00
[improvement][arch] unifying the process output when upgrading several repo packages to prevent wrong error returns
This commit is contained in:
@@ -157,18 +157,22 @@ class ProcessHandler:
|
|||||||
|
|
||||||
return process.subproc.returncode is None or process.subproc.returncode == 0
|
return process.subproc.returncode is None or process.subproc.returncode == 0
|
||||||
|
|
||||||
def handle_simple(self, proc: SimpleProcess) -> Tuple[bool, str]:
|
def handle_simple(self, proc: SimpleProcess, output_handler=None) -> Tuple[bool, str]:
|
||||||
self._notify_watcher(' '.join(proc.instance.args) + '\n')
|
self._notify_watcher(' '.join(proc.instance.args) + '\n')
|
||||||
|
|
||||||
output = StringIO()
|
output = StringIO()
|
||||||
for o in proc.instance.stdout:
|
for o in proc.instance.stdout:
|
||||||
if o:
|
if o:
|
||||||
line = o.decode()
|
line = o.decode()
|
||||||
|
|
||||||
output.write(line)
|
output.write(line)
|
||||||
|
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
|
|
||||||
if line:
|
if line:
|
||||||
|
if output_handler:
|
||||||
|
output_handler(line)
|
||||||
|
|
||||||
self._notify_watcher(line)
|
self._notify_watcher(line)
|
||||||
|
|
||||||
output.seek(0)
|
output.seek(0)
|
||||||
|
|||||||
@@ -728,7 +728,7 @@ class ArchManager(SoftwareManager):
|
|||||||
try:
|
try:
|
||||||
output_handler = TransactionStatusHandler(watcher, self.i18n, len(repo_pkgs_names), self.logger)
|
output_handler = TransactionStatusHandler(watcher, self.i18n, len(repo_pkgs_names), self.logger)
|
||||||
output_handler.start()
|
output_handler.start()
|
||||||
success = handler.handle(pacman.upgrade_several(repo_pkgs_names, root_password), output_handler=output_handler.handle)
|
success = handler.handle_simple(pacman.upgrade_several(repo_pkgs_names, root_password), output_handler=output_handler.handle)
|
||||||
output_handler.stop_working()
|
output_handler.stop_working()
|
||||||
output_handler.join()
|
output_handler.join()
|
||||||
|
|
||||||
@@ -741,7 +741,7 @@ class ArchManager(SoftwareManager):
|
|||||||
disk.save_several(repo_pkgs_names, repo_map=repo_map, overwrite=True, maintainer=None)
|
disk.save_several(repo_pkgs_names, repo_map=repo_map, overwrite=True, maintainer=None)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.logger.error("An error occurred while upgrading repository packages")
|
self.logger.error("'pacman' returned an unexpected response after upgrading the repository packages")
|
||||||
return False
|
return False
|
||||||
except:
|
except:
|
||||||
watcher.change_substatus('')
|
watcher.change_substatus('')
|
||||||
|
|||||||
@@ -691,12 +691,8 @@ def list_installed_names() -> Set[str]:
|
|||||||
return {p for p in run_cmd('pacman -Qq').split('\n') if p}
|
return {p for p in run_cmd('pacman -Qq').split('\n') if p}
|
||||||
|
|
||||||
|
|
||||||
def upgrade_several(pkgnames: Iterable[str], root_password: str) -> SystemProcess:
|
def upgrade_several(pkgnames: Iterable[str], root_password: str) -> SimpleProcess:
|
||||||
cmd = ['pacman', '-S', *pkgnames, '--noconfirm']
|
return SimpleProcess(cmd=['pacman', '-S', *pkgnames, '--noconfirm'], root_password=root_password)
|
||||||
if root_password:
|
|
||||||
return SystemProcess(new_root_subprocess(cmd, root_password), wrong_error_phrase='warning:')
|
|
||||||
else:
|
|
||||||
return SystemProcess(new_subprocess(cmd), wrong_error_phrase='warning:')
|
|
||||||
|
|
||||||
|
|
||||||
def remove_several(pkgnames: Iterable[str], root_password: str) -> SystemProcess:
|
def remove_several(pkgnames: Iterable[str], root_password: str) -> SystemProcess:
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ class PreparePanel(QWidget, TaskManager):
|
|||||||
lb_icon.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred)
|
lb_icon.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred)
|
||||||
|
|
||||||
if icon_path:
|
if icon_path:
|
||||||
lb_icon.setPixmap(QIcon(icon_path).pixmap(12, 12))
|
lb_icon.setPixmap(QIcon(icon_path).pixmap(14, 14))
|
||||||
|
|
||||||
self.table.setCellWidget(task_row, 0, lb_icon)
|
self.table.setCellWidget(task_row, 0, lb_icon)
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ from bauh.commons.system import new_subprocess
|
|||||||
from bauh.view.core.config import read_config
|
from bauh.view.core.config import read_config
|
||||||
from bauh.view.qt.dialog import show_message
|
from bauh.view.qt.dialog import show_message
|
||||||
from bauh.view.qt.view_utils import load_resource_icon
|
from bauh.view.qt.view_utils import load_resource_icon
|
||||||
|
from bauh.view.util import util
|
||||||
from bauh.view.util.translation import I18n
|
from bauh.view.util.translation import I18n
|
||||||
|
|
||||||
|
|
||||||
@@ -28,7 +29,7 @@ def ask_root_password(context: ApplicationContext, i18n: I18n, app_config: dict
|
|||||||
diag.setStyleSheet("""QLineEdit { border-radius: 5px; font-size: 16px; border: 1px solid lightblue }""")
|
diag.setStyleSheet("""QLineEdit { border-radius: 5px; font-size: 16px; border: 1px solid lightblue }""")
|
||||||
diag.setInputMode(QInputDialog.TextInput)
|
diag.setInputMode(QInputDialog.TextInput)
|
||||||
diag.setTextEchoMode(QLineEdit.Password)
|
diag.setTextEchoMode(QLineEdit.Password)
|
||||||
diag.setWindowIcon(load_resource_icon('img/lock.svg', 20, 24))
|
diag.setWindowIcon(util.get_default_icon()[1])
|
||||||
diag.setWindowTitle(i18n['popup.root.title'])
|
diag.setWindowTitle(i18n['popup.root.title'])
|
||||||
diag.setLabelText('')
|
diag.setLabelText('')
|
||||||
diag.setOkButtonText(i18n['popup.root.continue'].capitalize())
|
diag.setOkButtonText(i18n['popup.root.continue'].capitalize())
|
||||||
|
|||||||
Reference in New Issue
Block a user