[arch] fix -> crashing when information of a given package is not available

This commit is contained in:
Vinicius Moreira
2021-01-02 10:13:53 -03:00
parent 579ea91dcc
commit 4d0660e0ea
15 changed files with 53 additions and 19 deletions

View File

@@ -1417,21 +1417,23 @@ class ArchManager(SoftwareManager):
t.start()
info = pacman.get_info_dict(pkg.name)
self._parse_dates_string_from_info(pkg.name, info)
if pkg.commit:
info['commit'] = pkg.commit
if info is not None:
self._parse_dates_string_from_info(pkg.name, info)
if pkg.last_modified:
info['last_modified'] = self._parse_timestamp(ts=pkg.last_modified,
error_msg="Could not parse AUR package '{}' 'last_modified' field ({})".format(pkg.name, pkg.last_modified))
if pkg.commit:
info['commit'] = pkg.commit
t.join()
if pkg.last_modified:
info['last_modified'] = self._parse_timestamp(ts=pkg.last_modified,
error_msg="Could not parse AUR package '{}' 'last_modified' field ({})".format(pkg.name, pkg.last_modified))
if pkg.pkgbuild:
info['13_pkg_build'] = pkg.pkgbuild
t.join()
info['14_installed_files'] = pacman.list_installed_files(pkg.name)
if pkg.pkgbuild:
info['13_pkg_build'] = pkg.pkgbuild
info['14_installed_files'] = pacman.list_installed_files(pkg.name)
return info
else:
@@ -1501,9 +1503,12 @@ class ArchManager(SoftwareManager):
def _get_info_repo_pkg(self, pkg: ArchPackage) -> dict:
info = pacman.get_info_dict(pkg.name, remote=not pkg.installed)
self._parse_dates_string_from_info(pkg.name, info)
if pkg.installed:
info['installed files'] = pacman.list_installed_files(pkg.name)
if info is not None:
self._parse_dates_string_from_info(pkg.name, info)
if pkg.installed:
info['installed files'] = pacman.list_installed_files(pkg.name)
return info

View File

@@ -69,7 +69,7 @@ def get_info_list(pkg_name: str, remote: bool = False) -> List[tuple]:
return re.findall(r'(\w+\s?\w+)\s*:\s*(.+(\n\s+.+)*)', info)
def get_info_dict(pkg_name: str, remote: bool = False) -> dict:
def get_info_dict(pkg_name: str, remote: bool = False) -> Optional[dict]:
list_attrs = {'depends on', 'required by', 'conflicts with'}
info_list = get_info_list(pkg_name, remote)