mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-08 01:34:15 +02:00
improving boot speed | refactoring
This commit is contained in:
@@ -31,7 +31,9 @@ icon_cache = Cache(expiration_time=args.icon_exp)
|
||||
caches.append(icon_cache)
|
||||
|
||||
disk_loader_factory = DiskCacheLoaderFactory(disk_cache=args.disk_cache, cache_map=cache_map)
|
||||
|
||||
manager = GenericApplicationManager(managers, disk_loader_factory=disk_loader_factory, app_args=args)
|
||||
manager.prepare()
|
||||
|
||||
app = QApplication(sys.argv)
|
||||
app.setApplicationName(__app_name__)
|
||||
@@ -65,5 +67,4 @@ if warnings:
|
||||
dialog.show_warning(title=locale_keys['warning'].capitalize(), body=warning)
|
||||
|
||||
CacheCleaner(caches).start()
|
||||
|
||||
sys.exit(app.exec_())
|
||||
|
||||
@@ -18,7 +18,6 @@ class GenericApplicationManager(ApplicationManager):
|
||||
self.map = {m.get_app_type(): m for m in self.managers}
|
||||
self.disk_loader_factory = disk_loader_factory
|
||||
self._enabled_map = {} if app_args.check_packaging_once else None
|
||||
self.prepare()
|
||||
|
||||
def _sort(self, apps: List[Application], word: str) -> List[Application]:
|
||||
|
||||
|
||||
@@ -2,8 +2,9 @@ import inspect
|
||||
import os
|
||||
import pkgutil
|
||||
from argparse import Namespace
|
||||
from typing import Set, List, Dict
|
||||
from typing import List, Dict
|
||||
|
||||
from fpakman_api.abstract.controller import ApplicationManager
|
||||
from fpakman_api.util.cache import Cache
|
||||
|
||||
from fpakman import ROOT_DIR
|
||||
@@ -12,7 +13,7 @@ from fpakman.util import util
|
||||
ignore_modules = {'fpakman_api'}
|
||||
|
||||
|
||||
def find_manager(member, ):
|
||||
def find_manager(member):
|
||||
if inspect.isclass(member) and inspect.getmro(member)[1].__name__ == 'ApplicationManager':
|
||||
return member
|
||||
elif inspect.ismodule(member) and member.__name__ not in ignore_modules:
|
||||
@@ -22,16 +23,16 @@ def find_manager(member, ):
|
||||
return manager_found
|
||||
|
||||
|
||||
def load_managers(caches: List[Cache], cache_map: Dict[type, Cache], locale_keys: Dict[str, str], app_args: Namespace, http_session):
|
||||
def load_managers(caches: List[Cache], cache_map: Dict[type, Cache], locale_keys: Dict[str, str], app_args: Namespace, http_session) -> List[ApplicationManager]:
|
||||
managers = None
|
||||
|
||||
for m in pkgutil.iter_modules():
|
||||
if m.ispkg and m.name and m.name not in ignore_modules and m.name.startswith('fpakman_'):
|
||||
module = pkgutil.find_loader(m.name).load_module()
|
||||
|
||||
manager = find_manager(module)
|
||||
manager_class = find_manager(module)
|
||||
|
||||
if manager:
|
||||
if manager_class:
|
||||
locale_path = '{}/resources/locale'.format(module.__path__[0])
|
||||
|
||||
if os.path.exists(locale_path):
|
||||
@@ -41,11 +42,11 @@ def load_managers(caches: List[Cache], cache_map: Dict[type, Cache], locale_keys
|
||||
managers = []
|
||||
|
||||
app_cache = Cache(expiration_time=app_args.cache_exp)
|
||||
man = manager(app_args=app_args,
|
||||
fpakman_root_dir=ROOT_DIR,
|
||||
http_session=http_session,
|
||||
locale_keys=locale_keys,
|
||||
app_cache=app_cache)
|
||||
man = manager_class(app_args=app_args,
|
||||
fpakman_root_dir=ROOT_DIR,
|
||||
http_session=http_session,
|
||||
locale_keys=locale_keys,
|
||||
app_cache=app_cache)
|
||||
cache_map[man.get_app_type()] = app_cache
|
||||
caches.append(app_cache)
|
||||
managers.append(man)
|
||||
|
||||
Reference in New Issue
Block a user