mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 02:24:16 +02:00
[arch] fix: crashing when no AUR package name is informed to the AUR client
This commit is contained in:
@@ -113,28 +113,29 @@ class AURClient:
|
|||||||
return self.http_client.get_json(URL_SEARCH + words)
|
return self.http_client.get_json(URL_SEARCH + words)
|
||||||
|
|
||||||
def get_info(self, names: Iterable[str]) -> Optional[List[dict]]:
|
def get_info(self, names: Iterable[str]) -> Optional[List[dict]]:
|
||||||
try:
|
if names:
|
||||||
res = self.http_client.get_json(URL_INFO + self._map_names_as_queries(names))
|
try:
|
||||||
except requests.exceptions.ConnectionError:
|
res = self.http_client.get_json(URL_INFO + self._map_names_as_queries(names))
|
||||||
self.logger.warning('Could not retrieve installed AUR packages API data. It seems the internet connection is off.')
|
except requests.exceptions.ConnectionError:
|
||||||
return
|
self.logger.warning('Could not retrieve installed AUR packages API data. It seems the internet connection is off.')
|
||||||
|
return
|
||||||
|
|
||||||
if res is None:
|
if res is None:
|
||||||
self.logger.warning("Call to AUR API's info endpoint has failed")
|
self.logger.warning("Call to AUR API's info endpoint has failed")
|
||||||
return
|
return
|
||||||
|
|
||||||
error = res.get('error')
|
error = res.get('error')
|
||||||
|
|
||||||
if error:
|
if error:
|
||||||
self.logger.warning(f"AUR API's info endpoint returned an unexpected error: {error}")
|
self.logger.warning(f"AUR API's info endpoint returned an unexpected error: {error}")
|
||||||
return
|
return
|
||||||
|
|
||||||
results = res.get('results')
|
results = res.get('results')
|
||||||
|
|
||||||
if results is not None:
|
if results is not None:
|
||||||
return results
|
return results
|
||||||
|
|
||||||
self.logger.warning(f"AUR API's info endpoint returned an unexpected response: {res}")
|
self.logger.warning(f"AUR API's info endpoint returned an unexpected response: {res}")
|
||||||
|
|
||||||
def map_provided(self, pkgname: str, pkgver: str, provided: Optional[Iterable[str]] = None, strip_epoch: bool = True) -> Set[str]:
|
def map_provided(self, pkgname: str, pkgver: str, provided: Optional[Iterable[str]] = None, strip_epoch: bool = True) -> Set[str]:
|
||||||
all_provided = {pkgname, f"{pkgname}={pkgver.split('-')[0] if strip_epoch else pkgver}"}
|
all_provided = {pkgname, f"{pkgname}={pkgver.split('-')[0] if strip_epoch else pkgver}"}
|
||||||
@@ -195,7 +196,7 @@ class AURClient:
|
|||||||
self.logger.warning('No .SRCINFO found for {}'.format(name))
|
self.logger.warning('No .SRCINFO found for {}'.format(name))
|
||||||
self.logger.info('Checking if {} is based on another package'.format(name))
|
self.logger.info('Checking if {} is based on another package'.format(name))
|
||||||
# if was not found, it may be based on another package.
|
# if was not found, it may be based on another package.
|
||||||
infos = self.get_info({name})
|
infos = self.get_info((name,))
|
||||||
|
|
||||||
if infos:
|
if infos:
|
||||||
info = infos[0]
|
info = infos[0]
|
||||||
|
|||||||
@@ -264,24 +264,26 @@ class DependenciesAnalyser:
|
|||||||
aur_search = self.aur_client.search(dep_name)
|
aur_search = self.aur_client.search(dep_name)
|
||||||
|
|
||||||
if aur_search:
|
if aur_search:
|
||||||
if dep_name == dep_exp:
|
aur_results = aur_search.get('results')
|
||||||
version_required, exp_op = None, None
|
|
||||||
else:
|
|
||||||
split_informed_dep = self.re_dep_operator.split(dep_exp)
|
|
||||||
version_required = split_informed_dep[2]
|
|
||||||
exp_op = split_informed_dep[1] if split_informed_dep[1] != '=' else '=='
|
|
||||||
|
|
||||||
for pkgname, pkgdata in self.aur_client.gen_updates_data(
|
if aur_results:
|
||||||
(aur_res['Name'] for aur_res in aur_search['results'])):
|
if dep_name == dep_exp:
|
||||||
if pkgname == dep_name or (dep_name in pkgdata['p']):
|
version_required, exp_op = None, None
|
||||||
try:
|
else:
|
||||||
if not version_required or match_required_version(pkgdata['v'], exp_op,
|
split_informed_dep = self.re_dep_operator.split(dep_exp)
|
||||||
version_required):
|
version_required = split_informed_dep[2]
|
||||||
yield pkgname, pkgdata
|
exp_op = split_informed_dep[1] if split_informed_dep[1] != '=' else '=='
|
||||||
except:
|
|
||||||
self._log.warning(f"Could not compare AUR package '{pkgname}' version '{pkgdata['v']}' "
|
for pkgname, pkgdata in self.aur_client.gen_updates_data((aur_res['Name'] for aur_res in aur_results)):
|
||||||
f"with the dependency expression '{dep_exp}'")
|
if pkgname == dep_name or (dep_name in pkgdata['p']):
|
||||||
traceback.print_exc()
|
try:
|
||||||
|
if not version_required or match_required_version(pkgdata['v'], exp_op,
|
||||||
|
version_required):
|
||||||
|
yield pkgname, pkgdata
|
||||||
|
except:
|
||||||
|
self._log.warning(f"Could not compare AUR package '{pkgname}' version '{pkgdata['v']}' "
|
||||||
|
f"with the dependency expression '{dep_exp}'")
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
def _fill_missing_dep(self, dep_name: str, dep_exp: str, aur_index: Iterable[str],
|
def _fill_missing_dep(self, dep_name: str, dep_exp: str, aur_index: Iterable[str],
|
||||||
missing_deps: Set[Tuple[str, str]],
|
missing_deps: Set[Tuple[str, str]],
|
||||||
@@ -382,8 +384,9 @@ class DependenciesAnalyser:
|
|||||||
raise PackageNotFoundException(dep_exp)
|
raise PackageNotFoundException(dep_exp)
|
||||||
|
|
||||||
def _fill_aur_updates_data(self, pkgnames: Iterable[str], output_data: dict):
|
def _fill_aur_updates_data(self, pkgnames: Iterable[str], output_data: dict):
|
||||||
for pkgname, pkgdata in self.aur_client.gen_updates_data(pkgnames):
|
if pkgnames:
|
||||||
output_data[pkgname] = pkgdata
|
for pkgname, pkgdata in self.aur_client.gen_updates_data(pkgnames):
|
||||||
|
output_data[pkgname] = pkgdata
|
||||||
|
|
||||||
def map_missing_deps(self, pkgs_data: Dict[str, dict], provided_map: Dict[str, Set[str]],
|
def map_missing_deps(self, pkgs_data: Dict[str, dict], provided_map: Dict[str, Set[str]],
|
||||||
remote_provided_map: Dict[str, Set[str]], remote_repo_map: Dict[str, str],
|
remote_provided_map: Dict[str, Set[str]], remote_repo_map: Dict[str, str],
|
||||||
@@ -516,8 +519,9 @@ class DependenciesAnalyser:
|
|||||||
if repo_providers_data:
|
if repo_providers_data:
|
||||||
deps_data.update(repo_providers_data)
|
deps_data.update(repo_providers_data)
|
||||||
|
|
||||||
for pkgname, pkgdata in self.aur_client.gen_updates_data(aur_providers_no_data):
|
if aur_providers_no_data:
|
||||||
deps_data[pkgname] = pkgdata
|
for pkgname, pkgdata in self.aur_client.gen_updates_data(aur_providers_no_data):
|
||||||
|
deps_data[pkgname] = pkgdata
|
||||||
|
|
||||||
if aur_data_filler:
|
if aur_data_filler:
|
||||||
aur_data_filler.join()
|
aur_data_filler.join()
|
||||||
|
|||||||
Reference in New Issue
Block a user