refactor: add example hide logs only text blob and uri

This commit is contained in:
Florian Hönicke
2023-04-12 01:15:48 +02:00
parent a399ba814c
commit 6a1f042aa1
6 changed files with 30 additions and 10 deletions

View File

@@ -3,6 +3,8 @@ import shutil
import concurrent.futures
import concurrent.futures
from typing import Generator
import sys
from contextlib import contextmanager
def recreate_folder(folder_path):
if os.path.exists(folder_path) and os.path.isdir(folder_path):
@@ -34,4 +36,14 @@ def timeout_generator_wrapper(generator, timeout):
except concurrent.futures.TimeoutError:
raise GenerationTimeoutError(f"Generation took longer than {timeout} seconds")
return wrapper()
return wrapper()
@contextmanager
def suppress_stdout():
original_stdout = sys.stdout
sys.stdout = open(os.devnull, 'w')
try:
yield
finally:
sys.stdout.close()
sys.stdout = original_stdout