mirror of
https://github.com/SillyTavern/SillyTavern-Extras.git
synced 2026-01-26 17:20:04 +00:00
24 lines
456 B
Python
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
|