def show_command_error(self, e): '''display a command error''' if isinstance(e, CommandError): (etype, evalue, etraceback) = e.exception_info inner_exception = e.inner_exception message = e.message force_traceback = False else: (etype, evalue, etraceback) = sys.exc_info() inner_exception = e message = "uncaught exception" force_traceback = True if isinstance(inner_exception, LdbError): (ldb_ecode, ldb_emsg) = inner_exception self.errf.write("ERROR(ldb): {0!s} - {1!s}\n".format(message, ldb_emsg)) elif isinstance(inner_exception, AssertionError): self.errf.write("ERROR(assert): {0!s}\n".format(message)) force_traceback = True elif isinstance(inner_exception, RuntimeError): self.errf.write("ERROR(runtime): {0!s} - {1!s}\n".format(message, evalue)) elif type(inner_exception) is Exception: self.errf.write("ERROR(exception): {0!s} - {1!s}\n".format(message, evalue)) force_traceback = True elif inner_exception is None: self.errf.write("ERROR: {0!s}\n".format((message))) else: self.errf.write("ERROR({0!s}): {1!s} - {2!s}\n".format(str(etype), message, evalue)) force_traceback = True if force_traceback or samba.get_debug_level() >= 3: traceback.print_tb(etraceback)
def show_command_error(self, e): '''display a command error''' if isinstance(e, CommandError): (etype, evalue, etraceback) = e.exception_info inner_exception = e.inner_exception message = e.message force_traceback = False else: (etype, evalue, etraceback) = sys.exc_info() inner_exception = e message = "uncaught exception" force_traceback = True if isinstance(inner_exception, LdbError): (ldb_ecode, ldb_emsg) = inner_exception.args self.errf.write("ERROR(ldb): %s - %s\n" % (message, ldb_emsg)) elif isinstance(inner_exception, AssertionError): self.errf.write("ERROR(assert): %s\n" % message) force_traceback = True elif isinstance(inner_exception, RuntimeError): self.errf.write("ERROR(runtime): %s - %s\n" % (message, evalue)) elif type(inner_exception) is Exception: self.errf.write("ERROR(exception): %s - %s\n" % (message, evalue)) force_traceback = True elif inner_exception is None: self.errf.write("ERROR: %s\n" % (message)) else: self.errf.write("ERROR(%s): %s - %s\n" % (str(etype), message, evalue)) force_traceback = True if force_traceback or samba.get_debug_level() >= 3: traceback.print_tb(etraceback, file=self.errf)
def show_command_error(self, e): '''display a command error''' if isinstance(e, CommandError): (etype, evalue, etraceback) = e.exception_info inner_exception = e.inner_exception message = e.message force_traceback = False else: (etype, evalue, etraceback) = sys.exc_info() inner_exception = e message = "uncaught exception" force_traceback = True if isinstance(inner_exception, LdbError): (ldb_ecode, ldb_emsg) = inner_exception print >>sys.stderr, "ERROR(ldb): %s - %s" % (message, ldb_emsg) elif isinstance(inner_exception, AssertionError): print >>sys.stderr, "ERROR(assert): %s" % message force_traceback = True elif isinstance(inner_exception, RuntimeError): print >>sys.stderr, "ERROR(runtime): %s - %s" % (message, evalue) elif type(inner_exception) is Exception: print >>sys.stderr, "ERROR(exception): %s - %s" % (message, evalue) force_traceback = True elif inner_exception is None: print >>sys.stderr, "ERROR: %s" % (message) else: print >>sys.stderr, "ERROR(%s): %s - %s" % (str(etype), message, evalue) force_traceback = True if force_traceback or samba.get_debug_level() >= 3: traceback.print_tb(etraceback) sys.exit(1)
def setUp(self): super(TestCase, self).setUp() test_debug_level = os.getenv("TEST_DEBUG_LEVEL") if test_debug_level is not None: test_debug_level = int(test_debug_level) self._old_debug_level = samba.get_debug_level() samba.set_debug_level(test_debug_level) self.addCleanup(samba.set_debug_level, test_debug_level)