[fix][flatpak] displaying a wrong popup message when an error happens during commits reading within the downgrade process

This commit is contained in:
Vinícius Moreira
2020-01-22 17:34:24 -03:00
parent ffa7611930
commit 4931cf590a
3 changed files with 20 additions and 20 deletions

View File

@@ -23,6 +23,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- not pre-downloading some source files ( e.g: from **anbox-image** )
- not able to install packages based on other packages ( package name != package base )
- downgrade: pre-downloading sources from the latest version instead of the older
- Flatpak:
- displaying "No Internet connection" when an error happens during commits reading within the downgrade process
- UI:
- **About** window icons scaling

View File

@@ -151,11 +151,15 @@ class FlatpakManager(SoftwareManager):
return SearchResult(models, None, len(models))
def downgrade(self, pkg: FlatpakApplication, root_password: str, watcher: ProcessWatcher) -> bool:
handler = ProcessHandler(watcher)
pkg.commit = flatpak.get_commit(pkg.id, pkg.branch, pkg.installation)
watcher.change_progress(10)
watcher.change_substatus(self.i18n['flatpak.downgrade.commits'])
commits = flatpak.get_app_commits(pkg.ref, pkg.origin, pkg.installation)
commits = flatpak.get_app_commits(pkg.ref, pkg.origin, pkg.installation, handler)
if commits is None:
return False
commit_idx = commits.index(pkg.commit)
@@ -167,9 +171,9 @@ class FlatpakManager(SoftwareManager):
commit = commits[commit_idx + 1]
watcher.change_substatus(self.i18n['flatpak.downgrade.reverting'])
watcher.change_progress(50)
success = ProcessHandler(watcher).handle(SystemProcess(subproc=flatpak.downgrade(pkg.ref, commit, pkg.installation, root_password),
success_phrases=['Changes complete.', 'Updates complete.'],
wrong_error_phrase='Warning'))
success = handler.handle(SystemProcess(subproc=flatpak.downgrade(pkg.ref, commit, pkg.installation, root_password),
success_phrases=['Changes complete.', 'Updates complete.'],
wrong_error_phrase='Warning'))
watcher.change_progress(100)
return success

View File

@@ -5,7 +5,7 @@ from datetime import datetime
from typing import List, Dict, Set
from bauh.api.exception import NoInternetException
from bauh.commons.system import new_subprocess, run_cmd, new_root_subprocess, SimpleProcess
from bauh.commons.system import new_subprocess, run_cmd, new_root_subprocess, SimpleProcess, ProcessHandler
BASE_CMD = 'flatpak'
RE_SEVERAL_SPACES = re.compile(r'\s+')
@@ -150,15 +150,6 @@ def update(app_ref: str, installation: str):
return new_subprocess([BASE_CMD, 'update', '--no-related', '--no-deps', '-y', app_ref, '--{}'.format(installation)])
def register_flathub(installation: str) -> SimpleProcess:
return SimpleProcess([BASE_CMD,
'remote-add',
'--if-not-exists',
'flathub',
'https://flathub.org/repo/flathub.flatpakrepo',
'--{}'.format(installation)])
def uninstall(app_ref: str, installation: str):
"""
Removes the app by its reference
@@ -228,12 +219,15 @@ def downgrade(app_ref: str, commit: str, installation: str, root_password: str)
return new_subprocess(cmd)
def get_app_commits(app_ref: str, origin: str, installation: str) -> List[str]:
log = run_cmd('{} remote-info --log {} {} --{}'.format(BASE_CMD, origin, app_ref, installation))
if log:
return re.findall(r'Commit+:\s(.+)', log)
else:
def get_app_commits(app_ref: str, origin: str, installation: str, handler: ProcessHandler) -> List[str]:
try:
p = SimpleProcess(['flatpak', 'remote-info', '--log', origin, app_ref, '--{}'.format(installation)])
success, output = handler.handle_simple(p)
if output.startswith('error:'):
return
else:
return re.findall(r'Commit+:\s(.+)', output)
except:
raise NoInternetException()