diff --git a/CHANGELOG.md b/CHANGELOG.md index 53445937..c7113837 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - 3 password attempts for root authentication - AUR: - showing a "user-friendly" popup when there are integrity issues with the source-files of a building package + ### Fixes +- application not initializing when there is no internet connection - AUR: - update-checking for some scenarios - not respecting **ignorepkg** settings in **pacman.conf** diff --git a/bauh/gems/appimage/worker.py b/bauh/gems/appimage/worker.py index fcc6929e..e9449cbe 100644 --- a/bauh/gems/appimage/worker.py +++ b/bauh/gems/appimage/worker.py @@ -8,6 +8,8 @@ from multiprocessing import Process from pathlib import Path from threading import Thread +import requests + from bauh.api.http import HttpClient from bauh.gems.appimage import LOCAL_PATH, db @@ -68,7 +70,11 @@ class DatabaseUpdater(Thread if bool(int(os.getenv('BAUH_DEBUG', 0))) else Proce def run(self): if self.enabled: while True: - self._download_databases() + try: + self._download_databases() + except requests.exceptions.ConnectionError: + self.logger.warning('The internet connection seems to be off.') + self.logger.info('Sleeping') time.sleep(self.sleep) else: diff --git a/bauh/gems/arch/worker.py b/bauh/gems/arch/worker.py index 978ba102..a0f69558 100644 --- a/bauh/gems/arch/worker.py +++ b/bauh/gems/arch/worker.py @@ -8,6 +8,8 @@ from multiprocessing import Process from threading import Thread from typing import Dict, List +import requests + from bauh.api.abstract.context import ApplicationContext from bauh.api.abstract.controller import SoftwareManager from bauh.api.constants import HOME_PATH @@ -45,7 +47,7 @@ class AURIndexUpdater(Thread): self.logger.info('Pre-indexed {} AUR package names in memory'.format(len(self.man.names_index))) else: self.logger.warning('No data returned from: {}'.format(URL_INDEX)) - except ConnectionError: + except requests.exceptions.ConnectionError: self.logger.warning('No internet connection: could not pre-index packages') time.sleep(60 * 20) # updates every 20 minutes @@ -148,21 +150,26 @@ class CategoriesDownloader: def get_categories(self) -> Dict[str, List[str]]: self.logger.info('Downloading AUR category definitions from {}'.format(self.URL_CATEGORIES_FILE)) - res = self.http_client.get(self.URL_CATEGORIES_FILE) + try: + res = self.http_client.get(self.URL_CATEGORIES_FILE) - if res: - try: - categories_map = {} - for l in res.text.split('\n'): - if l: - data = l.split('=') - categories_map[data[0]] = [c.strip() for c in data[1].split(',') if c] + if res: + try: + categories_map = {} + for l in res.text.split('\n'): + if l: + data = l.split('=') + categories_map[data[0]] = [c.strip() for c in data[1].split(',') if c] - self.logger.info('Loaded categories for {} AUR packages'.format(len(categories_map))) - return categories_map - except: - self.logger.error("Could not parse AUR categories definitions") - traceback.print_exc() + self.logger.info('Loaded categories for {} AUR packages'.format(len(categories_map))) + return categories_map + except: + self.logger.error("Could not parse AUR categories definitions") + traceback.print_exc() + return {} + else: + self.logger.info('Could not download {}'.format(self.URL_CATEGORIES_FILE)) return {} - else: - self.logger.info('Could not download {}'.format(self.URL_CATEGORIES_FILE)) + except requests.exceptions.ConnectionError: + self.logger.warning('The internet connection seems to be off.') + return {} diff --git a/bauh/gems/snap/worker.py b/bauh/gems/snap/worker.py index 6bfd9c08..54bd1271 100644 --- a/bauh/gems/snap/worker.py +++ b/bauh/gems/snap/worker.py @@ -4,6 +4,8 @@ import traceback from threading import Thread from typing import Dict, List +import requests + from bauh.api.abstract.cache import MemoryCache from bauh.api.abstract.context import ApplicationContext from bauh.api.abstract.controller import SoftwareManager @@ -85,21 +87,25 @@ class CategoriesDownloader: def get_categories(self) -> Dict[str, List[str]]: self.logger.info('Downloading Snap category definitions from {}'.format(self.URL_CATEGORIES_FILE)) - res = self.http_client.get(self.URL_CATEGORIES_FILE) + try: + res = self.http_client.get(self.URL_CATEGORIES_FILE) - if res: - try: - categories_map = {} - for l in res.text.split('\n'): - if l: - data = l.split('=') - categories_map[data[0]] = [c.strip() for c in data[1].split(',') if c] + if res: + try: + categories_map = {} + for l in res.text.split('\n'): + if l: + data = l.split('=') + categories_map[data[0]] = [c.strip() for c in data[1].split(',') if c] - self.logger.info('Loaded categories for {} Snap applications'.format(len(categories_map))) - return categories_map - except: - self.logger.error("Could not parse categories definitions") - traceback.print_exc() - return {} - else: - self.logger.info('Could not download {}'.format(self.URL_CATEGORIES_FILE)) + self.logger.info('Loaded categories for {} Snap applications'.format(len(categories_map))) + return categories_map + except: + self.logger.error("Could not parse categories definitions") + traceback.print_exc() + return {} + else: + self.logger.info('Could not download {}'.format(self.URL_CATEGORIES_FILE)) + except requests.exceptions.ConnectionError: + self.logger.warning('The internet connection seems to be off.') + return {}