X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=bootstrap.py;h=3b03b3a691b5bb823a3f0548a616358eff93ee96;hb=1574e8a3a8982fab9278ad534f9427d464e4bffb;hp=3c886efc94f583e7b13a7bbc19d63a174890d120;hpb=0e451d3b3bf899b3d9ac0c38e3c3cd9d9be170ba;p=python_utils.git diff --git a/bootstrap.py b/bootstrap.py index 3c886ef..3b03b3a 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -12,7 +12,7 @@ import traceback from argparse_utils import ActionNoYes import config - +import logging_utils logger = logging.getLogger(__name__) @@ -48,9 +48,14 @@ def initialize(entry_point): @functools.wraps(entry_point) def initialize_wrapper(*args, **kwargs): sys.excepthook = handle_uncaught_exception - config.parse(entry_point.__globals__['__file__']) + if ( + '__globals__' in entry_point.__dict__ and + '__file__' in entry_point.__globals__ + ): + config.parse(entry_point.__globals__['__file__']) + else: + config.parse(None) - import logging_utils logging_utils.initialize_logging(logging.getLogger()) config.late_logging() @@ -58,8 +63,8 @@ def initialize(entry_point): logger.debug(f'Starting {entry_point.__name__} (program entry point)') ret = None - import timer - with timer.Timer() as t: + import stopwatch + with stopwatch.Timer() as t: ret = entry_point(*args, **kwargs) logger.debug( f'{entry_point.__name__} (program entry point) returned {ret}.' @@ -67,13 +72,13 @@ def initialize(entry_point): walltime = t() (utime, stime, cutime, cstime, elapsed_time) = os.times() - logger.debug(f'\n' + logger.debug('\n' f'user: {utime}s\n' f'system: {stime}s\n' f'child user: {cutime}s\n' f'child system: {cstime}s\n' - f'elapsed: {elapsed_time}s\n' - f'walltime: {walltime}s\n') + f'machine uptime: {elapsed_time}s\n' + f'walltime: {walltime}s') if ret != 0: logger.info(f'Exit {ret}') else: