Mercurial > piecrust2
comparison piecrust/main.py @ 39:2f717f961996
Better error reporting and cache validation.
Fix the processor pipeline in the preview server.
Move the `pages` route to first position.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Thu, 21 Aug 2014 22:28:22 -0700 |
parents | 091f99bfbe44 |
children | a62452ab5080 |
comparison
equal
deleted
inserted
replaced
38:091f99bfbe44 | 39:2f717f961996 |
---|---|
3 import os.path | 3 import os.path |
4 import logging | 4 import logging |
5 import argparse | 5 import argparse |
6 import colorama | 6 import colorama |
7 from piecrust.app import PieCrust, PieCrustConfiguration, APP_VERSION | 7 from piecrust.app import PieCrust, PieCrustConfiguration, APP_VERSION |
8 from piecrust.chefutil import format_timed | 8 from piecrust.chefutil import format_timed, log_friendly_exception |
9 from piecrust.environment import StandardEnvironment | 9 from piecrust.environment import StandardEnvironment |
10 from piecrust.pathutil import SiteNotFoundError, find_app_root | 10 from piecrust.pathutil import SiteNotFoundError, find_app_root |
11 from piecrust.plugins.base import PluginLoader | 11 from piecrust.plugins.base import PluginLoader |
12 | 12 |
13 | 13 |
55 return _run_chef(pre_args) | 55 return _run_chef(pre_args) |
56 except Exception as ex: | 56 except Exception as ex: |
57 if pre_args.debug: | 57 if pre_args.debug: |
58 logger.exception(ex) | 58 logger.exception(ex) |
59 else: | 59 else: |
60 logger.error(str(ex)) | 60 log_friendly_exception(logger, ex) |
61 return 1 | |
61 | 62 |
62 | 63 |
63 class PreParsedChefArgs(object): | 64 class PreParsedChefArgs(object): |
64 def __init__(self, root=None, cache=True, debug=False, quiet=False, | 65 def __init__(self, root=None, cache=True, debug=False, quiet=False, |
65 log_file=None, config_variant=None): | 66 log_file=None, config_variant=None): |
120 if res.quiet: | 121 if res.quiet: |
121 root_logger.setLevel(logging.WARNING) | 122 root_logger.setLevel(logging.WARNING) |
122 log_handler.setFormatter(ColoredFormatter("%(message)s")) | 123 log_handler.setFormatter(ColoredFormatter("%(message)s")) |
123 root_logger.addHandler(log_handler) | 124 root_logger.addHandler(log_handler) |
124 if res.log_file: | 125 if res.log_file: |
125 root_logger.addHandler(logging.FileHandler(res.log_file)) | 126 root_logger.addHandler(logging.FileHandler(res.log_file, mode='w')) |
126 | 127 |
127 return res | 128 return res |
128 | 129 |
129 | 130 |
130 def _run_chef(pre_args): | 131 def _run_chef(pre_args): |