mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-06 22:54:16 +02:00
[view] feature: new parameter '--suggestions' to force loading software suggestions after the initialization process
This commit is contained in:
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
|
|
||||||
## [0.10.3]
|
## [0.10.3]
|
||||||
|
|
||||||
|
### Features
|
||||||
|
- General
|
||||||
|
- new parameter `--suggestions`: forces loading software suggestions after the initialization process [#260](https://github.com/vinifmor/bauh/issues/260)
|
||||||
|
|
||||||
### Improvements
|
### Improvements
|
||||||
- General
|
- General
|
||||||
- preventing command injection through the search mechanism [#266](https://github.com/vinifmor/bauh/issues/266)
|
- preventing command injection through the search mechanism [#266](https://github.com/vinifmor/bauh/issues/266)
|
||||||
|
|||||||
@@ -398,6 +398,7 @@ You can change some application settings via environment variables or arguments
|
|||||||
- `--reset`: it cleans all configurations and cached data stored in the HOME directory.
|
- `--reset`: it cleans all configurations and cached data stored in the HOME directory.
|
||||||
- `--logs`: it enables logs (for debugging purposes).
|
- `--logs`: it enables logs (for debugging purposes).
|
||||||
- `--offline`: it assumes the internet connection is off.
|
- `--offline`: it assumes the internet connection is off.
|
||||||
|
- `--suggestions`: it forces loading software suggestions after the initialization process.
|
||||||
|
|
||||||
|
|
||||||
##### Configuration file (**~/.config/bauh/config.yml**)
|
##### Configuration file (**~/.config/bauh/config.yml**)
|
||||||
|
|||||||
@@ -53,6 +53,9 @@ def main(tray: bool = False):
|
|||||||
QCoreApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
|
QCoreApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
|
||||||
QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
|
QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
|
||||||
|
|
||||||
|
if bool(args.suggestions):
|
||||||
|
logger.info("Forcing loading software suggestions after the initialization process")
|
||||||
|
|
||||||
if tray or bool(args.tray):
|
if tray or bool(args.tray):
|
||||||
from bauh.tray import new_tray_icon
|
from bauh.tray import new_tray_icon
|
||||||
app, widget = new_tray_icon(app_config, logger)
|
app, widget = new_tray_icon(app_config, logger)
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ def read() -> Namespace:
|
|||||||
parser.add_argument('-v', '--version', action='version', version='%(prog)s {}'.format(__version__))
|
parser.add_argument('-v', '--version', action='version', version='%(prog)s {}'.format(__version__))
|
||||||
parser.add_argument('--logs', action="store_true", help='It activates {} logs.'.format(__app_name__))
|
parser.add_argument('--logs', action="store_true", help='It activates {} logs.'.format(__app_name__))
|
||||||
parser.add_argument('--offline', action="store_true", help='It assumes the internet connection is off')
|
parser.add_argument('--offline', action="store_true", help='It assumes the internet connection is off')
|
||||||
|
parser.add_argument('--suggestions', action="store_true",
|
||||||
|
help='It forces loading software suggestions after the initialization process')
|
||||||
|
|
||||||
exclusive_args = parser.add_mutually_exclusive_group()
|
exclusive_args = parser.add_mutually_exclusive_group()
|
||||||
exclusive_args.add_argument('--tray', action="store_true", help='If {} should be attached to the system tray.'.format(__app_name__))
|
exclusive_args.add_argument('--tray', action="store_true", help='If {} should be attached to the system tray.'.format(__app_name__))
|
||||||
|
|||||||
@@ -57,7 +57,8 @@ def new_manage_panel(app_args: Namespace, app_config: dict, logger: logging.Logg
|
|||||||
util.clean_app_files(managers)
|
util.clean_app_files(managers)
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
manager = GenericSoftwareManager(managers, context=context, config=app_config)
|
force_suggestions = bool(app_args.suggestions)
|
||||||
|
manager = GenericSoftwareManager(managers, context=context, config=app_config, force_suggestions=force_suggestions)
|
||||||
|
|
||||||
app = new_qt_application(app_config=app_config, logger=logger, quit_on_last_closed=True)
|
app = new_qt_application(app_config=app_config, logger=logger, quit_on_last_closed=True)
|
||||||
|
|
||||||
@@ -78,6 +79,7 @@ def new_manage_panel(app_args: Namespace, app_config: dict, logger: logging.Logg
|
|||||||
context=context,
|
context=context,
|
||||||
http_client=http_client,
|
http_client=http_client,
|
||||||
icon=util.get_default_icon()[1],
|
icon=util.get_default_icon()[1],
|
||||||
|
force_suggestions=force_suggestions,
|
||||||
logger=logger)
|
logger=logger)
|
||||||
|
|
||||||
prepare = PreparePanel(screen_size=screen_size,
|
prepare = PreparePanel(screen_size=screen_size,
|
||||||
@@ -85,7 +87,8 @@ def new_manage_panel(app_args: Namespace, app_config: dict, logger: logging.Logg
|
|||||||
manager=manager,
|
manager=manager,
|
||||||
i18n=i18n,
|
i18n=i18n,
|
||||||
manage_window=manage_window,
|
manage_window=manage_window,
|
||||||
app_config=app_config)
|
app_config=app_config,
|
||||||
|
force_suggestions=force_suggestions)
|
||||||
cache_cleaner.start()
|
cache_cleaner.start()
|
||||||
|
|
||||||
return app, prepare
|
return app, prepare
|
||||||
|
|||||||
@@ -39,7 +39,9 @@ class GenericUpgradeRequirements(UpgradeRequirements):
|
|||||||
|
|
||||||
class GenericSoftwareManager(SoftwareManager, SettingsController):
|
class GenericSoftwareManager(SoftwareManager, SettingsController):
|
||||||
|
|
||||||
def __init__(self, managers: List[SoftwareManager], context: ApplicationContext, config: dict):
|
def __init__(self, managers: List[SoftwareManager], context: ApplicationContext, config: dict,
|
||||||
|
force_suggestions: bool = False):
|
||||||
|
|
||||||
super(GenericSoftwareManager, self).__init__(context=context)
|
super(GenericSoftwareManager, self).__init__(context=context)
|
||||||
self.managers = managers
|
self.managers = managers
|
||||||
self.map = {t: m for m in self.managers for t in m.get_managed_types()}
|
self.map = {t: m for m in self.managers for t in m.get_managed_types()}
|
||||||
@@ -56,6 +58,7 @@ class GenericSoftwareManager(SoftwareManager, SettingsController):
|
|||||||
self.configman = CoreConfigManager()
|
self.configman = CoreConfigManager()
|
||||||
self._action_reset: Optional[CustomSoftwareAction] = None
|
self._action_reset: Optional[CustomSoftwareAction] = None
|
||||||
self._dynamic_extra_actions: Optional[Dict[CustomSoftwareAction, Callable[[dict], bool]]] = None
|
self._dynamic_extra_actions: Optional[Dict[CustomSoftwareAction, Callable[[dict], bool]]] = None
|
||||||
|
self.force_suggestions = force_suggestions
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def dynamic_extra_actions(self) -> Dict[CustomSoftwareAction, Callable[[dict], bool]]:
|
def dynamic_extra_actions(self) -> Dict[CustomSoftwareAction, Callable[[dict], bool]]:
|
||||||
@@ -488,11 +491,12 @@ class GenericSoftwareManager(SoftwareManager, SettingsController):
|
|||||||
suggestions.extend(man_sugs)
|
suggestions.extend(man_sugs)
|
||||||
|
|
||||||
def list_suggestions(self, limit: int, filter_installed: bool) -> List[PackageSuggestion]:
|
def list_suggestions(self, limit: int, filter_installed: bool) -> List[PackageSuggestion]:
|
||||||
if bool(self.config['suggestions']['enabled']):
|
if self.force_suggestions or bool(self.config['suggestions']['enabled']):
|
||||||
if self.managers and self.context.is_internet_available():
|
if self.managers and self.context.is_internet_available():
|
||||||
suggestions, threads = [], []
|
suggestions, threads = [], []
|
||||||
for man in self.managers:
|
for man in self.managers:
|
||||||
t = Thread(target=self._fill_suggestions, args=(suggestions, man, int(self.config['suggestions']['by_type']), filter_installed))
|
t = Thread(target=self._fill_suggestions,
|
||||||
|
args=(suggestions, man, int(self.config['suggestions']['by_type']), filter_installed))
|
||||||
t.start()
|
t.start()
|
||||||
threads.append(t)
|
threads.append(t)
|
||||||
|
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ class PreparePanel(QWidget, TaskManager):
|
|||||||
signal_password_response = pyqtSignal(bool, str)
|
signal_password_response = pyqtSignal(bool, str)
|
||||||
|
|
||||||
def __init__(self, context: ApplicationContext, manager: SoftwareManager, screen_size: QSize,
|
def __init__(self, context: ApplicationContext, manager: SoftwareManager, screen_size: QSize,
|
||||||
i18n: I18n, manage_window: QWidget, app_config: dict):
|
i18n: I18n, manage_window: QWidget, app_config: dict, force_suggestions: bool = False):
|
||||||
super(PreparePanel, self).__init__(flags=Qt.CustomizeWindowHint | Qt.WindowTitleHint)
|
super(PreparePanel, self).__init__(flags=Qt.CustomizeWindowHint | Qt.WindowTitleHint)
|
||||||
self.i18n = i18n
|
self.i18n = i18n
|
||||||
self.context = context
|
self.context = context
|
||||||
@@ -165,6 +165,7 @@ class PreparePanel(QWidget, TaskManager):
|
|||||||
self.ftasks = 0
|
self.ftasks = 0
|
||||||
self.started_at = None
|
self.started_at = None
|
||||||
self.self_close = False
|
self.self_close = False
|
||||||
|
self.force_suggestions = force_suggestions
|
||||||
|
|
||||||
self.prepare_thread = Prepare(self.context, manager, self.i18n)
|
self.prepare_thread = Prepare(self.context, manager, self.i18n)
|
||||||
self.prepare_thread.signal_register.connect(self.register_task)
|
self.prepare_thread.signal_register.connect(self.register_task)
|
||||||
@@ -438,7 +439,9 @@ class PreparePanel(QWidget, TaskManager):
|
|||||||
if self.isVisible():
|
if self.isVisible():
|
||||||
self.manage_window.show()
|
self.manage_window.show()
|
||||||
|
|
||||||
if self.app_config['boot']['load_apps']:
|
if self.force_suggestions:
|
||||||
|
self.manage_window.begin_load_suggestions(filter_installed=True)
|
||||||
|
elif self.app_config['boot']['load_apps']:
|
||||||
self.manage_window.begin_refresh_packages()
|
self.manage_window.begin_refresh_packages()
|
||||||
else:
|
else:
|
||||||
self.manage_window.load_without_packages()
|
self.manage_window.load_without_packages()
|
||||||
|
|||||||
@@ -97,7 +97,8 @@ class ManageWindow(QWidget):
|
|||||||
signal_stop_notifying = pyqtSignal()
|
signal_stop_notifying = pyqtSignal()
|
||||||
|
|
||||||
def __init__(self, i18n: I18n, icon_cache: MemoryCache, manager: SoftwareManager, screen_size: QSize, config: dict,
|
def __init__(self, i18n: I18n, icon_cache: MemoryCache, manager: SoftwareManager, screen_size: QSize, config: dict,
|
||||||
context: ApplicationContext, http_client: HttpClient, logger: logging.Logger, icon: QIcon):
|
context: ApplicationContext, http_client: HttpClient, logger: logging.Logger, icon: QIcon,
|
||||||
|
force_suggestions: bool = False):
|
||||||
super(ManageWindow, self).__init__()
|
super(ManageWindow, self).__init__()
|
||||||
self.setObjectName('manage_window')
|
self.setObjectName('manage_window')
|
||||||
self.comp_manager = QtComponentsManager()
|
self.comp_manager = QtComponentsManager()
|
||||||
@@ -375,8 +376,11 @@ class ManageWindow(QWidget):
|
|||||||
|
|
||||||
self.container_bottom.layout().addWidget(new_spacer())
|
self.container_bottom.layout().addWidget(new_spacer())
|
||||||
|
|
||||||
if config['suggestions']['enabled']:
|
self.load_suggestions = force_suggestions or bool(config['suggestions']['enabled'])
|
||||||
bt_sugs = IconButton(action=lambda: self._begin_load_suggestions(filter_installed=True),
|
self.suggestions_requested = False
|
||||||
|
|
||||||
|
if self.load_suggestions:
|
||||||
|
bt_sugs = IconButton(action=lambda: self.begin_load_suggestions(filter_installed=True),
|
||||||
i18n=i18n,
|
i18n=i18n,
|
||||||
tooltip=self.i18n['manage_window.bt.suggestions.tooltip'])
|
tooltip=self.i18n['manage_window.bt.suggestions.tooltip'])
|
||||||
bt_sugs.setObjectName('suggestions')
|
bt_sugs.setObjectName('suggestions')
|
||||||
@@ -442,8 +446,6 @@ class ManageWindow(QWidget):
|
|||||||
self.types_changed = False
|
self.types_changed = False
|
||||||
|
|
||||||
self.dialog_about = None
|
self.dialog_about = None
|
||||||
self.load_suggestions = bool(config['suggestions']['enabled'])
|
|
||||||
self.suggestions_requested = False
|
|
||||||
self.first_refresh = True
|
self.first_refresh = True
|
||||||
|
|
||||||
self.thread_warnings = ListWarnings(man=manager, i18n=i18n)
|
self.thread_warnings = ListWarnings(man=manager, i18n=i18n)
|
||||||
@@ -739,7 +741,7 @@ class ManageWindow(QWidget):
|
|||||||
self._handle_console_option(False)
|
self._handle_console_option(False)
|
||||||
self._finish_refresh_packages({'installed': None, 'types': None}, as_installed=False)
|
self._finish_refresh_packages({'installed': None, 'types': None}, as_installed=False)
|
||||||
|
|
||||||
def _begin_load_suggestions(self, filter_installed: bool):
|
def begin_load_suggestions(self, filter_installed: bool):
|
||||||
self.search_bar.clear()
|
self.search_bar.clear()
|
||||||
self._begin_action(self.i18n['manage_window.status.suggestions'])
|
self._begin_action(self.i18n['manage_window.status.suggestions'])
|
||||||
self._handle_console_option(False)
|
self._handle_console_option(False)
|
||||||
@@ -972,7 +974,7 @@ class ManageWindow(QWidget):
|
|||||||
if as_installed:
|
if as_installed:
|
||||||
self.pkgs_installed = pkgs_info['pkgs']
|
self.pkgs_installed = pkgs_info['pkgs']
|
||||||
|
|
||||||
self._begin_load_suggestions(filter_installed=False)
|
self.begin_load_suggestions(filter_installed=False)
|
||||||
self.load_suggestions = False
|
self.load_suggestions = False
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user