From 1963a577a2c88c65b18d117bbfe8f01e8d6f8772 Mon Sep 17 00:00:00 2001 From: lrossett Date: Sep 09 2020 14:26:18 +0000 Subject: lookaside cache --- diff --git a/src/centpkg/cli/__init__.py b/src/centpkg/cli/__init__.py index 3963485..4c8761b 100644 --- a/src/centpkg/cli/__init__.py +++ b/src/centpkg/cli/__init__.py @@ -5,9 +5,27 @@ import logging import configparser import pyrpkg.utils +import pyrpkg # import pyrpkg.cli import centpkg.api.cli +from . import lookaside + + +class Commands(pyrpkg.Commands): + def __init__(self, *args, **kwargs): + """Init the object and some configuration details.""" + super(Commands, self).__init__(*args, **kwargs) + + def lookasidecache(self): + """A helper to interact with the lookaside cache + + We override this because we need a different download path. + """ + @pyrpkg.utils.cached_property + def lookasidecache(self): + return lookaside.CentOSLookasideCache( + self.lookasidehash, self.lookaside, self.lookaside_cgi) def get_log(client): @@ -34,9 +52,10 @@ def run(*args, **kwargs): """ cli_name = 'centpkg' parser = argparse.ArgumentParser(add_help=False) + parser.add_argument( '-C', '--config', help='Specify a config file to use', - default='/etc/rpkg/rpkg.conf') + default='/etc/centpkg/centpkg.conf') (args, other) = parser.parse_known_args() if not os.path.exists(args.config) and not other[-1] in ['--help', '-h']: @@ -47,7 +66,7 @@ def run(*args, **kwargs): config.read(args.config) client = centpkg.api.cli.CentPkgCli(config) - client.do_imports() + client.do_imports('centpkg') client.parse_cmdline() if not client.args.path: diff --git a/src/centpkg/cli/lookaside.py b/src/centpkg/cli/lookaside.py new file mode 100644 index 0000000..576b290 --- /dev/null +++ b/src/centpkg/cli/lookaside.py @@ -0,0 +1,26 @@ +# Copyright (c) 2020 - Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. See http://www.gnu.org/copyleft/gpl.html for +# the full text of the license. + + +"""Interact with the Fedora lookaside cache + +We need to override the pyrpkg.lookasidecache module to handle our custom +download path. +""" + + +from pyrpkg.lookaside import CGILookasideCache + + +class CentOSLookasideCache(CGILookasideCache): + """ + Centos pkg cache rpkg subclass. + """ + def __init__(self, *args, **kwargs): + super(CentOSLookasideCache, self).__init__(*args, **kwargs) + self.download_path = ('%(name)s/%(branch)s/%(hash)s')