Mercurial > piecrust2
diff foodtruck/sites.py @ 601:effbc78b5528
admin: Better error reporting, general clean-up.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 24 Jan 2016 10:42:33 -0800 |
parents | 3cec8634209a |
children | c6bc0ef03f82 |
line wrap: on
line diff
--- a/foodtruck/sites.py Sun Jan 24 10:41:36 2016 -0800 +++ b/foodtruck/sites.py Sun Jan 24 10:42:33 2016 -0800 @@ -6,6 +6,7 @@ import threading import subprocess from piecrust.app import PieCrust +from piecrust.configuration import merge_dicts logger = logging.getLogger(__name__) @@ -15,6 +16,10 @@ pass +class InvalidSiteError(Exception): + pass + + class Site(object): def __init__(self, name, root_dir, config): self.name = name @@ -48,7 +53,7 @@ elif global_scm_cfg: cfg = copy.deepcopy(global_scm_cfg) - if not cfg or not 'type' in cfg: + if not cfg or 'type' not in cfg: raise Exception("No SCM available for site: %s" % self.name) if cfg['type'] == 'hg': @@ -134,12 +139,12 @@ scfg = self.config.get('sites/%s' % name) if scfg is None: - raise Exception("No such site: %s" % name) + raise InvalidSiteError("No such site: %s" % name) root_dir = scfg.get('path') if root_dir is None: - raise Exception("Site '%s' has no path defined." % name) + raise InvalidSiteError("Site '%s' has no path defined." % name) if not os.path.isdir(root_dir): - raise Exception("Site '%s' has an invalid path." % name) + raise InvalidSiteError("Site '%s' has an invalid path." % name) self._site_dirs[name] = root_dir return root_dir