Mercurial > wikked
changeset 213:841175200700
Some basic error handling and performance timing for Witch.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Mon, 17 Feb 2014 14:38:30 -0800 |
parents | 5bf00af997ac |
children | 2dd7535045eb |
files | wikked/witch.py |
diffstat | 1 files changed, 16 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/wikked/witch.py Mon Feb 17 14:37:53 2014 -0800 +++ b/wikked/witch.py Mon Feb 17 14:38:30 2014 -0800 @@ -1,6 +1,7 @@ import sys import logging import argparse +import datetime import colorama from wikked.commands.base import command_classes from wikked.utils import find_wiki_root @@ -104,7 +105,19 @@ wiki.start() # Run the command! - ctx = WitchContext(params, wiki, result) - exit_code = result.func(ctx) - return exit_code + now = datetime.datetime.now() + try: + ctx = WitchContext(params, wiki, result) + exit_code = result.func(ctx) + if exit_code is not None: + return exit_code + return 0 + except Exception as e: + logger.critical("Critical error while running witch command:") + logger.exception(e) + return -1 + finally: + after = datetime.datetime.now() + delta = after - now + logger.debug("Ran command in %fs" % delta.total_seconds())