mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 00:04:15 +02:00
[appimage] begin: moving suggestions to cloud
This commit is contained in:
@@ -5,3 +5,4 @@ from bauh.api.constants import HOME_PATH
|
||||
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
LOCAL_PATH = '{}/.local/share/bauh/appimage'.format(HOME_PATH)
|
||||
INSTALLATION_PATH = LOCAL_PATH + '/installed/'
|
||||
SUGGESTIONS_FILE = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/appimage/suggestions.txt'
|
||||
@@ -22,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, LOCAL_PATH
|
||||
from bauh.gems.appimage import query, INSTALLATION_PATH, LOCAL_PATH, SUGGESTIONS_FILE
|
||||
from bauh.gems.appimage.config import read_config
|
||||
from bauh.gems.appimage.model import AppImage
|
||||
from bauh.gems.appimage.worker import DatabaseUpdater
|
||||
@@ -421,21 +421,26 @@ class AppImageManager(SoftwareManager):
|
||||
connection = self._get_db_connection(DB_APPS_PATH)
|
||||
|
||||
if connection:
|
||||
try:
|
||||
sugs = [(i, p) for i, p in suggestions.ALL.items()]
|
||||
sugs.sort(key=lambda t: t[1].value, reverse=True)
|
||||
file = self.http_client.get(SUGGESTIONS_FILE)
|
||||
|
||||
if limit > 0:
|
||||
sugs = sugs[0:limit]
|
||||
if not file or not file.text:
|
||||
self.logger.warning("No suggestion found in {}".format(SUGGESTIONS_FILE))
|
||||
return res
|
||||
else:
|
||||
try:
|
||||
for line in file.text.split('\n'):
|
||||
if line: # TODO stopped here
|
||||
if limit > 0:
|
||||
sugs = sugs[0:limit]
|
||||
|
||||
cursor = connection.cursor()
|
||||
cursor.execute(query.FIND_APPS_BY_NAME_FULL.format(','.join(["'{}'".format(s[0]) for s in sugs])))
|
||||
cursor = connection.cursor()
|
||||
cursor.execute(query.FIND_APPS_BY_NAME_FULL.format(','.join(["'{}'".format(s[0]) for s in sugs])))
|
||||
|
||||
for t in cursor.fetchall():
|
||||
app = AppImage(*t)
|
||||
res.append(PackageSuggestion(app, suggestions.ALL.get(app.name.lower())))
|
||||
finally:
|
||||
self._close_connection(DB_APPS_PATH, connection)
|
||||
for t in cursor.fetchall():
|
||||
app = AppImage(*t)
|
||||
res.append(PackageSuggestion(app, suggestions.ALL.get(app.name.lower())))
|
||||
finally:
|
||||
self._close_connection(DB_APPS_PATH, connection)
|
||||
|
||||
return res
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
from bauh.api.abstract.model import SuggestionPriority
|
||||
|
||||
ALL = {
|
||||
'onlyoffice': SuggestionPriority.MEDIUM,
|
||||
'gamehub': SuggestionPriority.MEDIUM,
|
||||
'rpcs3': SuggestionPriority.MEDIUM,
|
||||
'etcher': SuggestionPriority.MEDIUM,
|
||||
'postman': SuggestionPriority.LOW,
|
||||
'nosqlbooster': SuggestionPriority.LOW,
|
||||
'emcas': SuggestionPriority.LOW,
|
||||
'azpainter': SuggestionPriority.LOW
|
||||
}
|
||||
Reference in New Issue
Block a user