mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
protect against no profile module
This commit is contained in:
parent
a2a8aacb7e
commit
da7a5b6b55
@ -128,13 +128,7 @@ class ShowBase(DirectObject.DirectObject):
|
||||
taskMgr.resumeFunc = PStatClient.resumeAfterPause
|
||||
|
||||
if self.__dev__:
|
||||
import profile, pstats
|
||||
profile.Profile.bias = float(self.config.GetString("profile-bias","0"))
|
||||
|
||||
|
||||
def f8(x):
|
||||
return ("%"+"8.%df"%base.config.GetInt("profile-decimals",3)) % x
|
||||
pstats.f8=f8
|
||||
self.__setupProfile()
|
||||
|
||||
# If the aspect ratio is 0 or None, it means to infer the
|
||||
# aspect ratio from the window size.
|
||||
@ -426,6 +420,21 @@ class ShowBase(DirectObject.DirectObject):
|
||||
def popCTrav(self):
|
||||
self.cTrav = self.cTravStack.pop()
|
||||
|
||||
def __setupProfile(self):
|
||||
""" Sets up the Python profiler, if avaialable, according to
|
||||
some Panda config settings. """
|
||||
|
||||
try:
|
||||
import profile, pstats
|
||||
except ImportError:
|
||||
return
|
||||
|
||||
profile.Profile.bias = float(self.config.GetString("profile-bias","0"))
|
||||
|
||||
def f8(x):
|
||||
return ("%"+"8.%df"%base.config.GetInt("profile-decimals",3)) % x
|
||||
pstats.f8=f8
|
||||
|
||||
# temp; see ToonBase.py
|
||||
def getExitErrorCode(self):
|
||||
return 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user