mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 18:34:16 +02:00
[fix][arch] not displaying 'removing' substatus during the upgrade process
This commit is contained in:
@@ -34,6 +34,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
- Arch
|
||||
- uninstall: not checking if the are other installed providers for the target package
|
||||
- not recursively asking for dependencies providers when installing / upgrading
|
||||
- not displaying "removing" substatus during the upgrade process
|
||||
- UI
|
||||
- table overwrite effect when updating its content
|
||||
|
||||
|
||||
@@ -851,15 +851,25 @@ class ArchManager(SoftwareManager):
|
||||
|
||||
if requirements.to_remove:
|
||||
to_remove_names = {r.pkg.name for r in requirements.to_remove}
|
||||
output_handler = TransactionStatusHandler(watcher=handler.watcher,
|
||||
i18n=self.i18n,
|
||||
pkgs_to_sync=0,
|
||||
logger=self.logger,
|
||||
pkgs_to_remove=len(to_remove_names))
|
||||
output_handler.start()
|
||||
try:
|
||||
success = handler.handle(pacman.remove_several(to_remove_names, root_password))
|
||||
success = handler.handle(pacman.remove_several(to_remove_names, root_password), output_handler=output_handler.handle)
|
||||
|
||||
if not success:
|
||||
self.logger.error("Could not remove packages: {}".format(', '.join(to_remove_names)))
|
||||
output_handler.stop_working()
|
||||
output_handler.join()
|
||||
return False
|
||||
except:
|
||||
self.logger.error("An error occured while removing packages: {}".format(', '.join(to_remove_names)))
|
||||
traceback.print_exc()
|
||||
output_handler.stop_working()
|
||||
output_handler.join()
|
||||
return False
|
||||
|
||||
if repo_pkgs:
|
||||
@@ -1305,7 +1315,7 @@ class ArchManager(SoftwareManager):
|
||||
|
||||
return True
|
||||
|
||||
def _install_deps(self, context: TransactionContext, deps: List[Tuple[str, str]]) -> Iterable[str]:
|
||||
def _install_deps(self, context: TransactionContext, deps: List[Tuple[str, str]]) -> Iterable[str]:
|
||||
"""
|
||||
:param pkgs_repos:
|
||||
:param root_password:
|
||||
@@ -1355,7 +1365,7 @@ class ArchManager(SoftwareManager):
|
||||
except ArchDownloadException:
|
||||
return False
|
||||
|
||||
status_handler = TransactionStatusHandler(watcher=context.watcher, i18n=self.i18n, npkgs=len(repo_dep_names),
|
||||
status_handler = TransactionStatusHandler(watcher=context.watcher, i18n=self.i18n, pkgs_to_sync=len(repo_dep_names),
|
||||
logger=self.logger, percentage=len(repo_deps) > 1, downloading=downloaded)
|
||||
status_handler.start()
|
||||
installed, _ = context.handler.handle_simple(pacman.install_as_process(pkgpaths=repo_dep_names,
|
||||
|
||||
@@ -9,15 +9,17 @@ from bauh.view.util.translation import I18n
|
||||
|
||||
class TransactionStatusHandler(Thread):
|
||||
|
||||
def __init__(self, watcher: ProcessWatcher, i18n: I18n, npkgs: int, logger: logging.Logger,
|
||||
percentage: bool = True, downloading: int = 0):
|
||||
def __init__(self, watcher: ProcessWatcher, i18n: I18n, pkgs_to_sync: int, logger: logging.Logger,
|
||||
percentage: bool = True, downloading: int = 0, pkgs_to_remove: int = 0):
|
||||
super(TransactionStatusHandler, self).__init__(daemon=True)
|
||||
self.watcher = watcher
|
||||
self.i18n = i18n
|
||||
self.npkgs = npkgs
|
||||
self.pkgs_to_sync = pkgs_to_sync
|
||||
self.pkgs_to_remove = pkgs_to_remove
|
||||
self.downloading = downloading
|
||||
self.upgrading = 0
|
||||
self.installing = 0
|
||||
self.removing = 0
|
||||
self.outputs = []
|
||||
self.work = True
|
||||
self.logger = logger
|
||||
@@ -32,7 +34,7 @@ class TransactionStatusHandler(Thread):
|
||||
def gen_percentage(self) -> str:
|
||||
if self.percentage:
|
||||
performed = self.downloading + self.upgrading + self.installing
|
||||
return '({0:.2f}%) '.format((performed / (2 * self.npkgs)) * 100)
|
||||
return '({0:.2f}%) '.format((performed / (2 * self.pkgs_to_sync)) * 100)
|
||||
else:
|
||||
return ''
|
||||
|
||||
@@ -41,32 +43,42 @@ class TransactionStatusHandler(Thread):
|
||||
|
||||
def _handle(self, output: str) -> bool:
|
||||
if output:
|
||||
if output.startswith('removing'):
|
||||
if self.pkgs_to_remove > 0:
|
||||
self.removing += 1
|
||||
|
||||
self.watcher.change_substatus(
|
||||
'[{}/{}] {} {}'.format(self.removing, self.pkgs_to_remove,
|
||||
self.i18n['uninstalling'].capitalize(), output.split(' ')[1].strip()))
|
||||
else:
|
||||
self.watcher.change_substatus('{} {}'.format(self.i18n['uninstalling'].capitalize(), output.split(' ')[1].strip()))
|
||||
|
||||
if output.startswith('downloading'):
|
||||
if self.downloading < self.npkgs:
|
||||
if self.downloading < self.pkgs_to_sync:
|
||||
perc = self.gen_percentage()
|
||||
self.downloading += 1
|
||||
|
||||
self.watcher.change_substatus('{}[{}/{}] {} {} {}'.format(perc, self.downloading, self.npkgs, bold('[pacman]'),
|
||||
self.watcher.change_substatus('{}[{}/{}] {} {} {}'.format(perc, self.downloading, self.pkgs_to_sync, bold('[pacman]'),
|
||||
self.i18n['downloading'].capitalize(), output.split(' ')[1].strip()))
|
||||
elif output.startswith('upgrading'):
|
||||
if self.get_performed() < self.npkgs:
|
||||
if self.get_performed() < self.pkgs_to_sync:
|
||||
perc = self.gen_percentage()
|
||||
self.upgrading += 1
|
||||
|
||||
performed = self.upgrading + self.installing
|
||||
|
||||
if performed <= self.npkgs:
|
||||
self.watcher.change_substatus('{}[{}/{}] {} {}'.format(perc, self.upgrading, self.npkgs,
|
||||
if performed <= self.pkgs_to_sync:
|
||||
self.watcher.change_substatus('{}[{}/{}] {} {}'.format(perc, self.upgrading, self.pkgs_to_sync,
|
||||
self.i18n['manage_window.status.upgrading'].capitalize(), output.split(' ')[1].strip()))
|
||||
elif output.startswith('installing'):
|
||||
if self.get_performed() < self.npkgs:
|
||||
if self.get_performed() < self.pkgs_to_sync:
|
||||
perc = self.gen_percentage()
|
||||
self.installing += 1
|
||||
|
||||
performed = self.upgrading + self.installing
|
||||
|
||||
if performed <= self.npkgs:
|
||||
self.watcher.change_substatus('{}[{}/{}] {} {}'.format(perc, self.installing, self.npkgs,
|
||||
if performed <= self.pkgs_to_sync:
|
||||
self.watcher.change_substatus('{}[{}/{}] {} {}'.format(perc, self.installing, self.pkgs_to_sync,
|
||||
self.i18n['manage_window.status.installing'].capitalize(),
|
||||
output.split(' ')[1].strip()))
|
||||
else:
|
||||
@@ -83,7 +95,7 @@ class TransactionStatusHandler(Thread):
|
||||
|
||||
if performed == 0 and self.downloading > 0:
|
||||
self.watcher.change_substatus('')
|
||||
elif performed == self.npkgs:
|
||||
elif performed == self.pkgs_to_sync:
|
||||
self.watcher.change_substatus(self.i18n['finishing'].capitalize())
|
||||
return False
|
||||
|
||||
|
||||
@@ -385,6 +385,7 @@ task.download_categories=Download de categories [ {} ]
|
||||
type=tipus
|
||||
uninstall=desinstal·la
|
||||
uninstalled=desinstal·lada
|
||||
uninstalling=uninstalling
|
||||
unknown=desconegut
|
||||
updates=actualitzacions
|
||||
user=usuari
|
||||
|
||||
@@ -384,6 +384,7 @@ task.download_categories=Downloading categories [ {} ]
|
||||
type=Typ
|
||||
uninstall=Deinstallation
|
||||
uninstalled=deinstalliert
|
||||
uninstalling=uninstalling
|
||||
unknown=unbekannt
|
||||
updates=Updates
|
||||
user=Benutzer
|
||||
|
||||
@@ -384,6 +384,7 @@ task.download_categories=Downloading categories [ {} ]
|
||||
type=type
|
||||
uninstall=uninstall
|
||||
uninstalled=uninstalled
|
||||
uninstalling=uninstalling
|
||||
unknown=unknown
|
||||
updates=updates
|
||||
user=user
|
||||
|
||||
@@ -363,6 +363,7 @@ prepare_panel.title.start=Inicializando
|
||||
proceed=continuar
|
||||
publisher=publicador
|
||||
publisher.verified=verificado
|
||||
removing=removing
|
||||
repository=repositorio
|
||||
screenshots.bt_back.label=anterior
|
||||
screenshots.bt_next.label=siguiente
|
||||
@@ -385,6 +386,7 @@ task.download_categories=Descargando categorías [ {} ]
|
||||
type=tipo
|
||||
uninstall=desinstalar
|
||||
uninstalled=desinstalada
|
||||
uninstalling=desinstalando
|
||||
unknown=desconocido
|
||||
updates=actualizaciones
|
||||
user=usuario
|
||||
|
||||
@@ -387,6 +387,7 @@ task.download_categories=Download delle categorie [ {} ]
|
||||
type=tipe
|
||||
uninstall=Disinstalla
|
||||
uninstalled=disinstallato
|
||||
uninstalling=uninstalling
|
||||
unknown=sconosciuto
|
||||
updates=aggiornamenti
|
||||
user=utente
|
||||
|
||||
@@ -384,6 +384,7 @@ task.download_categories=Baixando categorias [ {} ]
|
||||
type=tipo
|
||||
uninstall=desinstalar
|
||||
uninstalled=desinstalado
|
||||
uninstalling=desinstalando
|
||||
unknown=desconhecido
|
||||
updates=atualizações
|
||||
user=usuário
|
||||
|
||||
@@ -384,6 +384,7 @@ task.download_categories=Downloading categories [ {} ]
|
||||
type=Тип
|
||||
uninstall=Деинсталляция
|
||||
uninstalled=Деинсталлировано
|
||||
uninstalling=uninstalling
|
||||
unknown=неизвестный
|
||||
updates=Обновления
|
||||
user=Пользователь
|
||||
|
||||
@@ -384,6 +384,7 @@ task.download_categories=Kategoriler indiriliyor [ {} ]
|
||||
type=tür
|
||||
uninstall=kaldır
|
||||
uninstalled=kaldırıldı
|
||||
uninstalling=uninstalling
|
||||
unknown=bilinmeyen
|
||||
updates=güncellemeler
|
||||
user=kullanıcı
|
||||
|
||||
Reference in New Issue
Block a user