mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 02:24:16 +02:00
[snap] suggestions retrieved from bauh-files
This commit is contained in:
@@ -61,6 +61,7 @@ updates:
|
|||||||
- AUR:
|
- AUR:
|
||||||
- an exception happens when retrieving matches from the cached AUR index
|
- an exception happens when retrieving matches from the cached AUR index
|
||||||
- not using the optimized compilation settings if the custom makepkg file is not found during the installation process
|
- not using the optimized compilation settings if the custom makepkg file is not found during the installation process
|
||||||
|
- minor fixes
|
||||||
|
|
||||||
## [0.7.5] 2019-12-20
|
## [0.7.5] 2019-12-20
|
||||||
### Fixes
|
### Fixes
|
||||||
|
|||||||
@@ -6,3 +6,4 @@ ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
|||||||
SNAP_CACHE_PATH = CACHE_PATH + '/snap'
|
SNAP_CACHE_PATH = CACHE_PATH + '/snap'
|
||||||
CATEGORIES_FILE_PATH = SNAP_CACHE_PATH + '/categories.txt'
|
CATEGORIES_FILE_PATH = SNAP_CACHE_PATH + '/categories.txt'
|
||||||
URL_CATEGORIES_FILE = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/snap/categories.txt'
|
URL_CATEGORIES_FILE = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/snap/categories.txt'
|
||||||
|
SUGGESTIONS_FILE = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/snap/suggestions.txt'
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ from bauh.api.abstract.view import SingleSelectComponent, SelectViewType, InputO
|
|||||||
from bauh.commons.category import CategoriesDownloader
|
from bauh.commons.category import CategoriesDownloader
|
||||||
from bauh.commons.html import bold
|
from bauh.commons.html import bold
|
||||||
from bauh.commons.system import SystemProcess, ProcessHandler, new_root_subprocess
|
from bauh.commons.system import SystemProcess, ProcessHandler, new_root_subprocess
|
||||||
from bauh.gems.snap import snap, suggestions, URL_CATEGORIES_FILE, SNAP_CACHE_PATH, CATEGORIES_FILE_PATH
|
from bauh.gems.snap import snap, URL_CATEGORIES_FILE, SNAP_CACHE_PATH, CATEGORIES_FILE_PATH, SUGGESTIONS_FILE
|
||||||
from bauh.gems.snap.constants import SNAP_API_URL
|
from bauh.gems.snap.constants import SNAP_API_URL
|
||||||
from bauh.gems.snap.model import SnapApplication
|
from bauh.gems.snap.model import SnapApplication
|
||||||
from bauh.gems.snap.worker import SnapAsyncDataLoader
|
from bauh.gems.snap.worker import SnapAsyncDataLoader
|
||||||
@@ -239,31 +239,39 @@ class SnapManager(SoftwareManager):
|
|||||||
res = []
|
res = []
|
||||||
|
|
||||||
if snap.is_snapd_running():
|
if snap.is_snapd_running():
|
||||||
sugs = [(i, p) for i, p in suggestions.ALL.items()]
|
self.logger.info('Downloading suggestions file {}'.format(SUGGESTIONS_FILE))
|
||||||
sugs.sort(key=lambda t: t[1].value, reverse=True)
|
file = self.http_client.get(SUGGESTIONS_FILE)
|
||||||
|
|
||||||
threads = []
|
if not file or not file.text:
|
||||||
self.categories_downloader.join()
|
self.logger.warning("No suggestion found in {}".format(SUGGESTIONS_FILE))
|
||||||
|
return res
|
||||||
|
else:
|
||||||
|
self.logger.info('Mapping suggestions')
|
||||||
|
self.categories_downloader.join()
|
||||||
|
|
||||||
for sug in sugs:
|
suggestions, threads = [], []
|
||||||
|
|
||||||
if limit <= 0 or len(res) < limit:
|
for l in file.text.split('\n'):
|
||||||
cached_sug = self.suggestions_cache.get(sug[0])
|
if l:
|
||||||
|
lsplit = l.strip().split('=')
|
||||||
|
|
||||||
if cached_sug:
|
if limit <= 0 or len(suggestions) < limit:
|
||||||
res.append(cached_sug)
|
cached_sug = self.suggestions_cache.get(lsplit[1])
|
||||||
else:
|
|
||||||
t = Thread(target=self._fill_suggestion, args=(sug[0], sug[1], res))
|
|
||||||
t.start()
|
|
||||||
threads.append(t)
|
|
||||||
time.sleep(0.001) # to avoid being blocked
|
|
||||||
else:
|
|
||||||
break
|
|
||||||
|
|
||||||
for t in threads:
|
if cached_sug:
|
||||||
t.join()
|
res.append(cached_sug)
|
||||||
|
else:
|
||||||
|
t = Thread(target=self._fill_suggestion, args=(lsplit[1], SuggestionPriority(int(lsplit[0])), res))
|
||||||
|
t.start()
|
||||||
|
threads.append(t)
|
||||||
|
time.sleep(0.001) # to avoid being blocked
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
|
||||||
res.sort(key=lambda s: s.priority.value, reverse=True)
|
for t in threads:
|
||||||
|
t.join()
|
||||||
|
|
||||||
|
res.sort(key=lambda s: s.priority.value, reverse=True)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def is_default_enabled(self) -> bool:
|
def is_default_enabled(self) -> bool:
|
||||||
|
|||||||
10
bauh/gems/snap/resources/suggestions.txt
Normal file
10
bauh/gems/snap/resources/suggestions.txt
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
3=skype
|
||||||
|
2=drawing
|
||||||
|
2=obs-studio
|
||||||
|
2=eclispe
|
||||||
|
1=krita
|
||||||
|
1=audacity
|
||||||
|
0=supertuxkart
|
||||||
|
0=retroarch
|
||||||
|
0=chromium
|
||||||
|
0=matroska-tools
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
from bauh.api.abstract.model import SuggestionPriority
|
|
||||||
|
|
||||||
ALL = {
|
|
||||||
'whatsdesk': SuggestionPriority.TOP,
|
|
||||||
'slack': SuggestionPriority.HIGH,
|
|
||||||
'discord': SuggestionPriority.HIGH,
|
|
||||||
'yakyak': SuggestionPriority.MEDIUM,
|
|
||||||
'instagraph': SuggestionPriority.MEDIUM,
|
|
||||||
'gimp': SuggestionPriority.MEDIUM,
|
|
||||||
'pycharm-professional': SuggestionPriority.LOW,
|
|
||||||
'eclipse': SuggestionPriority.LOW,
|
|
||||||
'supertuxkart': SuggestionPriority.LOW
|
|
||||||
}
|
|
||||||
@@ -23,7 +23,7 @@ URL_SUGGESTIONS = "https://raw.githubusercontent.com/vinifmor/bauh-files/master/
|
|||||||
UA_CHROME = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36'
|
UA_CHROME = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36'
|
||||||
TEMP_PATH = '/tmp/bauh/web'
|
TEMP_PATH = '/tmp/bauh/web'
|
||||||
SEARCH_INDEX_FILE = '{}/index.yml'.format(TEMP_PATH)
|
SEARCH_INDEX_FILE = '{}/index.yml'.format(TEMP_PATH)
|
||||||
SUGGESTIONS_CACHE_FILE = '{}/suggestions.yml'.format(TEMP_PATH)
|
SUGGESTIONS_CACHE_FILE = '{}/suggestions.txt'.format(TEMP_PATH)
|
||||||
CONFIG_FILE = '{}/web.yml'.format(CONFIG_PATH)
|
CONFIG_FILE = '{}/web.yml'.format(CONFIG_PATH)
|
||||||
NATIVEFIER_URL = 'https://github.com/jiahaog/nativefier/archive/v7.7.0.tar.gz'
|
NATIVEFIER_URL = 'https://github.com/jiahaog/nativefier/archive/v7.7.0.tar.gz'
|
||||||
|
|
||||||
|
|||||||
@@ -336,7 +336,7 @@ class GenericSoftwareManager(SoftwareManager):
|
|||||||
self.logger.info(man.__class__.__name__ + ' took {0:.2f} seconds'.format(mtf - mti))
|
self.logger.info(man.__class__.__name__ + ' took {0:.2f} seconds'.format(mtf - mti))
|
||||||
|
|
||||||
if man_sugs:
|
if man_sugs:
|
||||||
if len(man_sugs) > limit:
|
if 0 < limit < len(man_sugs):
|
||||||
man_sugs = man_sugs[0:limit]
|
man_sugs = man_sugs[0:limit]
|
||||||
|
|
||||||
suggestions.extend(man_sugs)
|
suggestions.extend(man_sugs)
|
||||||
|
|||||||
Reference in New Issue
Block a user