fixed verbosity switch for run_as_subprocess()the output now getst voided if the -v flag is not set

This commit is contained in:
2025-09-27 15:06:36 +02:00
parent 9a6826fac0
commit 400bc3091a
2 changed files with 14 additions and 7 deletions

View File

@@ -1,8 +1,12 @@
# Tempbox # 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. e.g. folder manipulation.
The tempbox command followed by another command executes it in an The tempbox command followed by another command executes it in an
temporary folder in /tmp. Afterwards it removes the temporary folder temporary folder in /tmp. Afterwards it removes the temporary folder
again. again.
## Changelog
<2025-09-27> - *Beta b0.0.1* - first release of tempbox

View File

@@ -26,9 +26,12 @@ def create_folders(number_folders, base_path, verbosity=False):
def execute_as_subprocess(command, base_path, verbosity=False): def execute_as_subprocess(command, base_path, verbosity=False):
"""executes the string given with the '-c, --command' flag.""" """executes the string given with the '-c, --command' flag."""
if verbosity: if verbosity:
print(base_path)
print(command)
print(verbosity)
subprocess.run(command, cwd=base_path, shell=True) subprocess.run(command, cwd=base_path, shell=True)
else: else:
subprocess.run(command, cwd=base_path, shell=True) subprocess.run(
command,
cwd=base_path,
shell=True,
stdout=subprocess.DEVNULL,
stderr=subprocess.STDOUT,
)