diff --git a/module_build_service/builder/KojiModuleBuilder.py b/module_build_service/builder/KojiModuleBuilder.py index b8044519..5b56f29a 100644 --- a/module_build_service/builder/KojiModuleBuilder.py +++ b/module_build_service/builder/KojiModuleBuilder.py @@ -356,7 +356,7 @@ class KojiModuleBuilder(GenericBuilder): fd.close() log.debug("Building %s.spec" % name) - # We are not interested in the rpmbuild stdout... + # We are not interested in the rpmbuild output... null_fd = open(os.devnull, "w") execute_cmd( [ @@ -369,7 +369,7 @@ class KojiModuleBuilder(GenericBuilder): "_sourcedir %s" % sources_dir, ], cwd=td, - stdout=null_fd, + output=null_fd, ) null_fd.close() sdir = os.path.join(td, "SRPMS") diff --git a/module_build_service/builder/MockModuleBuilder.py b/module_build_service/builder/MockModuleBuilder.py index ccfc5f29..370339c4 100644 --- a/module_build_service/builder/MockModuleBuilder.py +++ b/module_build_service/builder/MockModuleBuilder.py @@ -646,11 +646,9 @@ class MockModuleBuilder(GenericBuilder): mock_config = os.path.join( self.configdir, "mock-%s.cfg" % str(threading.current_thread().name)) - # Open the logs to which we will forward mock stdout/stderr. - mock_stdout_log = open( - os.path.join(self.resultsdir, artifact_name + "-mock-stdout.log"), "w") - mock_stderr_log = open( - os.path.join(self.resultsdir, artifact_name + "-mock-stderr.log"), "w") + # Open the log to which we will forward mock stdout/stderr. + mock_output_log = open( + os.path.join(self.resultsdir, artifact_name + "-mock-output.log"), "w") srpm = artifact_name resultsdir = builder.resultsdir @@ -658,12 +656,11 @@ class MockModuleBuilder(GenericBuilder): # Initialize mock. execute_cmd( ["mock", "-v", "-r", mock_config, "--init"], - stdout=mock_stdout_log, - stderr=mock_stderr_log, + output=mock_output_log, ) # Start the build and store results to resultsdir - builder.build(mock_stdout_log, mock_stderr_log) + builder.build(mock_output_log) srpm = find_srpm(resultsdir) # Emit messages simulating complete build. These messages @@ -687,8 +684,7 @@ class MockModuleBuilder(GenericBuilder): with open(os.path.join(resultsdir, "status.log"), "w") as f: f.write("failed\n") - mock_stdout_log.close() - mock_stderr_log.close() + mock_output_log.close() self._save_log(resultsdir, "state.log", artifact_name) self._save_log(resultsdir, "root.log", artifact_name) @@ -810,8 +806,8 @@ class BaseBuilder(object): self.resultsdir = resultsdir self.cmd = ["mock", "-v", "-r", config, "--no-clean", "--resultdir=%s" % resultsdir] - def build(self, stdout, stderr): - execute_cmd(self.cmd, stdout=stdout, stderr=stderr) + def build(self, output): + execute_cmd(self.cmd, output=output) class SRPMBuilder(BaseBuilder): diff --git a/module_build_service/builder/utils.py b/module_build_service/builder/utils.py index 5c779e09..cdffac60 100644 --- a/module_build_service/builder/utils.py +++ b/module_build_service/builder/utils.py @@ -26,27 +26,24 @@ def find_srpm(cod): return os.path.join(cod, f) -def execute_cmd(args, stdout=None, stderr=None, cwd=None): +def execute_cmd(args, output=None, cwd=None): """ - Executes command defined by `args`. If `stdout` or `stderr` is set to - Python file object, the stderr/stdout output is redirecter to that file. + Executes command defined by `args`. If `output` is set to + Python file object, the stderr and stdout output is redirected to that file. If `cwd` is set, current working directory is set accordingly for the executed command. :param args: list defining the command to execute. - :param stdout: Python file object to redirect the stdout to. - :param stderr: Python file object to redirect the stderr to. + :param output: Python file object to redirect the stderr and stdout to. :param cwd: string defining the current working directory for command. :raises RuntimeError: Raised when command exits with non-zero exit code. """ out_log_msg = "" - if stdout and hasattr(stdout, "name"): - out_log_msg += ", stdout log: %s" % stdout.name - if stderr and hasattr(stderr, "name"): - out_log_msg += ", stderr log: %s" % stderr.name + if output and hasattr(output, "name"): + out_log_msg += ", output log: %s" % output.name log.info("Executing the command \"%s\"%s" % (" ".join(args), out_log_msg)) - proc = subprocess.Popen(args, stdout=stdout, stderr=stderr, cwd=cwd) + proc = subprocess.Popen(args, stdout=output, stderr=output, cwd=cwd) out, err = proc.communicate() if proc.returncode != 0: