From c03cb5f6eac80e83f3985bcd9870612160631d57 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 1 May 2024 16:57:28 +0300 Subject: [PATCH] Updated for gpg imported --- ChangeLog.txt | 1 + slpkg/install_data.py | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index ca9ffb1d..46ff3c2f 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -8,6 +8,7 @@ - Updated: * Improved code quality + * Updated for check gpg key imported - Added: * Total file size with find command diff --git a/slpkg/install_data.py b/slpkg/install_data.py index eddb3eec..b870612a 100644 --- a/slpkg/install_data.py +++ b/slpkg/install_data.py @@ -4,6 +4,7 @@ import re import json +import subprocess from pathlib import Path from slpkg.configs import Configs @@ -29,13 +30,19 @@ class InstallData(Configs): """ Imports the GPG KEY. Args: - mirror (str): Repository mirror. + mirror (str): Repository GPG mirror key. """ if self.gpg_verification: - print(f'Getting key from:{mirror}') - gpg_command: str = 'gpg --quiet --fetch-key' gpg_key: str = f'{mirror}GPG-KEY' - self.multi_process.process(f'{gpg_command} {gpg_key}') + 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) + + output: str = re.split(r"/|\s", process.stdout) + + if 'imported:' in output: + print(f'Getting GPG key from: {gpg_key}') def write_repo_info(self, changelog_file: Path, info: dict) -> None: """ Reads the first date of the changelog file.""" @@ -77,8 +84,6 @@ class InstallData(Configs): print(f"Updating the database for '{self.cyan}{repo}{self.endc}'... ", end='', flush=True) - self._import_gpg_key(mirror='https://www.slackbuilds.org/') - data: dict = {} cache: list = [] names: list = [] @@ -158,6 +163,7 @@ class InstallData(Configs): data_file.write_text(json.dumps(data, indent=4), encoding='utf-8') self.view_done_message() + self._import_gpg_key(mirror='https://www.slackbuilds.org/') def install_binary_data(self, repo: str) -> None: # pylint: disable=[R0912,R0914,R0915] """ Installs the data for binary repositories. @@ -173,8 +179,6 @@ class InstallData(Configs): if repo in slack_repos: mirror: str = self.repos.repositories[repo]['mirror_changelog'] - self._import_gpg_key(mirror=mirror) - checksums_dict: dict = {} data: dict = {} build: str = '' @@ -292,3 +296,4 @@ class InstallData(Configs): data_file.write_text(json.dumps(data, indent=4), encoding='utf-8') self.view_done_message() + self._import_gpg_key(mirror=mirror)