mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 00:04:15 +02:00
fix: application is not initializing when there is no internet connection
This commit is contained in:
@@ -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**
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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 {}
|
||||
|
||||
@@ -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 {}
|
||||
|
||||
Reference in New Issue
Block a user