Files
SillyTavern-extras/modules/utils.py
2023-11-30 02:03:11 +02:00

24 lines
456 B
Python

from contextlib import contextmanager
import sys
@contextmanager
def silence_log():
old_stdout = sys.stdout
old_stderr = sys.stderr
try:
with open(os.devnull, "w") as new_target:
sys.stdout = new_target
yield new_target
finally:
sys.stdout = old_stdout
sys.stderr = old_stderr
def is_colab():
try:
from google import colab
return True
except:
return False