Ejemplo n.º 1
0
class _TerminationLog(object):

    def __init__(self, dumper):
        self.time_watch = TimeWatch()
        self.dumper = dumper

    def __enter__(self):
        self.time_watch.start()
        return self

    def __exit__(self, exc_type, exc_value, traceback):
        self.time_watch.stop()
        if exc_type is not None:
            if issubclass(exc_type, SystemExit):
                LOGGER.error("generation stopped prematurely with code %d",
                             exc_value.code)
            elif issubclass(exc_type, KeyboardInterrupt):
                LOGGER.error("generation interrupted by user")
            elif issubclass(exc_type, Exception):
                LOGGER.error("uncaught exception while generating")
        LOGGER.info("%d build, %d rule, %d sub-generator",
                    self.dumper.build_count,
                    self.dumper.rule_count,
                    self.dumper.subgenerator_count)
        LOGGER.info("generation done in %s", self.time_watch.stats)
        return False # Tell to re-raise the exception if there was one.
Ejemplo n.º 2
0
 def __init__(self, dumper):
     self.time_watch = TimeWatch()
     self.dumper = dumper