mirror of
https://github.com/Cian-H/I-Form_Server_Node_Deployer.git
synced 2025-12-22 22:22:02 +00:00
25 lines
568 B
Python
25 lines
568 B
Python
from functools import wraps
|
|
import inspect
|
|
from typing import Callable
|
|
|
|
import typer # type: ignore
|
|
|
|
import config
|
|
|
|
|
|
def debug_guard(f: Callable) -> Callable:
|
|
if not config.DEBUG:
|
|
return f
|
|
try:
|
|
import snoop # type: ignore
|
|
except ImportError:
|
|
typer.echo("Debug mode requires the snoop package")
|
|
raise typer.Exit(1)
|
|
else:
|
|
snoop.install(
|
|
snoop="ss",
|
|
)
|
|
|
|
typer.echo(f"Debug mode enabled: {inspect.stack()[1].filename}")
|
|
wraps(f)(ss)(f) # noqa: F821 #* ss is installed in debug_mode
|