From a4687d371eb931da4f2b1d08a3f455fa9888bdd2 Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Fri, 2 May 2014 21:10:00 +0200 Subject: [PATCH] Improve error message for config file. --- vdirsyncer/cli.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/vdirsyncer/cli.py b/vdirsyncer/cli.py index 2b00441..348dadc 100644 --- a/vdirsyncer/cli.py +++ b/vdirsyncer/cli.py @@ -32,7 +32,12 @@ cli_logger = log.get(__name__) def load_config(fname, pair_options=('collections', 'conflict_resolution')): c = RawConfigParser() - c.read(fname) + try: + with open(fname) as f: + c.readfp(f) + except IOError: + cli_logger.exception('Error while trying to read config file.') + sys.exit(1) get_options = lambda s: dict(parse_options(c.items(s), section=s)) @@ -59,7 +64,7 @@ def load_config(fname, pair_options=('collections', 'conflict_resolution')): cli_logger.error( 'Unknown section in {}: {}'.format(fname, section)) - if not general: + if general is None: cli_logger.error('Unable to find general section. You should copy the ' 'example config from the repository and edit it.') cli_logger.error('https://github.com/untitaker/vdirsyncer')