From f310aa46f57d833b034bda4be855dd5f17c79265 Mon Sep 17 00:00:00 2001 From: vanzhiganov Date: Sun, 26 Jan 2025 08:47:21 +0300 Subject: [PATCH] add options nowait for build command --- koji_forgejo_webhook.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/koji_forgejo_webhook.py b/koji_forgejo_webhook.py index b3a9c87..beb8a5c 100644 --- a/koji_forgejo_webhook.py +++ b/koji_forgejo_webhook.py @@ -4,7 +4,7 @@ import hmac import logging import configparser import subprocess -from flask import Flask, request, abort, current_app +from flask import Flask, request, abort import koji # Load configuration from .ini file @@ -17,6 +17,7 @@ app.config['SECRET_KEY'] = config.get('DEFAULT', 'SECRET_KEY') app.config['KOJI_SERVER'] = config.get('DEFAULT', 'KOJI_SERVER') app.config['KOJI_TARGET'] = config.get('DEFAULT', 'KOJI_TARGET') app.config['KOJI_USE_SHELL'] = config.getboolean('DEFAULT', 'KOJI_USE_SHELL') +app.config['KOJI_NOWAIT'] = config.getboolean('DEFAULT', 'KOJI_NOWAIT', True) app.config['WEBHOOK_SECRET_KEY'] = config.get('DEFAULT', 'WEBHOOK_SECRET_KEY') @@ -24,10 +25,11 @@ class KojiProcessor: def __init__(self): pass - def koji_build_shell(self, build_target, git_url): + def koji_build_shell(self, build_target, git_url, nowait=True): try: # Construct the koji build command - command = ['koji', 'build', build_target, git_url] + nw = '--nowait' if nowait else '' + command = ['koji', 'build', nw, build_target, git_url] # Start the build process result = subprocess.run(command, check=True, capture_output=True, text=True) @@ -39,7 +41,7 @@ class KojiProcessor: logging.error("Error starting build:") logging.error(e.stderr) - def koji_build(self, server_url, build_target, source_url): + def koji_build(self, server_url, build_target, source_url, nowait=True): """ Perform a Koji build @@ -61,7 +63,7 @@ class KojiProcessor: build_target, # Build target opts={ 'scratch': False, # Set to True for scratch build - 'nowait': False # Wait for build completion + 'nowait': nowait # Wait for build completion } )