mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-06 22:54: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)
|
||||
|
||||
def get_info(self, names: Iterable[str]) -> Optional[List[dict]]:
|
||||
try:
|
||||
res = self.http_client.get_json(URL_INFO + self._map_names_as_queries(names))
|
||||
except requests.exceptions.ConnectionError:
|
||||
self.logger.warning('Could not retrieve installed AUR packages API data. It seems the internet connection is off.')
|
||||
return
|
||||
if names:
|
||||
try:
|
||||
res = self.http_client.get_json(URL_INFO + self._map_names_as_queries(names))
|
||||
except requests.exceptions.ConnectionError:
|
||||
self.logger.warning('Could not retrieve installed AUR packages API data. It seems the internet connection is off.')
|
||||
return
|
||||
|
||||
if res is None:
|
||||
self.logger.warning("Call to AUR API's info endpoint has failed")
|
||||
return
|
||||
if res is None:
|
||||
self.logger.warning("Call to AUR API's info endpoint has failed")
|
||||
return
|
||||
|
||||
error = res.get('error')
|
||||
error = res.get('error')
|
||||
|
||||
if error:
|
||||
self.logger.warning(f"AUR API's info endpoint returned an unexpected error: {error}")
|
||||
return
|
||||
if error:
|
||||
self.logger.warning(f"AUR API's info endpoint returned an unexpected error: {error}")
|
||||
return
|
||||
|
||||
results = res.get('results')
|
||||
results = res.get('results')
|
||||
|
||||
if results is not None:
|
||||
return results
|
||||
if results is not None:
|
||||
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]:
|
||||
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.info('Checking if {} is based on another package'.format(name))
|
||||
# if was not found, it may be based on another package.
|
||||
infos = self.get_info({name})
|
||||
infos = self.get_info((name,))
|
||||
|
||||
if infos:
|
||||
info = infos[0]
|
||||
|
||||
@@ -264,24 +264,26 @@ class DependenciesAnalyser:
|
||||
aur_search = self.aur_client.search(dep_name)
|
||||
|
||||
if aur_search:
|
||||
if dep_name == dep_exp:
|
||||
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 '=='
|
||||
aur_results = aur_search.get('results')
|
||||
|
||||
for pkgname, pkgdata in self.aur_client.gen_updates_data(
|
||||
(aur_res['Name'] for aur_res in aur_search['results'])):
|
||||
if pkgname == dep_name or (dep_name in pkgdata['p']):
|
||||
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()
|
||||
if aur_results:
|
||||
if dep_name == dep_exp:
|
||||
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((aur_res['Name'] for aur_res in aur_results)):
|
||||
if pkgname == dep_name or (dep_name in pkgdata['p']):
|
||||
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],
|
||||
missing_deps: Set[Tuple[str, str]],
|
||||
@@ -382,8 +384,9 @@ class DependenciesAnalyser:
|
||||
raise PackageNotFoundException(dep_exp)
|
||||
|
||||
def _fill_aur_updates_data(self, pkgnames: Iterable[str], output_data: dict):
|
||||
for pkgname, pkgdata in self.aur_client.gen_updates_data(pkgnames):
|
||||
output_data[pkgname] = pkgdata
|
||||
if pkgnames:
|
||||
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]],
|
||||
remote_provided_map: Dict[str, Set[str]], remote_repo_map: Dict[str, str],
|
||||
@@ -516,8 +519,9 @@ class DependenciesAnalyser:
|
||||
if repo_providers_data:
|
||||
deps_data.update(repo_providers_data)
|
||||
|
||||
for pkgname, pkgdata in self.aur_client.gen_updates_data(aur_providers_no_data):
|
||||
deps_data[pkgname] = pkgdata
|
||||
if aur_providers_no_data:
|
||||
for pkgname, pkgdata in self.aur_client.gen_updates_data(aur_providers_no_data):
|
||||
deps_data[pkgname] = pkgdata
|
||||
|
||||
if aur_data_filler:
|
||||
aur_data_filler.join()
|
||||
|
||||
Reference in New Issue
Block a user