add options nowait for build command

This commit is contained in:
Vyacheslav Anzhiganov 2025-01-26 08:47:21 +03:00
parent e0e386c804
commit f310aa46f5

View file

@ -4,7 +4,7 @@ import hmac
import logging import logging
import configparser import configparser
import subprocess import subprocess
from flask import Flask, request, abort, current_app from flask import Flask, request, abort
import koji import koji
# Load configuration from .ini file # 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_SERVER'] = config.get('DEFAULT', 'KOJI_SERVER')
app.config['KOJI_TARGET'] = config.get('DEFAULT', 'KOJI_TARGET') app.config['KOJI_TARGET'] = config.get('DEFAULT', 'KOJI_TARGET')
app.config['KOJI_USE_SHELL'] = config.getboolean('DEFAULT', 'KOJI_USE_SHELL') 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') app.config['WEBHOOK_SECRET_KEY'] = config.get('DEFAULT', 'WEBHOOK_SECRET_KEY')
@ -24,10 +25,11 @@ class KojiProcessor:
def __init__(self): def __init__(self):
pass pass
def koji_build_shell(self, build_target, git_url): def koji_build_shell(self, build_target, git_url, nowait=True):
try: try:
# Construct the koji build command # 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 # Start the build process
result = subprocess.run(command, check=True, capture_output=True, text=True) result = subprocess.run(command, check=True, capture_output=True, text=True)
@ -39,7 +41,7 @@ class KojiProcessor:
logging.error("Error starting build:") logging.error("Error starting build:")
logging.error(e.stderr) 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 Perform a Koji build
@ -61,7 +63,7 @@ class KojiProcessor:
build_target, # Build target build_target, # Build target
opts={ opts={
'scratch': False, # Set to True for scratch build 'scratch': False, # Set to True for scratch build
'nowait': False # Wait for build completion 'nowait': nowait # Wait for build completion
} }
) )