improving the gems panel selector

This commit is contained in:
Vinicius Moreira
2019-10-11 18:45:52 -03:00
parent b7ea957861
commit c6cdfe30d0
13 changed files with 34 additions and 12 deletions

View File

@@ -3,5 +3,5 @@ import os
from bauh.api.constants import HOME_PATH
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
BASE_PATH = '{}/.local/share/bauh/appimage'.format(HOME_PATH)
INSTALLATION_PATH = BASE_PATH + '/installed/'
LOCAL_PATH = '{}/.local/share/bauh/appimage'.format(HOME_PATH)
INSTALLATION_PATH = LOCAL_PATH + '/installed/'

View File

@@ -329,9 +329,22 @@ class AppImageManager(SoftwareManager):
def set_enabled(self, enabled: bool):
self.enabled = enabled
def _is_sqlite3_available(self):
try:
new_subprocess(['sqlite3', '--version'])
return True
except FileNotFoundError:
return False
def _is_wget_available(self):
try:
new_subprocess(['wget', '--version'])
return True
except FileNotFoundError:
return False
def can_work(self) -> bool:
# TODO check wget and sqlite
return True
return self._is_sqlite3_available() and self._is_wget_available()
def requires_root(self, action: str, pkg: AppImage):
return False
@@ -347,7 +360,6 @@ class AppImageManager(SoftwareManager):
pass
def list_suggestions(self, limit: int) -> List[PackageSuggestion]:
# TODO
pass
def is_default_enabled(self) -> bool:

View File

@@ -1,4 +1,5 @@
gem.appimage.label=AppImage
gem.appimage.info=Applications published at https://appimage.github.io/
appimage.install.permission=Giving execution permission to {}
appimage.install.extract=Extracting the content from {}
appimage.install.desktop_entry=Generating a menu shortcut

View File

@@ -1,4 +1,5 @@
gem.appimage.label=AppImage
gem.appimage.info=Aplicativos publicados en https://appimage.github.io/
appimage.install.permission=Concediendo permiso de ejecución a {}
appimage.install.extract=Extrayendo el contenido de {}
appimage.install.desktop_entry=Creando un atajo en el menú

View File

@@ -1,4 +1,5 @@
gem.appimage.label=AppImage
gem.appimage.info=Aplicativos publicados em https://appimage.github.io/
appimage.install.permission=Concedendo permissão de execução para {}
appimage.install.extract=Extraindo o conteúdo de {}
appimage.install.desktop_entry=Criando um atalho no menu

View File

@@ -1,3 +1,4 @@
import glob
import logging
import os
import tarfile
@@ -8,13 +9,13 @@ from pathlib import Path
from threading import Thread
from bauh.api.http import HttpClient
from bauh.gems.appimage import BASE_PATH
from bauh.gems.appimage import LOCAL_PATH
class DatabaseUpdater(Thread if bool(int(os.getenv('BAUH_DEBUG', 0))) else Process):
URL_DB = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/appimage/dbs.tar.gz'
COMPRESS_FILE_PATH = BASE_PATH + '/db.tar.gz'
COMPRESS_FILE_PATH = LOCAL_PATH + '/db.tar.gz'
def __init__(self, http_client: HttpClient, logger: logging.Logger):
super(DatabaseUpdater, self).__init__(daemon=True)
@@ -29,26 +30,26 @@ class DatabaseUpdater(Thread if bool(int(os.getenv('BAUH_DEBUG', 0))) else Proce
res = self.http_client.get(self.URL_DB, headers={'Authorization': 'token {}'.format(os.getenv('GITHUB_TOKEN'))})
if res:
Path(BASE_PATH).mkdir(parents=True, exist_ok=True)
Path(LOCAL_PATH).mkdir(parents=True, exist_ok=True)
with open(self.COMPRESS_FILE_PATH, 'wb+') as f:
f.write(res.content)
self.logger.info("Database file saved at {}".format(self.COMPRESS_FILE_PATH))
old_db_files = {file for r, d, f in os.walk(BASE_PATH) for file in f if file.endswith('.db')}
old_db_files = glob.glob(LOCAL_PATH + '/*.db')
if old_db_files:
self.logger.info('Deleting old database files')
for f in old_db_files:
os.remove('{}/{}'.format(BASE_PATH, f))
os.remove(f)
self.logger.info('Old database files deleted')
self.logger.info('Uncompressing {}'.format(self.COMPRESS_FILE_PATH))
try:
tf = tarfile.open(self.COMPRESS_FILE_PATH)
tf.extractall(BASE_PATH)
tf.extractall(LOCAL_PATH)
self.logger.info('Successfully uncompressed file {}'.format(self.COMPRESS_FILE_PATH))
except:
self.logger.error('Could not extract file {}'.format(self.COMPRESS_FILE_PATH))

View File

@@ -1,3 +1,4 @@
gem.flatpak.info=Applications available in the repositories configured on your system
flatpak.notification.no_remotes=No Flatpak remotes set. It will not be possible to search for Flatpak apps.
flatpak.downgrade.impossible.title=Error
flatpak.downgrade.impossible.body=Impossible to downgrade: the app is in its first version

View File

@@ -1,3 +1,4 @@
gem.flatpak.info=Aplicativos disponibles en los repositorios configurados en su sistema
flatpak.info.arch=arquitectura
flatpak.info.branch=rama
flatpak.info.collection=colección

View File

@@ -1,3 +1,4 @@
gem.flatpak.info=Aplicativos disponíveis nos repositórios configurados do seu sistema
flatpak.info.arch=arquitetura
flatpak.info.branch=ramo
flatpak.info.collection=coleção

View File

@@ -1,3 +1,4 @@
gem.snap.info=Applications published at https://snapcraft.io/store
snap.notification.snapd_unavailable={} seems not to be installed or enabled. {} packages will not be available.
snap.notification.snap.disable=If you do not want to use Snap applications, uncheck {} in {}
snap.action.refresh.status=Refreshing

View File

@@ -1,3 +1,4 @@
gem.snap.info=Aplicativos publicados en https://snapcraft.io/store
snap.info.commands=comandos
snap.info.contact=contacto
snap.info.description=descripción

View File

@@ -1,3 +1,4 @@
gem.snap.info=Aplicativos publicados em https://snapcraft.io/store
snap.info.commands=comandos
snap.info.contact=contato
snap.info.description=descrição

View File

@@ -60,7 +60,7 @@ class GemSelectorPanel(QWidget):
self.bt_proceed.setEnabled(bool(default_ops))
self.gem_select_model = MultipleSelectComponent(label='', options=gem_options, default_options=default_ops, max_per_line=3)
self.gem_select_model = MultipleSelectComponent(label='', options=gem_options, default_options=default_ops, max_per_line=1)
self.gem_select = MultipleSelectQt(self.gem_select_model, self.check_state)
self.layout().addWidget(self.gem_select, 1, 1)