From 28612e9b26022b6188fc0dda73b7c318c1581d1c Mon Sep 17 00:00:00 2001 From: viktorvaladi Date: Tue, 30 Apr 2024 11:41:34 +0200 Subject: [PATCH] ruff fix --- fedn/fedn/utils/process.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/fedn/fedn/utils/process.py b/fedn/fedn/utils/process.py index c5663e2fa..1a30fca2c 100644 --- a/fedn/fedn/utils/process.py +++ b/fedn/fedn/utils/process.py @@ -15,6 +15,7 @@ See the License for the specific language governing permissions and limitations under the License. """ + import os import subprocess import sys @@ -68,6 +69,7 @@ def _exec_cmd( Args: ---- cmd: The command to run, as a string or a list of strings. + cwd: The current working directory. throw_on_error: If True, raises an Exception if the exit code of the program is nonzero. extra_env: Extra environment variables to be defined when running the child process. If this argument is specified, `kwargs` cannot contain `env`. @@ -96,9 +98,7 @@ def _exec_cmd( raise ValueError("`extra_env` and `env` cannot be used at the same time") if capture_output and stream_output: - raise ValueError( - "`capture_output=True` and `stream_output=True` cannot be specified at the same time" - ) + raise ValueError("`capture_output=True` and `stream_output=True` cannot be specified at the same time") env = env if extra_env is None else {**os.environ, **extra_env} @@ -110,9 +110,7 @@ def _exec_cmd( if capture_output or stream_output: if kwargs.get("stdout") is not None or kwargs.get("stderr") is not None: - raise ValueError( - "stdout and stderr arguments may not be used with capture_output or stream_output" - ) + raise ValueError("stdout and stderr arguments may not be used with capture_output or stream_output") kwargs["stdout"] = subprocess.PIPE if capture_output: kwargs["stderr"] = subprocess.PIPE @@ -150,7 +148,7 @@ def _exec_cmd( def run_process(args, cwd): - """ Run a process and log the output. + """Run a process and log the output. :param args: The arguments to the process. :type args: list @@ -158,11 +156,10 @@ def run_process(args, cwd): :type cwd: str :return: """ - status = subprocess.Popen( - args, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + status = subprocess.Popen(args, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) def check_io(): - """ Check stdout/stderr of the child process. + """Check stdout/stderr of the child process. :return: """