From a918727374da68eee4efea99437553e2420dd77c Mon Sep 17 00:00:00 2001 From: Troy Dawson Date: Oct 31 2022 21:25:26 +0000 Subject: Clean code, fix rhel7 --- diff --git a/src/centpkg-sig.conf b/src/centpkg-sig.conf index e75eb01..324124c 100644 --- a/src/centpkg-sig.conf +++ b/src/centpkg-sig.conf @@ -3,8 +3,6 @@ lookaside = https://git.centos.org/sources lookasidehash = sha512 lookaside_cgi = https://git.centos.org/sources/upload_sig.cgi # lookaside_cgi = https://git.centos.org/sources/upload.cgi -lookaside_structure = hash -# lookaside_structure = branch distgit_namespaced = True distgit_namespaces = rpms gitbaseurl = ssh://git@git.centos.org/%(repo)s.git diff --git a/src/centpkg/__init__.py b/src/centpkg/__init__.py index 044094b..c161d73 100644 --- a/src/centpkg/__init__.py +++ b/src/centpkg/__init__.py @@ -153,11 +153,6 @@ class Commands(Commands): # should only be used when configured for SHA512 self.source_entry_type = 'bsd' if self.lookasidehash != 'md5' else 'old' self.branchre = 'c\d{1,}(s)?(tream)?|master' - self.lookaside_structure = None - - def update(self, config): - if self.lookaside_structure is None: - self.lookaside_structure = config.get('lookaside_structure', 'hash') @property def distgitdir(self): @@ -172,17 +167,12 @@ class Commands(Commands): ) else: if self.distgitdir.sigbranch: - self.log.info(" Centpkg: Commands lookasidecache: SIGLookasideCache") - self.log.info(" lookaside_structure " + self.lookaside_structure) return SIGLookasideCache(self.lookasidehash, self.lookaside, self.lookaside_cgi, self.repo_name, - self.branch_merge, - structure=self.lookaside_structure) + self.branch_merge) else: - self.log.info(" Centpkg: Commands lookasidecache: CLLookasideCache") - self.log.info(" lookaside_structure " + self.lookaside_structure) return CLLookasideCache(self.lookasidehash, self.lookaside, self.lookaside_cgi, diff --git a/src/centpkg/cli.py b/src/centpkg/cli.py index faebb0d..61202fb 100755 --- a/src/centpkg/cli.py +++ b/src/centpkg/cli.py @@ -35,11 +35,6 @@ class centpkgClient(cliClient): self.setup_centos_subparsers() - def load_cmd(self): - super(centpkgClient, self).load_cmd() - cfg = self.config[self.get_name()] - self._cmd.update(cfg) - def setup_centos_subparsers(self): self.register_do_fork() self.register_request_gated_side_tag() diff --git a/src/centpkg/lookaside.py b/src/centpkg/lookaside.py index 5193e12..9de5157 100644 --- a/src/centpkg/lookaside.py +++ b/src/centpkg/lookaside.py @@ -94,7 +94,7 @@ class StreamLookasideCache(CGILookasideCache): return super(StreamLookasideCache, self).remote_file_exists( _name, filename, hashstr) - def upload(self, name, filename, hashstr, offline=False, **kwargs): + def upload(self, name, filename, hashstr, offline=False): """ Uploads a file to lookaside cache. @@ -178,14 +178,11 @@ class CLLookasideCache(CGILookasideCache): def __init__(self, hashtype, download_url, upload_url, name, branch): super(CLLookasideCache, self).__init__( hashtype, download_url, upload_url, name, branch) - self.log.info(" Centpkg: CLLookasideCache __init__") self.name = name self.branch = branch def get_download_url(self, name, filename, hash, hashtype=None, **kwargs): - print(" Centpkg: CLLookasideCache get_download_url") self.download_path='%(name)s/%(branch)s/%(hash)s' - print(" Centpkg: CLLookasideCache get_download_url download_path: " + self.download_path) if "/" in name: real_name = name.split("/")[-1] else: @@ -207,32 +204,28 @@ class SIGLookasideCache(CGILookasideCache): It inherits most of its behavior from `pyrpkg.lookasideCGILookasideCache`. """ - def __init__(self, hashtype, download_url, upload_url, name, branch, structure='hash', client_cert=None, ca_cert=None): + def __init__(self, hashtype, download_url, upload_url, name, branch, client_cert=None, ca_cert=None): super(SIGLookasideCache, self).__init__( hashtype, download_url, upload_url, client_cert=client_cert, ca_cert=ca_cert) self.name = name self.branch = branch - self.structure = structure def get_download_url(self, name, filename, hash, hashtype=None, **kwargs): - if self.structure == 'hash': - download_path = '%(name)s/%(branch)s/%(hash)s' - if "/" in name: - real_name = name.split("/")[-1] - else: - real_name = name - path_dict = { - 'name': real_name, - 'filename': filename, - 'branch': self.branch, - 'hash': hash, - 'hashtype': hashtype - } - path = download_path % path_dict - return os.path.join(self.download_url, path) - - return super(SIGLookasideCache, self).get_download_url(name, filename, hash, hashtype, **kwargs) + download_path = '%(name)s/%(branch)s/%(hash)s' + if "/" in name: + real_name = name.split("/")[-1] + else: + real_name = name + path_dict = { + 'name': real_name, + 'filename': filename, + 'branch': self.branch, + 'hash': hash, + 'hashtype': hashtype + } + path = download_path % path_dict + return os.path.join(self.download_url, path) def remote_file_exists(self, name, filename, hash): """Verify whether a file exists on the lookaside cache @@ -259,8 +252,6 @@ class SIGLookasideCache(CGILookasideCache): post_data = [('name', _name), ('%ssum' % self.hashtype, hash), ('filename', filename)] - if self.structure == 'branch': - post_data.append(('branch', self.branch)) with io.BytesIO() as buf: c = pycurl.Curl() @@ -338,8 +329,6 @@ class SIGLookasideCache(CGILookasideCache): post_data = [('name', name), ('%ssum' % self.hashtype, hash), ('file', (pycurl.FORM_FILE, filepath))] - if self.structure == 'branch': - post_data.append(('branch', self.branch)) with io.BytesIO() as buf: c = pycurl.Curl()