mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-09 16:44:15 +02:00
[fix][arch] not stopping the upgrade process if a transaction error happens
This commit is contained in:
@@ -10,8 +10,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
- Arch
|
- Arch
|
||||||
|
- not stopping the upgrade process if a transaction error happens
|
||||||
- wrong dialog titles
|
- wrong dialog titles
|
||||||
|
|
||||||
|
|
||||||
## [0.9.0] - 2020-04-15
|
## [0.9.0] - 2020-04-15
|
||||||
### Features
|
### Features
|
||||||
- Backup
|
- Backup
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ class SimpleProcess:
|
|||||||
|
|
||||||
def __init__(self, cmd: List[str], cwd: str = '.', expected_code: int = None,
|
def __init__(self, cmd: List[str], cwd: str = '.', expected_code: int = None,
|
||||||
global_interpreter: bool = USE_GLOBAL_INTERPRETER, lang: str = DEFAULT_LANG, root_password: str = None,
|
global_interpreter: bool = USE_GLOBAL_INTERPRETER, lang: str = DEFAULT_LANG, root_password: str = None,
|
||||||
extra_paths: Set[str] = None):
|
extra_paths: Set[str] = None, error_phrases: Set[str] = None):
|
||||||
pwdin, final_cmd = None, []
|
pwdin, final_cmd = None, []
|
||||||
|
|
||||||
if root_password is not None:
|
if root_password is not None:
|
||||||
@@ -76,6 +76,7 @@ class SimpleProcess:
|
|||||||
|
|
||||||
self.instance = self._new(final_cmd, cwd, global_interpreter, lang, stdin=pwdin, extra_paths=extra_paths)
|
self.instance = self._new(final_cmd, cwd, global_interpreter, lang, stdin=pwdin, extra_paths=extra_paths)
|
||||||
self.expected_code = expected_code
|
self.expected_code = expected_code
|
||||||
|
self.error_phrases = error_phrases
|
||||||
|
|
||||||
def _new(self, cmd: List[str], cwd: str, global_interpreter: bool, lang: str, stdin = None, extra_paths: Set[str] = None) -> subprocess.Popen:
|
def _new(self, cmd: List[str], cwd: str, global_interpreter: bool, lang: str, stdin = None, extra_paths: Set[str] = None) -> subprocess.Popen:
|
||||||
|
|
||||||
@@ -175,8 +176,18 @@ class ProcessHandler:
|
|||||||
|
|
||||||
self._notify_watcher(line)
|
self._notify_watcher(line)
|
||||||
|
|
||||||
|
proc.instance.wait()
|
||||||
output.seek(0)
|
output.seek(0)
|
||||||
return proc.instance.returncode == proc.expected_code, output.read()
|
|
||||||
|
success = proc.instance.returncode == proc.expected_code,
|
||||||
|
string_output = output.read()
|
||||||
|
|
||||||
|
if proc.error_phrases:
|
||||||
|
for phrase in proc.error_phrases:
|
||||||
|
if phrase in string_output:
|
||||||
|
success = False
|
||||||
|
break
|
||||||
|
return success, string_output
|
||||||
|
|
||||||
|
|
||||||
def run_cmd(cmd: str, expected_code: int = 0, ignore_return_code: bool = False, print_error: bool = True,
|
def run_cmd(cmd: str, expected_code: int = 0, ignore_return_code: bool = False, print_error: bool = True,
|
||||||
|
|||||||
@@ -741,7 +741,7 @@ class ArchManager(SoftwareManager):
|
|||||||
disk.save_several(repo_pkgs_names, repo_map=repo_map, overwrite=True, maintainer=None)
|
disk.save_several(repo_pkgs_names, repo_map=repo_map, overwrite=True, maintainer=None)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.logger.error("'pacman' returned an unexpected response after upgrading the repository packages")
|
self.logger.error("'pacman' returned an unexpected response or error phrase after upgrading the repository packages")
|
||||||
return False
|
return False
|
||||||
except:
|
except:
|
||||||
watcher.change_substatus('')
|
watcher.change_substatus('')
|
||||||
|
|||||||
@@ -141,7 +141,10 @@ def install_as_process(pkgpaths: Iterable[str], root_password: str, file: bool,
|
|||||||
else:
|
else:
|
||||||
cmd = ['pacman', '-S', *pkgpaths, '--noconfirm'] # pkgpath = pkgname
|
cmd = ['pacman', '-S', *pkgpaths, '--noconfirm'] # pkgpath = pkgname
|
||||||
|
|
||||||
return SimpleProcess(cmd=cmd, root_password=root_password, cwd=pkgdir)
|
return SimpleProcess(cmd=cmd,
|
||||||
|
root_password=root_password,
|
||||||
|
cwd=pkgdir,
|
||||||
|
error_phrases={"error: failed to prepare transaction"})
|
||||||
|
|
||||||
|
|
||||||
def list_desktop_entries(pkgnames: Set[str]) -> List[str]:
|
def list_desktop_entries(pkgnames: Set[str]) -> List[str]:
|
||||||
@@ -692,7 +695,9 @@ def list_installed_names() -> Set[str]:
|
|||||||
|
|
||||||
|
|
||||||
def upgrade_several(pkgnames: Iterable[str], root_password: str) -> SimpleProcess:
|
def upgrade_several(pkgnames: Iterable[str], root_password: str) -> SimpleProcess:
|
||||||
return SimpleProcess(cmd=['pacman', '-S', *pkgnames, '--noconfirm'], root_password=root_password)
|
return SimpleProcess(cmd=['pacman', '-S', *pkgnames, '--noconfirm'],
|
||||||
|
root_password=root_password,
|
||||||
|
error_phrases={'error: failed to prepare transaction'})
|
||||||
|
|
||||||
|
|
||||||
def remove_several(pkgnames: Iterable[str], root_password: str) -> SystemProcess:
|
def remove_several(pkgnames: Iterable[str], root_password: str) -> SystemProcess:
|
||||||
|
|||||||
Reference in New Issue
Block a user