diff --git a/direct/src/distributed/ConnectionRepository.py b/direct/src/distributed/ConnectionRepository.py index 0cd6632e63..a36d49b154 100644 --- a/direct/src/distributed/ConnectionRepository.py +++ b/direct/src/distributed/ConnectionRepository.py @@ -238,6 +238,11 @@ class ConnectionRepository(DirectObject.DirectObject): return 1 return 0 + def flush(self): + # Ensure the latest has been sent to the server. + if self.tcpConn: + self.tcpConn.flush() + def ensureValidConnection(self): # Was the connection reset? if self.connectHttp: diff --git a/direct/src/showbase/PythonUtil.py b/direct/src/showbase/PythonUtil.py index fbac947fa8..05cb9a4358 100644 --- a/direct/src/showbase/PythonUtil.py +++ b/direct/src/showbase/PythonUtil.py @@ -687,6 +687,34 @@ def findPythonModule(module): return None +def describeException(backTrace = 4): + # When called in an exception handler, returns a string describing + # the current exception. + + infoArr = sys.exc_info() + exception = infoArr[0] + exceptionName = getattr(exception, '__name__', None) + extraInfo = infoArr[1] + trace = infoArr[2] + + stack = [] + while trace.tb_next: + module = trace.tb_frame.f_globals.get('__name__', None) + lineno = trace.tb_lineno + stack.append("%s:%s, " % (module, lineno)) + trace = trace.tb_next + + module = trace.tb_frame.f_globals.get('__name__', None) + lineno = trace.tb_lineno + stack.append("%s:%s, " % (module, lineno)) + + description = "" + for i in range(len(stack) - 1, max(len(stack) - backTrace, 0) - 1, -1): + description += stack[i] + + description += "%s: %s" % (exceptionName, extraInfo) + return description + class PureVirtual: """ Python classes that want to have C++-style pure-virtual functions can derive from this class and call 'derivedMustOverride' from their @@ -698,3 +726,4 @@ class PureVirtual: and are not meant to be chained down to. This simulates C++ pure-virtual methods. """ raise 'error: derived class must implement %s' % callerInfo()[2] +