diff --git a/slpkg/update_repositories.py b/slpkg/update_repositories.py index aed3d063..33fdea4a 100644 --- a/slpkg/update_repositories.py +++ b/slpkg/update_repositories.py @@ -58,16 +58,19 @@ class UpdateRepositories(Configs): # pylint: disable=[R0902] mirror (str): Repository GPG mirror key. """ if self.gpg_verification: - gpg_key: str = f'{mirror}GPG-KEY' + gpg_key: str = f'{mirror}GPG-KEYa' gpg_command: str = 'gpg --fetch-key' - process = subprocess.run(f'{gpg_command} {gpg_key}', shell=True, stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, encoding='utf-8', text=True, check=True) + try: + process = subprocess.run(f'{gpg_command} {gpg_key}', shell=True, stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, encoding='utf-8', text=True, check=True) + except subprocess.CalledProcessError as e: + print(f'Getting GPG key: {self.bred}Failed{self.endc}\n') + raise SystemExit(2) from e output: str = re.split(r"/|\s", process.stdout) - - if 'imported:' in output: - print(f'Getting GPG key from: {gpg_key}\n') + if process.returncode == 0 and 'imported:' in output: + print(f'Getting GPG key from: {mirror}\n') def run_update(self) -> None: """ Update the repositories by category.