mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-08 21:14: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__))
|
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
LOCAL_PATH = '{}/.local/share/bauh/appimage'.format(HOME_PATH)
|
LOCAL_PATH = '{}/.local/share/bauh/appimage'.format(HOME_PATH)
|
||||||
INSTALLATION_PATH = LOCAL_PATH + '/installed/'
|
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.api.constants import HOME_PATH
|
||||||
from bauh.commons.html import bold
|
from bauh.commons.html import bold
|
||||||
from bauh.commons.system import SystemProcess, new_subprocess, ProcessHandler, run_cmd, SimpleProcess
|
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.config import read_config
|
||||||
from bauh.gems.appimage.model import AppImage
|
from bauh.gems.appimage.model import AppImage
|
||||||
from bauh.gems.appimage.worker import DatabaseUpdater
|
from bauh.gems.appimage.worker import DatabaseUpdater
|
||||||
@@ -421,21 +421,26 @@ class AppImageManager(SoftwareManager):
|
|||||||
connection = self._get_db_connection(DB_APPS_PATH)
|
connection = self._get_db_connection(DB_APPS_PATH)
|
||||||
|
|
||||||
if connection:
|
if connection:
|
||||||
try:
|
file = self.http_client.get(SUGGESTIONS_FILE)
|
||||||
sugs = [(i, p) for i, p in suggestions.ALL.items()]
|
|
||||||
sugs.sort(key=lambda t: t[1].value, reverse=True)
|
|
||||||
|
|
||||||
if limit > 0:
|
if not file or not file.text:
|
||||||
sugs = sugs[0:limit]
|
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 = connection.cursor()
|
||||||
cursor.execute(query.FIND_APPS_BY_NAME_FULL.format(','.join(["'{}'".format(s[0]) for s in sugs])))
|
cursor.execute(query.FIND_APPS_BY_NAME_FULL.format(','.join(["'{}'".format(s[0]) for s in sugs])))
|
||||||
|
|
||||||
for t in cursor.fetchall():
|
for t in cursor.fetchall():
|
||||||
app = AppImage(*t)
|
app = AppImage(*t)
|
||||||
res.append(PackageSuggestion(app, suggestions.ALL.get(app.name.lower())))
|
res.append(PackageSuggestion(app, suggestions.ALL.get(app.name.lower())))
|
||||||
finally:
|
finally:
|
||||||
self._close_connection(DB_APPS_PATH, connection)
|
self._close_connection(DB_APPS_PATH, connection)
|
||||||
|
|
||||||
return res
|
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