diff --git a/direct/src/actor/Actor.py b/direct/src/actor/Actor.py index a287eac397..8f5d5183e0 100644 --- a/direct/src/actor/Actor.py +++ b/direct/src/actor/Actor.py @@ -11,7 +11,7 @@ from panda3d.core import Loader as PandaLoader from direct.showbase.DirectObject import DirectObject from direct.showbase.Loader import Loader from direct.directnotify import DirectNotifyGlobal - +import warnings class Actor(DirectObject, NodePath): """ @@ -1652,6 +1652,8 @@ class Actor(DirectObject, NodePath): This method is deprecated. You should use setBlend() instead. """ + if __debug__: + warnings.warn("This method is deprecated. You should use setBlend() instead.", DeprecationWarning, stacklevel=2) self.setBlend(animBlend = True, blendType = blendType, partName = partName) def disableBlend(self, partName = None): @@ -1661,6 +1663,8 @@ class Actor(DirectObject, NodePath): This method is deprecated. You should use setBlend() instead. """ + if __debug__: + warnings.warn("This method is deprecated. You should use setBlend() instead.", DeprecationWarning, stacklevel=2) self.setBlend(animBlend = False, partName = partName) def setControlEffect(self, animName, effect, diff --git a/direct/src/dist/FreezeTool.py b/direct/src/dist/FreezeTool.py index 858e742d57..761593f511 100644 --- a/direct/src/dist/FreezeTool.py +++ b/direct/src/dist/FreezeTool.py @@ -12,6 +12,7 @@ import io import distutils.sysconfig as sysconf import zipfile import importlib +import warnings from . import pefile @@ -1985,7 +1986,7 @@ class Freezer: if append_offset: # This is for legacy deploy-stub. - print("WARNING: Could not find blob header. Is deploy-stub outdated?") + warnings.warn("Could not find blob header. Is deploy-stub outdated?") blob += struct.pack(' 0: - print("warning: %d motion trails still exist when motion trail task is removed" %(total_motion_trails)) + if __debug__: + warnings.warn("%d motion trails still exist when motion trail task is removed" % (total_motion_trails), RuntimeWarning, stacklevel=2) MotionTrail.motion_trail_list = [] diff --git a/direct/src/particles/ForceGroup.py b/direct/src/particles/ForceGroup.py index b6d867a406..3623120783 100644 --- a/direct/src/particles/ForceGroup.py +++ b/direct/src/particles/ForceGroup.py @@ -5,6 +5,7 @@ from direct.showbase.PhysicsManagerGlobal import * from direct.directnotify import DirectNotifyGlobal import sys +import warnings class ForceGroup(DirectObject): @@ -61,7 +62,7 @@ class ForceGroup(DirectObject): # Get/set def getName(self): - """Deprecated: access .name directly instead.""" + warnings.warn("Deprecated: access .name directly instead.", DeprecationWarning, stacklevel=2) return self.name def getNode(self): diff --git a/direct/src/showbase/AppRunnerGlobal.py b/direct/src/showbase/AppRunnerGlobal.py index 81f56c9562..6448235fa5 100644 --- a/direct/src/showbase/AppRunnerGlobal.py +++ b/direct/src/showbase/AppRunnerGlobal.py @@ -12,7 +12,8 @@ the AppRunner at startup. """ if __debug__: - print('AppRunner has been removed and AppRunnerGlobal has been deprecated') + import warnings + warnings.warn("AppRunner has been removed and AppRunnerGlobal has been deprecated.", DeprecationWarning, stacklevel=2) #: Contains the global :class:`~.AppRunner.AppRunner` instance, or None #: if this application was not run from the runtime environment. diff --git a/direct/src/showbase/DConfig.py b/direct/src/showbase/DConfig.py index 54c90d1566..a0331632e2 100644 --- a/direct/src/showbase/DConfig.py +++ b/direct/src/showbase/DConfig.py @@ -4,21 +4,30 @@ __all__ = [] from panda3d.core import (ConfigFlags, ConfigVariableBool, ConfigVariableInt, ConfigVariableDouble, ConfigVariableString) +import warnings def GetBool(sym, default=False): + if __debug__: + warnings.warn("This is deprecated. Use ConfigVariableBool instead", DeprecationWarning, stacklevel=2) return ConfigVariableBool(sym, default, "DConfig", ConfigFlags.F_dconfig).value def GetInt(sym, default=0): + if __debug__: + warnings.warn("This is deprecated. Use ConfigVariableInt instead", DeprecationWarning, stacklevel=2) return ConfigVariableInt(sym, default, "DConfig", ConfigFlags.F_dconfig).value def GetDouble(sym, default=0.0): + if __debug__: + warnings.warn("This is deprecated. Use ConfigVariableDouble instead", DeprecationWarning, stacklevel=2) return ConfigVariableDouble(sym, default, "DConfig", ConfigFlags.F_dconfig).value def GetString(sym, default=""): + if __debug__: + warnings.warn("This is deprecated. Use ConfigVariableString instead", DeprecationWarning, stacklevel=2) return ConfigVariableString(sym, default, "DConfig", ConfigFlags.F_dconfig).value diff --git a/direct/src/showbase/Loader.py b/direct/src/showbase/Loader.py index 43da8c6742..0c752d0a33 100644 --- a/direct/src/showbase/Loader.py +++ b/direct/src/showbase/Loader.py @@ -8,6 +8,7 @@ from panda3d.core import * from panda3d.core import Loader as PandaLoader from direct.directnotify.DirectNotifyGlobal import * from direct.showbase.DirectObject import DirectObject +import warnings # You can specify a phaseChecker callback to check # a modelPath to see if it is being loaded in the correct @@ -295,7 +296,8 @@ class Loader(DirectObject): called after cancelRequest() has been performed. This is now deprecated: call cb.cancel() instead. """ - + if __debug__: + warnings.warn("This is now deprecated: call cb.cancel() instead.", DeprecationWarning, stacklevel=2) cb.cancel() def isRequestPending(self, cb): @@ -304,7 +306,8 @@ class Loader(DirectObject): been cancelled. This is now deprecated: call cb.done() instead. """ - + if __debug__: + warnings.warn("This is now deprecated: call cb.done() instead.", DeprecationWarning, stacklevel=2) return bool(cb.requests) def loadModelOnce(self, modelPath): @@ -315,7 +318,8 @@ class Loader(DirectObject): then attempt to load it from disk. Return a nodepath to the model if successful or None otherwise """ - Loader.notify.info("loader.loadModelOnce() is deprecated; use loader.loadModel() instead.") + if __debug__: + warnings.warn("loader.loadModelOnce() is deprecated; use loader.loadModel() instead.", DeprecationWarning, stacklevel=2) return self.loadModel(modelPath, noCache = False) @@ -326,7 +330,8 @@ class Loader(DirectObject): then attempt to load it from disk. Return a nodepath to a copy of the model if successful or None otherwise """ - Loader.notify.info("loader.loadModelCopy() is deprecated; use loader.loadModel() instead.") + if __debug__: + warnings.warn("loader.loadModelCopy() is deprecated; use loader.loadModel() instead.", DeprecationWarning, stacklevel=2) return self.loadModel(modelPath, loaderOptions = loaderOptions, noCache = False) @@ -344,7 +349,8 @@ class Loader(DirectObject): However, if you're loading a font, see loadFont(), below. """ - Loader.notify.info("loader.loadModelNode() is deprecated; use loader.loadModel() instead.") + if __debug__: + warnings.warn("loader.loadModelNode() is deprecated; use loader.loadModel() instead.", DeprecationWarning, stacklevel=2) model = self.loadModel(modelPath, noCache = False) if model is not None: diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index 91cf6d111f..96ca8da523 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -72,6 +72,7 @@ if __debug__: from direct.showbase import GarbageReport from direct.directutil import DeltaProfiler from . import OnScreenDebug + import warnings @atexit.register def exitfunc(): @@ -2034,7 +2035,8 @@ class ShowBase(DirectObject.DirectObject): """ :deprecated: Use `.Loader.Loader.loadSfx()` instead. """ - assert self.notify.warning("base.loadSfx is deprecated, use base.loader.loadSfx instead.") + if __debug__: + warnings.warn("base.loadSfx is deprecated, use base.loader.loadSfx instead.", DeprecationWarning, stacklevel=2) return self.loader.loadSfx(name) # This function should only be in the loader but is here for @@ -2044,7 +2046,8 @@ class ShowBase(DirectObject.DirectObject): """ :deprecated: Use `.Loader.Loader.loadMusic()` instead. """ - assert self.notify.warning("base.loadMusic is deprecated, use base.loader.loadMusic instead.") + if __debug__: + warnings.warn("base.loadMusic is deprecated, use base.loader.loadMusic instead.", DeprecationWarning, stacklevel=2) return self.loader.loadMusic(name) def playSfx( diff --git a/direct/src/showbase/ShowBaseGlobal.py b/direct/src/showbase/ShowBaseGlobal.py index a6bf22c113..05c92fe5ec 100644 --- a/direct/src/showbase/ShowBaseGlobal.py +++ b/direct/src/showbase/ShowBaseGlobal.py @@ -19,6 +19,7 @@ from panda3d.core import VirtualFileSystem, Notify, ClockObject, PandaSystem from panda3d.core import ConfigPageManager, ConfigVariableManager from panda3d.core import NodePath, PGTop from . import DConfig as config +import warnings __dev__ = config.GetBool('want-dev', __debug__) @@ -63,7 +64,8 @@ directNotify.setDconfigLevels() def run(): """Deprecated alias for :meth:`base.run() <.ShowBase.run>`.""" - assert ShowBase.notify.warning("run() is deprecated, use base.run() instead") + if __debug__: + warnings.warn("run() is deprecated, use base.run() instead", DeprecationWarning, stacklevel=2) base.run()