Example #1
0
 def display_hook(self, obj):
     try:
         if obj is None:
             return
         if print_hooks.is_pretty_printable(obj):
             if print_hooks.needs_packing(obj):
                 packed = print_hooks.pack_for_transport(obj)
                 if not self.write_object.emit(packed):
                     logger.debug(msg("error sending packed object"))
                     sys.stdout.write(print_hooks.html_repr(obj))
             else:
                 if not self.write_object.emit(obj):
                     logger.debug(msg("error sending object"))
                     logger.debug(msg("error sending packed object"))
                     sys.stdout.write(print_hooks.html_repr(obj))
         else:
             logger.debug(msg("object", obj, "is not prettyprintable"))
             sys.stdout.write(repr(obj))
         return
     except Exception, e:
         logger.debug(msg("Exception", e, "encountered while printing object", obj))
         sys.__displayhook__(obj)
Example #2
0
 def write_object(self, obj):
     logger.debug(msg("Received object", obj, "writing it to stdout"))
     self.write('stdout',print_hooks.html_repr(obj, self._document))