mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 00:04:15 +02:00
[flatpak] fix: wrong encoded strings displayed (requires Flatpak >= 1.12)
This commit is contained in:
@@ -13,6 +13,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
- Arch
|
- Arch
|
||||||
- regression: not displaying ignored updates
|
- regression: not displaying ignored updates
|
||||||
|
|
||||||
|
- Flatpak:
|
||||||
|
- executed commands are not displayed on the system default language and encoding (requires Flatpak >= 1.12) [#242](https://github.com/vinifmor/bauh/issues/242)
|
||||||
|
- applications and runtimes descriptions are not displayed on the system default language (when available) [#242](https://github.com/vinifmor/bauh/issues/242)
|
||||||
|
|
||||||
- UI:
|
- UI:
|
||||||
- fix: rare crash when updating table items
|
- fix: rare crash when updating table items
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ VERSION_1_2 = parse_version('1.2')
|
|||||||
VERSION_1_3 = parse_version('1.3')
|
VERSION_1_3 = parse_version('1.3')
|
||||||
VERSION_1_4 = parse_version('1.4')
|
VERSION_1_4 = parse_version('1.4')
|
||||||
VERSION_1_5 = parse_version('1.5')
|
VERSION_1_5 = parse_version('1.5')
|
||||||
|
VERSION_1_12 = parse_version('1.12')
|
||||||
|
|
||||||
|
|
||||||
def get_icon_path() -> str:
|
def get_icon_path() -> str:
|
||||||
|
|||||||
@@ -224,10 +224,11 @@ class FlatpakManager(SoftwareManager):
|
|||||||
commit = history.history[history.pkg_status_idx + 1]['commit']
|
commit = history.history[history.pkg_status_idx + 1]['commit']
|
||||||
watcher.change_substatus(self.i18n['flatpak.downgrade.reverting'])
|
watcher.change_substatus(self.i18n['flatpak.downgrade.reverting'])
|
||||||
watcher.change_progress(50)
|
watcher.change_progress(50)
|
||||||
success, _ = ProcessHandler(watcher).handle_simple(flatpak.downgrade(pkg.ref,
|
success, _ = ProcessHandler(watcher).handle_simple(flatpak.downgrade(app_ref=pkg.ref,
|
||||||
commit,
|
commit=commit,
|
||||||
pkg.installation,
|
installation=pkg.installation,
|
||||||
root_password))
|
root_password=root_password,
|
||||||
|
version=flatpak.get_version()))
|
||||||
watcher.change_progress(100)
|
watcher.change_progress(100)
|
||||||
return success
|
return success
|
||||||
|
|
||||||
@@ -254,13 +255,15 @@ class FlatpakManager(SoftwareManager):
|
|||||||
if req.pkg.update_component:
|
if req.pkg.update_component:
|
||||||
res, _ = ProcessHandler(watcher).handle_simple(flatpak.install(app_id=ref,
|
res, _ = ProcessHandler(watcher).handle_simple(flatpak.install(app_id=ref,
|
||||||
installation=req.pkg.installation,
|
installation=req.pkg.installation,
|
||||||
origin=req.pkg.origin))
|
origin=req.pkg.origin,
|
||||||
|
version=flatpak_version))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
res, _ = ProcessHandler(watcher).handle_simple(flatpak.update(app_ref=ref,
|
res, _ = ProcessHandler(watcher).handle_simple(flatpak.update(app_ref=ref,
|
||||||
installation=req.pkg.installation,
|
installation=req.pkg.installation,
|
||||||
related=related,
|
related=related,
|
||||||
deps=deps))
|
deps=deps,
|
||||||
|
version=flatpak_version))
|
||||||
|
|
||||||
watcher.change_substatus('')
|
watcher.change_substatus('')
|
||||||
if not res:
|
if not res:
|
||||||
@@ -280,7 +283,9 @@ class FlatpakManager(SoftwareManager):
|
|||||||
if not self._make_exports_dir(watcher):
|
if not self._make_exports_dir(watcher):
|
||||||
return TransactionResult.fail()
|
return TransactionResult.fail()
|
||||||
|
|
||||||
uninstalled, _ = ProcessHandler(watcher).handle_simple(flatpak.uninstall(pkg.ref, pkg.installation))
|
flatpak_version = flatpak.get_version()
|
||||||
|
uninstalled, _ = ProcessHandler(watcher).handle_simple(flatpak.uninstall(pkg.ref, pkg.installation,
|
||||||
|
flatpak_version))
|
||||||
|
|
||||||
if uninstalled:
|
if uninstalled:
|
||||||
if self.suggestions_cache:
|
if self.suggestions_cache:
|
||||||
@@ -445,7 +450,8 @@ class FlatpakManager(SoftwareManager):
|
|||||||
if not self._make_exports_dir(handler.watcher):
|
if not self._make_exports_dir(handler.watcher):
|
||||||
return TransactionResult(success=False, installed=[], removed=[])
|
return TransactionResult(success=False, installed=[], removed=[])
|
||||||
|
|
||||||
installed, output = handler.handle_simple(flatpak.install(str(pkg.id), pkg.origin, pkg.installation))
|
installed, output = handler.handle_simple(flatpak.install(str(pkg.id), pkg.origin, pkg.installation,
|
||||||
|
flatpak_version))
|
||||||
|
|
||||||
if not installed and 'error: No ref chosen to resolve matches' in output:
|
if not installed and 'error: No ref chosen to resolve matches' in output:
|
||||||
ref_opts = RE_INSTALL_REFS.findall(output)
|
ref_opts = RE_INSTALL_REFS.findall(output)
|
||||||
@@ -459,7 +465,8 @@ class FlatpakManager(SoftwareManager):
|
|||||||
confirmation_label=self.i18n['proceed'].capitalize(),
|
confirmation_label=self.i18n['proceed'].capitalize(),
|
||||||
deny_label=self.i18n['cancel'].capitalize()):
|
deny_label=self.i18n['cancel'].capitalize()):
|
||||||
ref = ref_select.get_selected()
|
ref = ref_select.get_selected()
|
||||||
installed, output = handler.handle_simple(flatpak.install(ref, pkg.origin, pkg.installation))
|
installed, output = handler.handle_simple(flatpak.install(ref, pkg.origin, pkg.installation,
|
||||||
|
flatpak_version))
|
||||||
pkg.ref = ref
|
pkg.ref = ref
|
||||||
pkg.runtime = 'runtime' in ref
|
pkg.runtime = 'runtime' in ref
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ from packaging.version import Version
|
|||||||
from packaging.version import parse as parse_version
|
from packaging.version import parse as parse_version
|
||||||
|
|
||||||
from bauh.api.exception import NoInternetException
|
from bauh.api.exception import NoInternetException
|
||||||
from bauh.commons.system import new_subprocess, run_cmd, SimpleProcess, ProcessHandler
|
from bauh.commons.system import new_subprocess, run_cmd, SimpleProcess, ProcessHandler, DEFAULT_LANG
|
||||||
from bauh.commons.util import size_to_byte
|
from bauh.commons.util import size_to_byte
|
||||||
from bauh.gems.flatpak import EXPORTS_PATH, VERSION_1_3, VERSION_1_2, VERSION_1_5
|
from bauh.gems.flatpak import EXPORTS_PATH, VERSION_1_3, VERSION_1_2, VERSION_1_5, VERSION_1_12
|
||||||
|
|
||||||
RE_SEVERAL_SPACES = re.compile(r'\s+')
|
RE_SEVERAL_SPACES = re.compile(r'\s+')
|
||||||
RE_COMMIT = re.compile(r'(Latest commit|Commit)\s*:\s*(.+)')
|
RE_COMMIT = re.compile(r'(Latest commit|Commit)\s*:\s*(.+)')
|
||||||
@@ -95,7 +95,7 @@ def list_installed(version: Version) -> List[dict]:
|
|||||||
apps = []
|
apps = []
|
||||||
|
|
||||||
if version < VERSION_1_2:
|
if version < VERSION_1_2:
|
||||||
app_list = new_subprocess(['flatpak', 'list', '-d'])
|
app_list = new_subprocess(['flatpak', 'list', '-d'], lang=None)
|
||||||
|
|
||||||
for o in app_list.stdout:
|
for o in app_list.stdout:
|
||||||
if o:
|
if o:
|
||||||
@@ -118,7 +118,7 @@ def list_installed(version: Version) -> List[dict]:
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
cols = 'application,ref,arch,branch,description,origin,options,{}version'.format('' if version < VERSION_1_3 else 'name,')
|
cols = 'application,ref,arch,branch,description,origin,options,{}version'.format('' if version < VERSION_1_3 else 'name,')
|
||||||
app_list = new_subprocess(['flatpak', 'list', '--columns=' + cols])
|
app_list = new_subprocess(['flatpak', 'list', '--columns=' + cols], lang=None)
|
||||||
|
|
||||||
for o in app_list.stdout:
|
for o in app_list.stdout:
|
||||||
if o:
|
if o:
|
||||||
@@ -157,7 +157,7 @@ def list_installed(version: Version) -> List[dict]:
|
|||||||
return apps
|
return apps
|
||||||
|
|
||||||
|
|
||||||
def update(app_ref: str, installation: str, related: bool = False, deps: bool = False) -> SimpleProcess:
|
def update(app_ref: str, installation: str, version: Version, related: bool = False, deps: bool = False) -> SimpleProcess:
|
||||||
cmd = ['flatpak', 'update', '-y', app_ref, '--{}'.format(installation)]
|
cmd = ['flatpak', 'update', '-y', app_ref, '--{}'.format(installation)]
|
||||||
|
|
||||||
if not related:
|
if not related:
|
||||||
@@ -166,12 +166,14 @@ def update(app_ref: str, installation: str, related: bool = False, deps: bool =
|
|||||||
if not deps:
|
if not deps:
|
||||||
cmd.append('--no-deps')
|
cmd.append('--no-deps')
|
||||||
|
|
||||||
return SimpleProcess(cmd=cmd, extra_paths={EXPORTS_PATH}, shell=True)
|
return SimpleProcess(cmd=cmd, extra_paths={EXPORTS_PATH}, shell=True,
|
||||||
|
lang=DEFAULT_LANG if version < VERSION_1_12 else None)
|
||||||
|
|
||||||
|
|
||||||
def uninstall(app_ref: str, installation: str) -> SimpleProcess:
|
def uninstall(app_ref: str, installation: str, version: Version) -> SimpleProcess:
|
||||||
return SimpleProcess(cmd=['flatpak', 'uninstall', app_ref, '-y', '--{}'.format(installation)],
|
return SimpleProcess(cmd=['flatpak', 'uninstall', app_ref, '-y', '--{}'.format(installation)],
|
||||||
extra_paths={EXPORTS_PATH},
|
extra_paths={EXPORTS_PATH},
|
||||||
|
lang=DEFAULT_LANG if version < VERSION_1_12 else None,
|
||||||
shell=True)
|
shell=True)
|
||||||
|
|
||||||
|
|
||||||
@@ -229,14 +231,15 @@ def read_updates(version: Version, installation: str) -> Dict[str, set]:
|
|||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
def downgrade(app_ref: str, commit: str, installation: str, root_password: Optional[str]) -> SimpleProcess:
|
def downgrade(app_ref: str, commit: str, installation: str, root_password: Optional[str], version: Version) -> SimpleProcess:
|
||||||
cmd = ['flatpak', 'update', '--no-related', '--no-deps', '--commit={}'.format(commit), app_ref, '-y', '--{}'.format(installation)]
|
cmd = ['flatpak', 'update', '--no-related', '--no-deps', '--commit={}'.format(commit), app_ref, '-y', '--{}'.format(installation)]
|
||||||
|
|
||||||
return SimpleProcess(cmd=cmd,
|
return SimpleProcess(cmd=cmd,
|
||||||
root_password=root_password if installation=='system' else None,
|
root_password=root_password if installation == 'system' else None,
|
||||||
extra_paths={EXPORTS_PATH},
|
extra_paths={EXPORTS_PATH},
|
||||||
success_phrases={'Changes complete.', 'Updates complete.'},
|
lang=DEFAULT_LANG if version < VERSION_1_12 else None,
|
||||||
wrong_error_phrases={'Warning'})
|
success_phrases={'Changes complete.', 'Updates complete.'} if version < VERSION_1_12 else None,
|
||||||
|
wrong_error_phrases={'Warning'} if version < VERSION_1_12 else None)
|
||||||
|
|
||||||
|
|
||||||
def get_app_commits(app_ref: str, origin: str, installation: str, handler: ProcessHandler) -> Optional[List[str]]:
|
def get_app_commits(app_ref: str, origin: str, installation: str, handler: ProcessHandler) -> Optional[List[str]]:
|
||||||
@@ -282,13 +285,13 @@ def get_app_commits_data(app_ref: str, origin: str, installation: str, full_str:
|
|||||||
|
|
||||||
def search(version: Version, word: str, installation: str, app_id: bool = False) -> List[dict]:
|
def search(version: Version, word: str, installation: str, app_id: bool = False) -> List[dict]:
|
||||||
|
|
||||||
res = run_cmd('{} search {} --{}'.format('flatpak', word, installation))
|
res = run_cmd('{} search {} --{}'.format('flatpak', word, installation), lang=None)
|
||||||
|
|
||||||
found = []
|
found = []
|
||||||
|
|
||||||
split_res = res.split('\n')
|
split_res = res.strip().split('\n')
|
||||||
|
|
||||||
if split_res and split_res[0].lower() != 'no matches found':
|
if split_res and '\t' in split_res[0]:
|
||||||
for info in split_res:
|
for info in split_res:
|
||||||
if info:
|
if info:
|
||||||
info_list = info.split('\t')
|
info_list = info.split('\t')
|
||||||
@@ -359,10 +362,11 @@ def search(version: Version, word: str, installation: str, app_id: bool = False)
|
|||||||
return found
|
return found
|
||||||
|
|
||||||
|
|
||||||
def install(app_id: str, origin: str, installation: str) -> SimpleProcess:
|
def install(app_id: str, origin: str, installation: str, version: Version) -> SimpleProcess:
|
||||||
return SimpleProcess(cmd=['flatpak', 'install', origin, app_id, '-y', '--{}'.format(installation)],
|
return SimpleProcess(cmd=['flatpak', 'install', origin, app_id, '-y', '--{}'.format(installation)],
|
||||||
extra_paths={EXPORTS_PATH},
|
extra_paths={EXPORTS_PATH},
|
||||||
wrong_error_phrases={'Warning'},
|
lang=DEFAULT_LANG if version < VERSION_1_12 else None,
|
||||||
|
wrong_error_phrases={'Warning'} if version < VERSION_1_12 else None,
|
||||||
shell=True)
|
shell=True)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,9 @@ class FlatpakAsyncDataLoader(Thread):
|
|||||||
if not self.app.name:
|
if not self.app.name:
|
||||||
self.app.name = data.get('name')
|
self.app.name = data.get('name')
|
||||||
|
|
||||||
|
if not self.app.description:
|
||||||
self.app.description = data.get('description', data.get('summary', None))
|
self.app.description = data.get('description', data.get('summary', None))
|
||||||
|
|
||||||
self.app.icon_url = data.get('iconMobileUrl', None)
|
self.app.icon_url = data.get('iconMobileUrl', None)
|
||||||
self.app.latest_version = data.get('currentReleaseVersion', self.app.version)
|
self.app.latest_version = data.get('currentReleaseVersion', self.app.version)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user