Fix verbose import warning for debugpy contrib

This commit is contained in:
Griatch 2026-02-14 10:38:43 +01:00
parent abcb3d1cc3
commit c3b01d0aec

View file

@ -1,17 +1,11 @@
import sys
from django.conf import settings
from evennia.utils import utils
COMMAND_DEFAULT_CLASS = utils.class_from_module(settings.COMMAND_DEFAULT_CLASS)
ERROR_MSG = """Error, debugpy not found! Please install debugpy by running: `pip install debugpy`
After that please reboot Evennia with `evennia reboot`"""
try:
import debugpy
except ImportError:
print(ERROR_MSG)
sys.exit()
ERROR_MSG = "debugpy needed for the debugpy contrib. Admin must install it and reboot."
class CmdDebugPy(COMMAND_DEFAULT_CLASS):
@ -20,12 +14,20 @@ class CmdDebugPy(COMMAND_DEFAULT_CLASS):
Usage:
debugpy
"""
key = "debugpy"
locks = "cmd:perm(debugpy) or perm(Builder)"
def func(self):
try:
import debugpy
except ImportError:
self.caller.msg(ERROR_MSG)
return
caller = self.caller
caller.msg("Waiting for debugger attach...")
yield 0.1 # make sure msg is sent first