diff --git a/CHANGELOG.md b/CHANGELOG.md index 89dea989..0e3d0c47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Improvements - All icons are now SVG files +### Fixes +- not verifying if an icon path is a file +- Web: + - not handling HTTP connection issues + ## [0.8.0] 2019-12-24 ### Features - Native Web applications support: diff --git a/bauh/gems/web/controller.py b/bauh/gems/web/controller.py index 435e0570..ccf338e3 100644 --- a/bauh/gems/web/controller.py +++ b/bauh/gems/web/controller.py @@ -11,6 +11,7 @@ from typing import List, Type, Set, Tuple import yaml from colorama import Fore +from requests import exceptions from bauh.api.abstract.context import ApplicationContext from bauh.api.abstract.controller import SoftwareManager, SearchResult @@ -136,10 +137,14 @@ class WebApplicationManager(SoftwareManager): return description def _get_fix_for(self, url_no_protocol: str) -> str: - res = self.http_client.get(URL_FIX_PATTERN.format(url=url_no_protocol)) + try: + fix_url = URL_FIX_PATTERN.format(url=url_no_protocol) + res = self.http_client.get(fix_url) - if res: - return res.text + if res: + return res.text + except Exception as e: + self.logger.warning("Error when trying to retrieve a fix for {}: {}".format(fix_url, e.__class__.__name__)) def _strip_url_protocol(self, url: str) -> str: return RE_PROTOCOL_STRIP.split(url)[1].strip().lower() @@ -149,10 +154,14 @@ class WebApplicationManager(SoftwareManager): def _map_url(self, url: str) -> "BeautifulSoup": headers = {'Accept-language': self._get_lang_header(), 'User-Agent': UA_CHROME} - url_res = self.http_client.get(url, headers=headers, ignore_ssl=True, single_call=True) - if url_res: - return BeautifulSoup(url_res.text, 'lxml', parse_only=SoupStrainer('head')) + try: + url_res = self.http_client.get(url, headers=headers, ignore_ssl=True, single_call=True) + + if url_res: + return BeautifulSoup(url_res.text, 'lxml', parse_only=SoupStrainer('head')) + except exceptions.ConnectionError as e: + self.logger.warning("Could not get {}: {}".format(url, e.__class__.__name__)) def search(self, words: str, disk_loader: DiskCacheLoader, limit: int = -1, is_url: bool = False) -> SearchResult: local_config = {} diff --git a/bauh/view/qt/apps_table.py b/bauh/view/qt/apps_table.py index beb8e8e0..1b3001c9 100644 --- a/bauh/view/qt/apps_table.py +++ b/bauh/view/qt/apps_table.py @@ -342,8 +342,9 @@ class AppsTable(QTableWidget): item.setText(name) - if self.disk_cache and pkg.model.supports_disk_cache() and pkg.model.get_disk_icon_path() and os.path.exists(pkg.model.get_disk_icon_path()): - with open(pkg.model.get_disk_icon_path(), 'rb') as f: + icon_path = pkg.model.get_disk_icon_path() + if self.disk_cache and pkg.model.supports_disk_cache() and icon_path and os.path.isfile(icon_path): + with open(icon_path, 'rb') as f: icon_bytes = f.read() pixmap = QPixmap() pixmap.loadFromData(icon_bytes)