From 9863cdb812f7e488fae03898f7e41310403d85ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Moreira?= Date: Tue, 17 Dec 2019 16:18:43 -0300 Subject: [PATCH] [wgem] suggestions now can provide their own electron version --- bauh/gems/web/__init__.py | 8 ++++---- bauh/gems/web/controller.py | 16 ++++++++++++++-- bauh/gems/web/model.py | 4 ++++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/bauh/gems/web/__init__.py b/bauh/gems/web/__init__.py index 8274253a..26946647 100644 --- a/bauh/gems/web/__init__.py +++ b/bauh/gems/web/__init__.py @@ -19,9 +19,9 @@ ELECTRON_SHA256_URL = 'https://github.com/electron/electron/releases/download/v{ URL_ENVIRONMENT_SETTINGS = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/web/environment.yml' DESKTOP_ENTRY_PATH_PATTERN = DESKTOP_ENTRIES_DIR + '/bauh.web.{name}.desktop' URL_FIX_PATTERN = "https://raw.githubusercontent.com/vinifmor/bauh-files/master/web/fix/{url}.js" -URL_SUGGESTIONS = "https://raw.githubusercontent.com/vinifmor/bauh-files/master/web/suggestions.yaml" +URL_SUGGESTIONS = "https://raw.githubusercontent.com/vinifmor/bauh-files/master/web/suggestions.yml" UA_CHROME = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36' TEMP_PATH = '/tmp/bauh/web' -SEARCH_INDEX_FILE = '{}/index.yaml'.format(TEMP_PATH) -SUGGESTIONS_CACHE_FILE = '{}/suggestions.yaml'.format(TEMP_PATH) -CONFIG_FILE = '{}/web.yaml'.format(CONFIG_PATH) +SEARCH_INDEX_FILE = '{}/index.yml'.format(TEMP_PATH) +SUGGESTIONS_CACHE_FILE = '{}/suggestions.yml'.format(TEMP_PATH) +CONFIG_FILE = '{}/web.yml'.format(CONFIG_PATH) diff --git a/bauh/gems/web/controller.py b/bauh/gems/web/controller.py index 4cfc496d..b2302f76 100644 --- a/bauh/gems/web/controller.py +++ b/bauh/gems/web/controller.py @@ -489,8 +489,18 @@ class WebApplicationManager(SoftwareManager): if system_env: self.logger.warning("Using system's nativefier to install {}".format(pkg.url)) + electron_version = self.env_settings['electron']['version'] + + if pkg.version and pkg.version != electron_version: + self.logger.info('A preset Electron version is defined for {}: {}'.format(pkg.url, pkg.version)) + electron_version = pkg.version + + if config['environment']['electron']['version']: + self.logger.warning("A custom Electron version will be used {} to install {}".format(electron_version, pkg.url)) + electron_version = config['environment']['electron']['version'] + installed = handler.handle_simple(nativefier.install(url=pkg.url, name=app_id, output_dir=app_dir, - electron_version=self.env_settings['electron']['version'], + electron_version=electron_version, system=system_env, cwd=INSTALLED_PATH, extra_options=install_options)) @@ -644,6 +654,8 @@ class WebApplicationManager(SoftwareManager): categories=[suggestion['category']] if suggestion.get('category') else None, preset_options=suggestion.get('options')) + app.set_version(suggestion.get('version')) + description = suggestion.get('description') if isinstance(description, dict): @@ -651,7 +663,7 @@ class WebApplicationManager(SoftwareManager): elif isinstance(description, str): app.description = description - if self.env_settings and self.env_settings.get('electron'): + if not app.version and self.env_settings and self.env_settings.get('electron'): app.version = self.env_settings['electron']['version'] app.latest_version = app.version diff --git a/bauh/gems/web/model.py b/bauh/gems/web/model.py index 8b285c21..87b80aaa 100644 --- a/bauh/gems/web/model.py +++ b/bauh/gems/web/model.py @@ -20,6 +20,10 @@ class WebApplication(SoftwarePackage): self.set_custom_icon(custom_icon) self.preset_options = preset_options + def set_version(self, version: str): + self.version = str(version) if version else None + self.latest_version = version + def has_history(self): return False