base: Silence execwarnings on dev.

Yes, this makes the warnings show up on client as well, because truth be told, having exec and eval calls on production builds is a very bad idea.
This commit is contained in:
Little Cat 2021-07-09 01:51:16 -03:00
parent 79cab772af
commit 869100692a
No known key found for this signature in database
GPG key ID: 68CC2B4D0E5AF41C
14 changed files with 21 additions and 19 deletions

View file

@ -23,6 +23,7 @@ class AIBase:
self.config = getConfigShowbase()
__builtins__['__dev__'] = self.config.GetBool('want-dev', 0)
__builtins__['__astron__'] = self.config.GetBool('astron-support', 1)
__builtins__['__execWarnings__'] = self.config.GetBool('want-exec-warnings', 0)
logStackDump = (self.config.GetBool('log-stack-dump', (not __dev__)) or self.config.GetBool('ai-log-stack-dump', (not __dev__)))
uploadStackDump = self.config.GetBool('upload-stack-dump', 0)
if logStackDump or uploadStackDump:

View file

@ -72,7 +72,7 @@ AIMsgName2Id = {'STATESERVER_OBJECT_GENERATE_WITH_REQUIRED': 2001,
'DBSERVER_SET_STORED_VALUES': 1014,
'SERVER_PING': 5002}
AIMsgId2Names = invertDictLossless(AIMsgName2Id)
if not isClient():
if not __debug__ or __execWarnings__:
print('EXECWARNING AIMsgTypes: %s' % AIMsgName2Id)
printStack()
for name, value in list(AIMsgName2Id.items()):

View file

@ -100,16 +100,16 @@ class ChatInputNormal(DirectObject.DirectObject):
def __execMessage(self, message):
if not ChatInputNormal.ExecNamespace:
ChatInputNormal.ExecNamespace = {}
exec('from pandac.PandaModules import *', globals(), self.ExecNamespace)
exec('from panda3d.core import *', globals(), self.ExecNamespace)
self.importExecNamespace()
try:
if not isClient():
if not __debug__ or __execWarnings__:
print('EXECWARNING ChatInputNormal eval: %s' % message)
printStack()
return str(eval(message, globals(), ChatInputNormal.ExecNamespace))
except SyntaxError:
try:
if not isClient():
if not __debug__ or __execWarnings__:
print('EXECWARNING ChatInputNormal exec: %s' % message)
printStack()
exec(message, globals(), ChatInputNormal.ExecNamespace)

View file

@ -130,13 +130,13 @@ class ChatInputTyped(DirectObject.DirectObject):
exec('from pandac.PandaModules import *', globals(), self.ExecNamespace)
self.importExecNamespace()
try:
if not isClient():
if not __debug__ or __execWarnings__:
print('EXECWARNING ChatInputNormal eval: %s' % message)
printStack()
return str(eval(message, globals(), ChatInputTyped.ExecNamespace))
except SyntaxError:
try:
if not isClient():
if not __debug__ or __execWarnings__:
print('EXECWARNING ChatInputNormal exec: %s' % message)
printStack()
exec(message, globals(), ChatInputTyped.ExecNamespace)

View file

@ -285,16 +285,16 @@ class ChatInputWhiteListFrame(FSM.FSM, DirectFrame):
def __execMessage(self, message):
if not ChatInputTyped.ExecNamespace:
ChatInputTyped.ExecNamespace = {}
exec('from pandac.PandaModules import *', globals(), self.ExecNamespace)
exec('from panda3d.core import *', globals(), self.ExecNamespace)
self.importExecNamespace()
try:
if not isClient():
if not __debug__ or __execWarnings__:
print('EXECWARNING ChatInputWhiteListFrame eval: %s' % message)
printStack()
return str(eval(message, globals(), ChatInputTyped.ExecNamespace))
except SyntaxError:
try:
if not isClient():
if not __debug__ or __execWarnings__:
print('EXECWARNING ChatInputWhiteListFrame exec: %s' % message)
printStack()
exec(message, globals(), ChatInputTyped.ExecNamespace)

View file

@ -249,16 +249,16 @@ class TalkAssistant(DirectObject.DirectObject):
print('execMessage %s' % message)
if not TalkAssistant.ExecNamespace:
TalkAssistant.ExecNamespace = {}
exec('from pandac.PandaModules import *', globals(), self.ExecNamespace)
exec('from panda3d.core import *', globals(), self.ExecNamespace)
self.importExecNamespace()
try:
if not isClient():
if not __debug__ or __execWarnings__:
print('EXECWARNING TalkAssistant eval: %s' % message)
printStack()
return str(eval(message, globals(), TalkAssistant.ExecNamespace))
except SyntaxError:
try:
if not isClient():
if not __debug__ or __execWarnings__:
print('EXECWARNING TalkAssistant exec: %s' % message)
printStack()
exec(message, globals(), TalkAssistant.ExecNamespace)

