configuration file reading bugfix; refs #99

This commit is contained in:
Chris Caron 2019-04-10 17:28:07 -04:00
parent 2357395c61
commit 6a9faffb0b
4 changed files with 21 additions and 18 deletions

View File

@ -118,6 +118,8 @@ class AppriseConfig(object):
return_status = False return_status = False
continue continue
logger.debug("Loading configuration: {}".format(_config))
# Instantiate ourselves an object, this function throws or # Instantiate ourselves an object, this function throws or
# returns None if it fails # returns None if it fails
instance = AppriseConfig.instantiate(_config, asset=asset, tag=tag) instance = AppriseConfig.instantiate(_config, asset=asset, tag=tag)
@ -190,7 +192,7 @@ class AppriseConfig(object):
# Some basic validation # Some basic validation
if schema not in config.SCHEMA_MAP: if schema not in config.SCHEMA_MAP:
logger.debug('Unsupported schema {}.'.format(schema)) logger.warning('Unsupported schema {}.'.format(schema))
return None return None
# Parse our url details of the server object as dictionary containing # Parse our url details of the server object as dictionary containing
@ -199,7 +201,7 @@ class AppriseConfig(object):
if not results: if not results:
# Failed to parse the server URL # Failed to parse the server URL
logger.debug('Unparseable URL {}.'.format(url)) logger.warning('Unparseable URL {}.'.format(url))
return None return None
# Build a list of tags to associate with the newly added notifications # Build a list of tags to associate with the newly added notifications
@ -217,7 +219,7 @@ class AppriseConfig(object):
except Exception: except Exception:
# the arguments are invalid or can not be used. # the arguments are invalid or can not be used.
logger.debug('Could not load URL: %s' % url) logger.warning('Could not load URL: %s' % url)
return None return None
else: else:

View File

@ -48,10 +48,10 @@ CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
# Define our default configuration we use if nothing is otherwise specified # Define our default configuration we use if nothing is otherwise specified
DEFAULT_SEARCH_PATHS = ( DEFAULT_SEARCH_PATHS = (
'file://~/.apprise', '~/.apprise',
'file://~/.apprise.yml', '~/.apprise.yml',
'file://~/.config/apprise', '~/.config/apprise',
'file://~/.config/apprise.yml', '~/.config/apprise.yml',
) )

View File

@ -417,7 +417,7 @@ class ConfigBase(URLBase):
schema = GET_SCHEMA_RE.match(_url) schema = GET_SCHEMA_RE.match(_url)
if schema is None: if schema is None:
ConfigBase.logger.warning( ConfigBase.logger.warning(
'Unsupported schema in urls entry #{}'.format(no)) 'Unsupported schema in urls entry #{}'.format(no + 1))
continue continue
# Ensure our schema is always in lower case # Ensure our schema is always in lower case
@ -427,7 +427,7 @@ class ConfigBase(URLBase):
if schema not in plugins.SCHEMA_MAP: if schema not in plugins.SCHEMA_MAP:
ConfigBase.logger.warning( ConfigBase.logger.warning(
'Unsupported schema {} in urls entry #{}'.format( 'Unsupported schema {} in urls entry #{}'.format(
schema, no)) schema, no + 1))
continue continue
# Parse our url details of the server object as dictionary # Parse our url details of the server object as dictionary
@ -436,7 +436,7 @@ class ConfigBase(URLBase):
if _results is None: if _results is None:
ConfigBase.logger.warning( ConfigBase.logger.warning(
'Unparseable {} based url; entry #{}'.format( 'Unparseable {} based url; entry #{}'.format(
schema, no)) schema, no + 1))
continue continue
# add our results to our global set # add our results to our global set
@ -456,7 +456,7 @@ class ConfigBase(URLBase):
schema = GET_SCHEMA_RE.match(_url) schema = GET_SCHEMA_RE.match(_url)
if schema is None: if schema is None:
ConfigBase.logger.warning( ConfigBase.logger.warning(
'Unsupported schema in urls entry #{}'.format(no)) 'Unsupported schema in urls entry #{}'.format(no + 1))
continue continue
# Ensure our schema is always in lower case # Ensure our schema is always in lower case
@ -466,7 +466,7 @@ class ConfigBase(URLBase):
if schema not in plugins.SCHEMA_MAP: if schema not in plugins.SCHEMA_MAP:
ConfigBase.logger.warning( ConfigBase.logger.warning(
'Unsupported schema {} in urls entry #{}'.format( 'Unsupported schema {} in urls entry #{}'.format(
schema, no)) schema, no + 1))
continue continue
# Parse our url details of the server object as dictionary # Parse our url details of the server object as dictionary
@ -511,7 +511,7 @@ class ConfigBase(URLBase):
else: else:
# Unsupported # Unsupported
ConfigBase.logger.warning( ConfigBase.logger.warning(
'Unsupported apprise yaml entry #{}'.format(no)) 'Unsupported apprise yaml entry #{}'.format(no + 1))
continue continue
# Track our entries # Track our entries
@ -536,8 +536,8 @@ class ConfigBase(URLBase):
_results['tag'] = global_tags _results['tag'] = global_tags
ConfigBase.logger.trace( ConfigBase.logger.trace(
'URL no.{} {} unpacked as:{}{}' 'URL #{}: {} unpacked as:{}{}'
.format(os.linesep, no, url, os.linesep.join( .format(no + 1, url, os.linesep, os.linesep.join(
['{}="{}"'.format(k, a) ['{}="{}"'.format(k, a)
for k, a in _results.items()]))) for k, a in _results.items()])))
@ -557,7 +557,7 @@ class ConfigBase(URLBase):
# the arguments are invalid or can not be used. # the arguments are invalid or can not be used.
ConfigBase.logger.warning( ConfigBase.logger.warning(
'Could not load apprise yaml entry #{}, item #{}' 'Could not load apprise yaml entry #{}, item #{}'
.format(no, entry)) .format(no + 1, entry))
continue continue
# if we reach here, we successfully loaded our data # if we reach here, we successfully loaded our data

View File

@ -26,6 +26,7 @@
import re import re
import io import io
import os import os
from os.path import expanduser
from .ConfigBase import ConfigBase from .ConfigBase import ConfigBase
from ..common import ConfigFormat from ..common import ConfigFormat
@ -149,7 +150,7 @@ class ConfigFile(ConfigBase):
""" """
results = ConfigBase.parse_url(url) results = ConfigBase.parse_url(url, verify_host=False)
if not results: if not results:
# We're done early; it's not a good URL # We're done early; it's not a good URL
return results return results
@ -158,5 +159,5 @@ class ConfigFile(ConfigBase):
if not match: if not match:
return None return None
results['path'] = match.group('path') results['path'] = expanduser(ConfigFile.unquote(match.group('path')))
return results return results