Exemple #1
0
    def _search(self, word: str, is_url: bool, man: SoftwareManager, disk_loader, res: SearchResult):
        if self._can_work(man):
            mti = time.time()
            apps_found = man.search(words=word, disk_loader=disk_loader, is_url=is_url)
            mtf = time.time()
            self.logger.info(man.__class__.__name__ + " took {0:.2f} seconds".format(mtf - mti))

            res.installed.extend(apps_found.installed)
            res.new.extend(apps_found.new)
Exemple #2
0
    def _fill_suggestions(self, suggestions: list, man: SoftwareManager, limit: int, filter_installed: bool):
        if self._can_work(man):
            mti = time.time()
            man_sugs = man.list_suggestions(limit=limit, filter_installed=filter_installed)
            mtf = time.time()
            self.logger.info(man.__class__.__name__ + ' took {0:.2f} seconds'.format(mtf - mti))

            if man_sugs:
                if 0 < limit < len(man_sugs):
                    man_sugs = man_sugs[0:limit]

                suggestions.extend(man_sugs)
Exemple #3
0
    def _search(self, word: str, is_url: bool, man: SoftwareManager,
                disk_loader, res: SearchResult):
        if self._can_work(man):
            mti = time.time()
            apps_found = man.search(words=word,
                                    disk_loader=disk_loader,
                                    is_url=is_url,
                                    limit=-1)
            mtf = time.time()
            self.logger.info(
                f'{man.__class__.__name__} took {mtf - mti:.8f} seconds')

            res.installed.extend(apps_found.installed)
            res.new.extend(apps_found.new)
Exemple #4
0
    def _can_work(self, man: SoftwareManager):
        if self._available_cache is not None:
            available = False
            for t in man.get_managed_types():
                available = self._available_cache.get(t)

                if available is None:
                    available = man.is_enabled() and man.can_work()[0]
                    self._available_cache[t] = available

                if available:
                    available = True
        else:
            available = man.is_enabled() and man.can_work()[0]

        if available:
            if man not in self.working_managers:
                self.working_managers.append(man)
        else:
            if man in self.working_managers:
                self.working_managers.remove(man)

        return available
Exemple #5
0
    def _save_manager_settings(self, man: SoftwareManager,
                               panel: ViewComponent, success_map: Dict[str,
                                                                       bool],
                               warnings: List[str]):
        success = False

        try:
            res = man.save_settings(panel)

            if res:
                success, errors = res[0], res[1]

                if errors:
                    warnings.extend(errors)
        except:
            self.logger.error(
                "An exception happened while {} was trying to save its settings"
                .format(man.__class__.__name__))
            traceback.print_exc()
        finally:
            success_map[man.__class__.__name__] = success
Exemple #6
0
 def _fill_sizes(self, man: SoftwareManager, pkgs: List[SoftwarePackage]):
     ti = time.time()
     man.fill_sizes(pkgs)
     tf = time.time()
     self.logger.info(man.__class__.__name__ +
                      " took {0:.2f} seconds".format(tf - ti))
Exemple #7
0
 def _fill_sizes(self, man: SoftwareManager, pkgs: List[SoftwarePackage]):
     ti = time.time()
     man.fill_sizes(pkgs)
     tf = time.time()
     self.logger.info(
         f'{man.__class__.__name__} took {tf - ti:.2f} seconds')