View file

@ -92,7 +92,7 @@ class LevelSpec:
def getCopyOfSpec(self, spec):
specCopy = {}
if not isClient():
if not __debug__ or __execWarnings__:
print('EXECWARNING LevelSpec exec: %s' % self.getSpecImportsModuleName())
printStack()
exec('from %s import *' % self.getSpecImportsModuleName())

View file

@ -11,6 +11,7 @@ class OTPBase(ShowBase):
self.wantEnviroDR = False
ShowBase.__init__(self, windowType=windowType)
__builtins__['__astron__'] = self.config.GetBool('astron-support', 1)
__builtins__['__execWarnings__'] = self.config.GetBool('want-exec-warnings', 0)
OTPBase.notify.info('__astron__ == %s' % __astron__)
if config.GetBool('want-phase-checker', 0):
from direct.showbase import Loader

View file

@ -5,7 +5,7 @@ TTAIMsgName2Id = {'DBSERVER_GET_ESTATE': 1040,
'IN_GAME_NEWS_MANAGER_UD_TO_ALL_AI': 1043,
'WHITELIST_MANAGER_UD_TO_ALL_AI': 1044}
TTAIMsgId2Names = invertDictLossless(TTAIMsgName2Id)
if not isClient():
if not __debug__ or __execWarnings__:
print('EXECWARNING ToontownAIMsgTypes: %s' % TTAIMsgName2Id)
printStack()
for name, value in list(TTAIMsgName2Id.items()):

View file

@ -41,7 +41,7 @@ BossbotCountryClubMiddleRoomIDs = (2, 5, 6)
BossbotCountryClubFinalRoomIDs = (18,)
BossbotCountryClubConnectorRooms = ('phase_12/models/bossbotHQ/Connector_Tunnel_A', 'phase_12/models/bossbotHQ/Connector_Tunnel_B')
CashbotMintSpecModules = {}
if not isClient():
if not __debug__ or __execWarnings__:
print('EXECWARNING CountryClubRoomSpecs: %s' % BossbotCountryClubRoomName2RoomId)
printStack()
for roomName, roomId in list(BossbotCountryClubRoomName2RoomId.items()):

View file

@ -62,7 +62,7 @@ CashbotMintMiddleRoomIDs = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1
CashbotMintFinalRoomIDs = (17, 18, 19, 20, 21, 22, 23, 24, 25)
CashbotMintConnectorRooms = ('phase_10/models/cashbotHQ/connector_7cubeL2', 'phase_10/models/cashbotHQ/connector_7cubeR2')
CashbotMintSpecModules = {}
if not isClient():
if not __debug__ or __execWarnings__:
print('EXECWARNING MintRoomSpecs: %s' % CashbotMintRoomName2RoomId)
printStack()
for roomName, roomId in list(CashbotMintRoomName2RoomId.items()):

View file

@ -48,7 +48,7 @@ CashbotStageMiddleRoomIDs = (1,)
CashbotStageFinalRoomIDs = (2,)
CashbotStageConnectorRooms = ('phase_11/models/lawbotHQ/LB_connector_7cubeL2', 'phase_11/models/lawbotHQ/LB_connector_7cubeLR')
CashbotStageSpecModules = {}
if not isClient():
if not __debug__ or __execWarnings__:
print('EXECWARNING StageRoomSpecs: %s' % CashbotStageRoomName2RoomId)
printStack()
for roomName, roomId in list(CashbotStageRoomName2RoomId.items()):

View file

@ -785,7 +785,7 @@ class DistributedCannon(DistributedObject.DistributedObject):
if not self.toonHead:
return Task.done
flightResults = self.__calcFlightResults(avId, launchTime)
if not isClient():
if not __debug__ or __execWarnings__:
print('EXECWARNING DistributedCannon: %s' % flightResults)
printStack()
for key in flightResults:

View file

@ -262,7 +262,7 @@ class DistributedPartyCannonActivity(DistributedPartyActivity):
if self.isLocalToonId(toonId):
self.inWater = 0
flightResults = self.__calcFlightResults(cannon, toonId, launchTime)
if not isClient():
if not __debug__ or __execWarnings__:
print('EXECWARNING DistributedPartyCannonActivity: %s' % flightResults)
printStack()
for key in flightResults: