diff --git a/linkcheck/command/linkchecker.py b/linkcheck/command/linkchecker.py index f4c5ff47..139a7cf8 100644 --- a/linkcheck/command/linkchecker.py +++ b/linkcheck/command/linkchecker.py @@ -135,11 +135,14 @@ def linkchecker(): files = [] if options.configfile: path = configuration.normpath(options.configfile) - if fileutil.is_valid_config_source(path): - files.append(path) + if not fileutil.is_valid_config_source(path): + raise LinkCheckerError( + _("Config file %s does not exist.") % options.configfile) + elif not fileutil.is_readable(path): + raise LinkCheckerError( + _("Could not read config file %s.") % options.configfile) else: - log.warn( - LOG_CMDLINE, _("Unreadable config file: %r"), options.configfile) + files.append(path) config.read(files=files) except LinkCheckerError as msg: # config error diff --git a/linkcheck/command/setup_config.py b/linkcheck/command/setup_config.py index 5d7e6a51..da6c36d1 100644 --- a/linkcheck/command/setup_config.py +++ b/linkcheck/command/setup_config.py @@ -203,10 +203,10 @@ def setup_config(config, options): config["useragent"] = options.useragent if options.cookiefile is not None: if not fileutil.is_valid_config_source(options.cookiefile): - log.error( - LOG_CMDLINE, _("Cookie file %s does not exist."), options.cookiefile) + print_usage( + _("Cookie file %s does not exist.") % options.cookiefile) elif not fileutil.is_readable(options.cookiefile): - msg = _("Could not read cookie file %s") % options.cookiefile - log.error(LOG_CMDLINE, msg) + print_usage( + _("Could not read cookie file %s") % options.cookiefile) else: config["cookiefile"] = options.cookiefile