From 400bc3091afb0705a83356a7aca8d33aed0be898 Mon Sep 17 00:00:00 2001 From: cerberus Date: Sat, 27 Sep 2025 15:06:36 +0200 Subject: [PATCH] fixed verbosity switch for run_as_subprocess()the output now getst voided if the -v flag is not set --- tempbox/README.md | 10 +++++++--- tempbox/tempbox_functions.py | 11 +++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/tempbox/README.md b/tempbox/README.md index 7cdeb55..d92fa19 100644 --- a/tempbox/README.md +++ b/tempbox/README.md @@ -1,8 +1,12 @@ # Tempbox -This script creates a temp file in /tmp. It is written to test +This script creates a temp file in /tmp. It is written to test e.g. folder manipulation. -The tempbox command followed by another command executes it in an -temporary folder in /tmp. Afterwards it removes the temporary folder +The tempbox command followed by another command executes it in an +temporary folder in /tmp. Afterwards it removes the temporary folder again. + +## Changelog + +<2025-09-27> - *Beta b0.0.1* - first release of tempbox diff --git a/tempbox/tempbox_functions.py b/tempbox/tempbox_functions.py index 6877e2c..22d251f 100644 --- a/tempbox/tempbox_functions.py +++ b/tempbox/tempbox_functions.py @@ -26,9 +26,12 @@ def create_folders(number_folders, base_path, verbosity=False): def execute_as_subprocess(command, base_path, verbosity=False): """executes the string given with the '-c, --command' flag.""" if verbosity: - print(base_path) - print(command) - print(verbosity) subprocess.run(command, cwd=base_path, shell=True) else: - subprocess.run(command, cwd=base_path, shell=True) + subprocess.run( + command, + cwd=base_path, + shell=True, + stdout=subprocess.DEVNULL, + stderr=subprocess.STDOUT, + )