| |
@@ -28,6 +28,7 @@
|
| |
|
| |
parser = argparse.ArgumentParser(
|
| |
description="Automatically prune copr result directory")
|
| |
+ parser.add_argument("--path", help="Specify just one project to prune; e.g. /path/to/results/<user>/<project>")
|
| |
parser.add_argument(
|
| |
"--no-mtime-optimization",
|
| |
action='store_true',
|
| |
@@ -71,17 +72,14 @@
|
| |
class Pruner(object):
|
| |
def __init__(self, opts, cmdline_opts=None):
|
| |
self.opts = opts
|
| |
- self.prune_days = getattr(self.opts, "prune_days", DEF_DAYS)
|
| |
- self.chroots = {}
|
| |
self.frontend_client = FrontendClient(self.opts)
|
| |
+ self.prune_days = getattr(self.opts, "prune_days", DEF_DAYS)
|
| |
+ self.chroots = self.fetch_chroots()
|
| |
self.mtime_optimization = True
|
| |
if cmdline_opts:
|
| |
self.mtime_optimization = not cmdline_opts.no_mtime_optimization
|
| |
|
| |
def run(self):
|
| |
- response = self.frontend_client._post_to_frontend_repeatedly("", "chroots-prunerepo-status")
|
| |
- self.chroots = json.loads(response.content)
|
| |
-
|
| |
results_dir = self.opts.destdir
|
| |
loginfo("Pruning results dir: {} ".format(results_dir))
|
| |
user_dir_names, user_dirs = list_subdir(results_dir)
|
| |
@@ -107,6 +105,10 @@
|
| |
loginfo("--------------------------------------------")
|
| |
loginfo("Pruning finished")
|
| |
|
| |
+ def fetch_chroots(self):
|
| |
+ response = self.frontend_client._post_to_frontend_repeatedly("", "chroots-prunerepo-status")
|
| |
+ return json.loads(response.content)
|
| |
+
|
| |
def prune_project(self, project_path, username, projectdir):
|
| |
loginfo("Going to prune {}/{}".format(username, projectdir))
|
| |
|
| |
@@ -183,6 +185,10 @@
|
| |
config_file = os.environ.get("BACKEND_CONFIG", "/etc/copr/copr-be.conf")
|
| |
pruner = Pruner(BackendConfigReader(config_file).read(), args)
|
| |
try:
|
| |
+ if args.path:
|
| |
+ ownername, projectdir = args.path.rstrip("/").split("/")[-2:]
|
| |
+ pruner.prune_project(args.path, ownername, projectdir)
|
| |
+ return
|
| |
pruner.run()
|
| |
except Exception as e:
|
| |
logexception(e)
|
| |
This change was taken from PR#679 to separate PR.