X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=hippotat.git;a=blobdiff_plain;f=hippotat%2F__init__.py;fp=hippotat%2F__init__.py;h=d0cc79902753286e2afa0c254297094e5c73de8d;hp=6b87da9f63919f64979e3bf8680bc361a99abdc3;hb=5510890e40f44f7851829b3bb1e319188e993798;hpb=cae50358b1bdc57fd1300aa27e845e9dc73b6cf2 diff --git a/hippotat/__init__.py b/hippotat/__init__.py index 6b87da9..d0cc799 100644 --- a/hippotat/__init__.py +++ b/hippotat/__init__.py @@ -20,6 +20,7 @@ import ipaddress from ipaddress import AddressValueError from optparse import OptionParser +import configparser from configparser import ConfigParser from configparser import NoOptionError @@ -403,7 +404,7 @@ def process_cfg_clients(constructor): #---------- startup ---------- -def common_startup(): +def common_startup(process_cfg): re = regexp.compile('#.*') cfg.read_string(re.sub('', defcfg)) need_defcfg = True @@ -514,6 +515,12 @@ just `+': all DFLAGs. readconfig('/etc/hippotat/config', False) readconfig('/etc/hippotat/config.d', False) + try: process_cfg() + except (configparser.Error, ValueError): + traceback.print_exc(file=sys.stderr) + print('\nInvalid configuration, giving up.', file=sys.stderr) + sys.exit(12) + #print(repr(debug_set), file=sys.stderr) log_formatter = twisted.logger.formatEventAsClassicLogText