From 869100692aeb7c7cd6c9601ed9c2da8a4edbad0e Mon Sep 17 00:00:00 2001 From: Little Cat Date: Fri, 9 Jul 2021 01:51:16 -0300 Subject: [PATCH] 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. --- otp/ai/AIBase.py | 1 + otp/ai/AIMsgTypes.py | 2 +- otp/chat/ChatInputNormal.py | 6 +++--- otp/chat/ChatInputTyped.py | 4 ++-- otp/chat/ChatInputWhiteListFrame.py | 6 +++--- otp/chat/TalkAssistant.py | 6 +++--- otp/level/LevelSpec.py | 2 +- otp/otpbase/OTPBase.py | 1 + toontown/ai/ToontownAIMsgTypes.py | 2 +- toontown/coghq/CountryClubRoomSpecs.py | 2 +- toontown/coghq/MintRoomSpecs.py | 2 +- toontown/coghq/StageRoomSpecs.py | 2 +- toontown/estate/DistributedCannon.py | 2 +- toontown/parties/DistributedPartyCannonActivity.py | 2 +- 14 files changed, 21 insertions(+), 19 deletions(-) diff --git a/otp/ai/AIBase.py b/otp/ai/AIBase.py index abc22fd..c9ff8c7 100644 --- a/otp/ai/AIBase.py +++ b/otp/ai/AIBase.py @@ -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: diff --git a/otp/ai/AIMsgTypes.py b/otp/ai/AIMsgTypes.py index 28295c5..06bd641 100644 --- a/otp/ai/AIMsgTypes.py +++ b/otp/ai/AIMsgTypes.py @@ -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()): diff --git a/otp/chat/ChatInputNormal.py b/otp/chat/ChatInputNormal.py index 8a0afac..d518757 100644 --- a/otp/chat/ChatInputNormal.py +++ b/otp/chat/ChatInputNormal.py @@ -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) diff --git a/otp/chat/ChatInputTyped.py b/otp/chat/ChatInputTyped.py index f6b567d..dc49e46 100644 --- a/otp/chat/ChatInputTyped.py +++ b/otp/chat/ChatInputTyped.py @@ -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) diff --git a/otp/chat/ChatInputWhiteListFrame.py b/otp/chat/ChatInputWhiteListFrame.py index 09f6e2b..0d4b1d4 100644 --- a/otp/chat/ChatInputWhiteListFrame.py +++ b/otp/chat/ChatInputWhiteListFrame.py @@ -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) diff --git a/otp/chat/TalkAssistant.py b/otp/chat/TalkAssistant.py index 866eaf7..2118a8e 100644 --- a/otp/chat/TalkAssistant.py +++ b/otp/chat/TalkAssistant.py @@ -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) diff --git a/otp/level/LevelSpec.py b/otp/level/LevelSpec.py index dc9a27b..7fa9c34 100644 --- a/otp/level/LevelSpec.py +++ b/otp/level/LevelSpec.py @@ -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()) diff --git a/otp/otpbase/OTPBase.py b/otp/otpbase/OTPBase.py index ce82d31..22b3681 100644 --- a/otp/otpbase/OTPBase.py +++ b/otp/otpbase/OTPBase.py @@ -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 diff --git a/toontown/ai/ToontownAIMsgTypes.py b/toontown/ai/ToontownAIMsgTypes.py index 1fdf673..6b37e20 100644 --- a/toontown/ai/ToontownAIMsgTypes.py +++ b/toontown/ai/ToontownAIMsgTypes.py @@ -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()): diff --git a/toontown/coghq/CountryClubRoomSpecs.py b/toontown/coghq/CountryClubRoomSpecs.py index aa1f5c8..e10112b 100644 --- a/toontown/coghq/CountryClubRoomSpecs.py +++ b/toontown/coghq/CountryClubRoomSpecs.py @@ -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()): diff --git a/toontown/coghq/MintRoomSpecs.py b/toontown/coghq/MintRoomSpecs.py index c917ddf..194b544 100644 --- a/toontown/coghq/MintRoomSpecs.py +++ b/toontown/coghq/MintRoomSpecs.py @@ -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()): diff --git a/toontown/coghq/StageRoomSpecs.py b/toontown/coghq/StageRoomSpecs.py index 1be4686..adc800d 100644 --- a/toontown/coghq/StageRoomSpecs.py +++ b/toontown/coghq/StageRoomSpecs.py @@ -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()): diff --git a/toontown/estate/DistributedCannon.py b/toontown/estate/DistributedCannon.py index 005ecfa..39901bd 100644 --- a/toontown/estate/DistributedCannon.py +++ b/toontown/estate/DistributedCannon.py @@ -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: diff --git a/toontown/parties/DistributedPartyCannonActivity.py b/toontown/parties/DistributedPartyCannonActivity.py index e313564..380941a 100644 --- a/toontown/parties/DistributedPartyCannonActivity.py +++ b/toontown/parties/DistributedPartyCannonActivity.py @@ -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: