mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-03-16 22:10:26 +00:00
Exit if FILENAME does not exist or is not readable
This commit is contained in:
parent
7a3be9ba93
commit
73b099ad4c
2 changed files with 11 additions and 8 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue