Merge branch 'staging' into fpakpart

This commit is contained in:
Vinícius Moreira
2020-01-10 15:16:38 -03:00
4 changed files with 33 additions and 16 deletions

View File

@@ -7,7 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [0.8.1] ## [0.8.1]
### Improvements ### Improvements
- All icons are now SVG files - All icons are now SVG files
- HDPI support ( by [octopusSD](https://github.com/octopusSD) ) - HDPI support improvements ( by [octopusSD](https://github.com/octopusSD) )
- Web: - Web:
- not using HTTP sessions anymore to perform the searches. It seems to avoid URLs not being found after an internet drop event. - not using HTTP sessions anymore to perform the searches. It seems to avoid URLs not being found after an internet drop event.
- supporting JPEG images as custom icons - supporting JPEG images as custom icons
@@ -17,10 +17,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Fixes ### Fixes
- missing categories i18n [48](https://github.com/vinifmor/bauh/issues/48) - missing categories i18n [48](https://github.com/vinifmor/bauh/issues/48)
- not verifying if an icon path is a file
- Web: - Web:
- not handling HTTP connection issues - not handling HTTP connection issues
- not passing the Home path as a String ( does not work in Python 3.5 ) - not passing the Home path as a String ( does not work in Python 3.5 )
- UI:
- not verifying if an icon path is a file
- minor fixes
### UI ### UI
- Default **Type** icon removed from the Type filter to make the design more consistent with the Category filter. - Default **Type** icon removed from the Type filter to make the design more consistent with the Category filter.

View File

@@ -9,6 +9,7 @@ from pathlib import Path
from threading import Thread from threading import Thread
from typing import List, Type, Set, Tuple from typing import List, Type, Set, Tuple
import requests
import yaml import yaml
from colorama import Fore from colorama import Fore
from requests import exceptions from requests import exceptions
@@ -152,14 +153,14 @@ class WebApplicationManager(SoftwareManager):
def serialize_to_disk(self, pkg: SoftwarePackage, icon_bytes: bytes, only_icon: bool): def serialize_to_disk(self, pkg: SoftwarePackage, icon_bytes: bytes, only_icon: bool):
super(WebApplicationManager, self).serialize_to_disk(pkg=pkg, icon_bytes=None, only_icon=False) super(WebApplicationManager, self).serialize_to_disk(pkg=pkg, icon_bytes=None, only_icon=False)
def _map_url(self, url: str) -> "BeautifulSoup": def _map_url(self, url: str) -> Tuple["BeautifulSoup", requests.Response]:
headers = {'Accept-language': self._get_lang_header(), 'User-Agent': UA_CHROME} headers = {'Accept-language': self._get_lang_header(), 'User-Agent': UA_CHROME}
try: try:
url_res = self.http_client.get(url, headers=headers, ignore_ssl=True, single_call=True, session=False) url_res = self.http_client.get(url, headers=headers, ignore_ssl=True, single_call=True, session=False)
if url_res: if url_res:
return BeautifulSoup(url_res.text, 'lxml', parse_only=SoupStrainer('head')) return BeautifulSoup(url_res.text, 'lxml', parse_only=SoupStrainer('head')), url_res
except exceptions.ConnectionError as e: except exceptions.ConnectionError as e:
self.logger.warning("Could not get {}: {}".format(url, e.__class__.__name__)) self.logger.warning("Could not get {}: {}".format(url, e.__class__.__name__))
@@ -182,14 +183,21 @@ class WebApplicationManager(SoftwareManager):
if installed_matches: if installed_matches:
res.installed.extend(installed_matches) res.installed.extend(installed_matches)
else: else:
soup = self._map_url(url) soup_map = self._map_url(url)
if soup_map:
soup, response = soup_map[0], soup_map[1]
final_url = response.url
if final_url.endswith('/'):
final_url = final_url[0:-1]
if soup:
name = self._get_app_name(url_no_protocol, soup) name = self._get_app_name(url_no_protocol, soup)
desc = self._get_app_description(url, soup) desc = self._get_app_description(final_url, soup)
icon_url = self._get_app_icon_url(url, soup) icon_url = self._get_app_icon_url(final_url, soup)
app = WebApplication(url=url, name=name, description=desc, icon_url=icon_url) app = WebApplication(url=final_url, name=name, description=desc, icon_url=icon_url)
if self.env_settings.get('electron') and self.env_settings['electron'].get('version'): if self.env_settings.get('electron') and self.env_settings['electron'].get('version'):
app.version = self.env_settings['electron']['version'] app.version = self.env_settings['electron']['version']
@@ -747,9 +755,16 @@ class WebApplicationManager(SoftwareManager):
pass pass
def _fill_suggestion(self, app: WebApplication): def _fill_suggestion(self, app: WebApplication):
soup = self._map_url(app.url) soup_map = self._map_url(app.url)
if soup_map:
soup, res = soup_map[0], soup_map[1]
app.url = res.url
if app.url.endswith('/'):
app.url = app.url[0:-1]
if soup:
if not app.name: if not app.name:
app.name = self._get_app_name(app.url, soup) app.name = self._get_app_name(app.url, soup)

View File

@@ -14,7 +14,6 @@ from bauh.commons.html import strip_html
from bauh.view.qt import dialog from bauh.view.qt import dialog
from bauh.view.qt.components import IconButton from bauh.view.qt.components import IconButton
from bauh.view.qt.view_model import PackageView, PackageViewStatus from bauh.view.qt.view_model import PackageView, PackageViewStatus
from bauh.view.qt.view_utils import load_resource_icon
from bauh.view.util import resource from bauh.view.util import resource
from bauh.view.util.translation import I18n from bauh.view.util.translation import I18n
@@ -154,7 +153,9 @@ class AppsTable(QTableWidget):
if app_v.status == PackageViewStatus.LOADING and app_v.model.status == PackageStatus.READY: if app_v.status == PackageViewStatus.LOADING and app_v.model.status == PackageStatus.READY:
if self.download_icons: if self.download_icons:
self.network_man.get(QNetworkRequest(QUrl(app_v.model.icon_url))) icon_request = QNetworkRequest(QUrl(app_v.model.icon_url))
icon_request.setAttribute(QNetworkRequest.FollowRedirectsAttribute, True)
self.network_man.get(icon_request)
self._update_row(app_v, change_update_col=False) self._update_row(app_v, change_update_col=False)
app_v.status = PackageViewStatus.READY app_v.status = PackageViewStatus.READY
@@ -289,8 +290,7 @@ class AppsTable(QTableWidget):
pixmap = self.cache_type_icon.get(pkg.model.get_type()) pixmap = self.cache_type_icon.get(pkg.model.get_type())
if not pixmap: if not pixmap:
pixmap = QPixmap(pkg.model.get_type_icon_path()) pixmap = QIcon(pkg.model.get_type_icon_path()).pixmap(QSize(16, 16))
pixmap = pixmap.scaled(16, 16, Qt.KeepAspectRatio, Qt.SmoothTransformation)
self.cache_type_icon[pkg.model.get_type()] = pixmap self.cache_type_icon[pkg.model.get_type()] = pixmap
item = QLabel() item = QLabel()

View File

@@ -837,7 +837,7 @@ class ManageWindow(QWidget):
new_width = max(table_width, toolbar_width, topbar_width) new_width = max(table_width, toolbar_width, topbar_width)
if accept_lower_width or new_width > self.width(): if (self.pkgs and accept_lower_width) or new_width > self.width():
self.resize(new_width, self.height()) self.resize(new_width, self.height())
if self.first_refresh: if self.first_refresh: