[wgem] filling preset app options

This commit is contained in:
Vinícius Moreira
2019-12-16 18:09:28 -03:00
parent 2cdd5b59f5
commit a602a583e3
10 changed files with 83 additions and 23 deletions

View File

@@ -1,3 +1,4 @@
import glob
import json
import os
import re
@@ -10,6 +11,8 @@ from pathlib import Path
from threading import Lock
from typing import Set, Type, List
from colorama import Fore
from bauh.api.abstract.context import ApplicationContext
from bauh.api.abstract.controller import SoftwareManager, SearchResult
from bauh.api.abstract.disk import DiskCacheLoader
@@ -19,7 +22,7 @@ from bauh.api.abstract.view import MessageType
from bauh.api.constants import HOME_PATH
from bauh.commons.html import bold
from bauh.commons.system import SystemProcess, new_subprocess, ProcessHandler, run_cmd, SimpleProcess
from bauh.gems.appimage import query, INSTALLATION_PATH, suggestions
from bauh.gems.appimage import query, INSTALLATION_PATH, suggestions, LOCAL_PATH
from bauh.gems.appimage.model import AppImage
from bauh.gems.appimage.worker import DatabaseUpdater
@@ -446,3 +449,13 @@ class AppImageManager(SoftwareManager):
return [pkg.url_screenshot]
return []
def clear_data(self):
for f in glob.glob('{}/*.db'.format(LOCAL_PATH)):
try:
print('[bauh][appimage] Deleting {}'.format(f))
os.remove(f)
print('{}[bauh][appimage] {} deleted{}'.format(Fore.YELLOW, f, Fore.RESET))
except:
print('{}[bauh][appimage] An exception has happened when deleting {}{}'.format(Fore.RED, Fore.RESET))
traceback.print_exc()

View File

@@ -10,6 +10,7 @@ from threading import Thread
import requests
from bauh.api.http import HttpClient
from bauh.commons import internet
from bauh.gems.appimage import LOCAL_PATH
@@ -73,7 +74,8 @@ class DatabaseUpdater(Thread):
if self.enabled:
while True:
try:
self._download_databases()
if internet.is_available(self.http_client, self.logger):
self._download_databases()
except requests.exceptions.ConnectionError:
self.logger.warning('The internet connection seems to be off.')