diff --git a/CHANGELOG.md b/CHANGELOG.md index f78b5170..add81edd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Package "Name" filter field ( above the packages table ) - Showing the number of packages being shown by the total found in the right lower corner - **Show button** for large fields in the **Info** window +- New environment variables / parameters: BAUH_MAX_DISPLAYED and BAUH_LOGS + ### Improvements: - Reading installed Snaps now takes around 95% less time diff --git a/README.md b/README.md index 332b7c3d..bbd753f2 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,7 @@ You can change some application settings via environment variables or arguments - **BAUH_TRAY**: If the tray icon and update-check daemon should be created. Use **0** (disable, default) or **1** (enable). - **BAUH_SUGGESTIONS**: If application suggestions should be displayed if no packaged considered as an application is installed (runtimes / libraries do not count as applications). Use **0** (disable) or **1** (enable, default). - **BAUH_MAX_DISPLAYED**: Maximum number of displayed packages in the management panel table. Default: 50. +- **BAUH_LOGS**: enable **bauh** logs (for debugging purposes). Use: **0** (disable, default) or **1** (enable) The application settings are stored in **/home/$USER/.config/bauh/config.json** diff --git a/bauh/api/abstract/controller.py b/bauh/api/abstract/controller.py index f99c5d00..cdaee2bb 100644 --- a/bauh/api/abstract/controller.py +++ b/bauh/api/abstract/controller.py @@ -160,7 +160,7 @@ class SoftwareManager(ABC): :param only_icon: if only the icon should be saved :return: """ - if pkg.supports_disk_cache(): + if self.context.disk_cache and pkg.supports_disk_cache(): if not only_icon: Path(pkg.get_disk_cache_path()).mkdir(parents=True, exist_ok=True) diff --git a/bauh/gems/arch/controller.py b/bauh/gems/arch/controller.py index 3494804e..09610e21 100644 --- a/bauh/gems/arch/controller.py +++ b/bauh/gems/arch/controller.py @@ -39,7 +39,7 @@ class ArchManager(SoftwareManager): self.aur_client = AURClient(context.http_client) self.names_index = {} self.aur_index_updater = AURIndexUpdater(context, self) - self.dcache_updater = ArchDiskCacheUpdater(context.logger) + self.dcache_updater = ArchDiskCacheUpdater(context.logger, context.disk_cache) self.logger = context.logger self.enabled = True self.arch_distro = self.context.linux_distro[0].lower() == 'arch' @@ -467,7 +467,9 @@ class ArchManager(SoftwareManager): if installed and self.context.disk_cache: handler.watcher.change_substatus(self.i18n['status.caching_data'].format(bold(pkgname))) - disk.save_several({pkgname}, mirror) + if self.context.disk_cache: + disk.save_several({pkgname}, mirror) + self._update_progress(handler.watcher, 100, change_progress) return installed diff --git a/bauh/gems/arch/resources/locale/en b/bauh/gems/arch/resources/locale/en index d35cae46..a925b205 100644 --- a/bauh/gems/arch/resources/locale/en +++ b/bauh/gems/arch/resources/locale/en @@ -1,4 +1,4 @@ -gem.arch.label=Arch ( AUR ) +gem.arch.label=AUR gem.arch.info=AUR packages are maintained by an independent user community. There is no warranty that they will work or not harm you system. arch.install.conflict.popup.title=Conflict detected arch.install.conflict.popup.body=The applications {} are in conflict. You must uninstall one to install the other. Continue ? diff --git a/bauh/gems/arch/resources/locale/es b/bauh/gems/arch/resources/locale/es index a961d463..b4e81370 100644 --- a/bauh/gems/arch/resources/locale/es +++ b/bauh/gems/arch/resources/locale/es @@ -1,4 +1,4 @@ -gem.arch.label=Arch ( AUR ) +gem.arch.label=AUR gem.arch.info=Los paquetes AUR son mantenidos por una comunidad de usuarios independiente. No hay garantía de que funcionen o que no dañen su sistema. aur.info.architecture=arquitectura aur.info.architecture.any=cualquier diff --git a/bauh/gems/arch/resources/locale/pt b/bauh/gems/arch/resources/locale/pt index 59d9c91e..803fc61c 100644 --- a/bauh/gems/arch/resources/locale/pt +++ b/bauh/gems/arch/resources/locale/pt @@ -1,4 +1,4 @@ -gem.arch.label=Arch ( AUR ) +gem.arch.label=AUR gem.arch.info=Pacotes do AUR são mantidos por uma comunidade de usuários independente. Não há garantia que funcionarão ou que não prejudicarão o seus sistema. aur.info.architecture=arquitetura aur.info.architecture.any=qualquer diff --git a/bauh/gems/arch/worker.py b/bauh/gems/arch/worker.py index 88cd0622..1b6e5d80 100644 --- a/bauh/gems/arch/worker.py +++ b/bauh/gems/arch/worker.py @@ -37,16 +37,18 @@ class AURIndexUpdater(Thread): class ArchDiskCacheUpdater(Thread if bool(os.getenv('BAUH_DEBUG', 0)) else Process): - def __init__(self, logger: logging.Logger): + def __init__(self, logger: logging.Logger, disk_cache: bool): super(ArchDiskCacheUpdater, self).__init__(daemon=True) self.logger = logger + self.disk_cache = disk_cache def run(self): - self.logger.info('Pre-caching installed AUR packages data to disk') - installed = pacman.list_and_map_installed() + if self.disk_cache: + self.logger.info('Pre-caching installed AUR packages data to disk') + installed = pacman.list_and_map_installed() - saved = 0 - if installed and installed['not_signed']: - saved = disk.save_several({app for app in installed['not_signed']}, 'aur', overwrite=False) + saved = 0 + if installed and installed['not_signed']: + saved = disk.save_several({app for app in installed['not_signed']}, 'aur', overwrite=False) - self.logger.info('Pre-cached data of {} AUR packages to the disk'.format(saved)) + self.logger.info('Pre-cached data of {} AUR packages to the disk'.format(saved)) diff --git a/bauh/gems/snap/controller.py b/bauh/gems/snap/controller.py index 2af18e6e..9f56226f 100644 --- a/bauh/gems/snap/controller.py +++ b/bauh/gems/snap/controller.py @@ -175,4 +175,4 @@ class SnapManager(SoftwareManager): return True def launch(self, pkg: SnapApplication): - snap.run(pkg) + snap.run(pkg, self.context.logger) diff --git a/bauh/gems/snap/snap.py b/bauh/gems/snap/snap.py index 8f18d451..af7c7dea 100644 --- a/bauh/gems/snap/snap.py +++ b/bauh/gems/snap/snap.py @@ -1,3 +1,4 @@ +import logging import re import subprocess import time @@ -155,9 +156,36 @@ def refresh_and_stream(app_name: str, root_password: str) -> subprocess.Popen: return new_root_subprocess([BASE_CMD, 'refresh', app_name], root_password) -def run(app: SnapApplication): +def run(app: SnapApplication, logger: logging.Logger): info = get_info(app.name, 'commands') + app_name = app.name.lower() if info.get('commands'): - subprocess.Popen([BASE_CMD, 'run', info['commands'][0]]) + + logger.info('Available commands found for {}: {}'.format(app_name, info['commands'])) + + commands = [c.strip() for c in info['commands']] + + # trying to find an exact match command: + command = None + + for c in commands: + if c.lower() == app_name: + command = c + logger.info("Found exact match command for '{}'".format(app_name)) + break + + if not command: + for c in command: + if not c.endswith('.apm'): + command = c + + if command: + logger.info("Running '{}'".format(command)) + subprocess.Popen([BASE_CMD, 'run', command]) + return + + logger.error("No valid command found for '{}'".format(app_name)) + else: + logger.error("No command found for '{}'".format(app_name)) diff --git a/bauh/view/core/controller.py b/bauh/view/core/controller.py index b0d87b6b..a6e5f3fc 100755 --- a/bauh/view/core/controller.py +++ b/bauh/view/core/controller.py @@ -336,4 +336,5 @@ class GenericSoftwareManager(SoftwareManager): man = self._get_manager_for(pkg) if man: + self.logger.info('Launching {}'.format(pkg)) man.launch(pkg)