mirror of https://github.com/caronc/apprise
Merge pull request #100 from caronc/99-config-file-detection
Auto-loading of configuration file bugfix; refs #99pull/102/head
commit
2b0af9b2de
|
@ -118,6 +118,8 @@ class AppriseConfig(object):
|
|||
return_status = False
|
||||
continue
|
||||
|
||||
logger.debug("Loading configuration: {}".format(_config))
|
||||
|
||||
# Instantiate ourselves an object, this function throws or
|
||||
# returns None if it fails
|
||||
instance = AppriseConfig.instantiate(_config, asset=asset, tag=tag)
|
||||
|
@ -190,7 +192,7 @@ class AppriseConfig(object):
|
|||
|
||||
# Some basic validation
|
||||
if schema not in config.SCHEMA_MAP:
|
||||
logger.debug('Unsupported schema {}.'.format(schema))
|
||||
logger.warning('Unsupported schema {}.'.format(schema))
|
||||
return None
|
||||
|
||||
# Parse our url details of the server object as dictionary containing
|
||||
|
@ -199,7 +201,7 @@ class AppriseConfig(object):
|
|||
|
||||
if not results:
|
||||
# Failed to parse the server URL
|
||||
logger.debug('Unparseable URL {}.'.format(url))
|
||||
logger.warning('Unparseable URL {}.'.format(url))
|
||||
return None
|
||||
|
||||
# Build a list of tags to associate with the newly added notifications
|
||||
|
@ -217,7 +219,7 @@ class AppriseConfig(object):
|
|||
|
||||
except Exception:
|
||||
# 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
|
||||
|
||||
else:
|
||||
|
|
|
@ -48,10 +48,10 @@ CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
|
|||
|
||||
# Define our default configuration we use if nothing is otherwise specified
|
||||
DEFAULT_SEARCH_PATHS = (
|
||||
'file://~/.apprise',
|
||||
'file://~/.apprise.yml',
|
||||
'file://~/.config/apprise',
|
||||
'file://~/.config/apprise.yml',
|
||||
'~/.apprise',
|
||||
'~/.apprise.yml',
|
||||
'~/.config/apprise',
|
||||
'~/.config/apprise.yml',
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -417,7 +417,7 @@ class ConfigBase(URLBase):
|
|||
schema = GET_SCHEMA_RE.match(_url)
|
||||
if schema is None:
|
||||
ConfigBase.logger.warning(
|
||||
'Unsupported schema in urls entry #{}'.format(no))
|
||||
'Unsupported schema in urls entry #{}'.format(no + 1))
|
||||
continue
|
||||
|
||||
# Ensure our schema is always in lower case
|
||||
|
@ -427,7 +427,7 @@ class ConfigBase(URLBase):
|
|||
if schema not in plugins.SCHEMA_MAP:
|
||||
ConfigBase.logger.warning(
|
||||
'Unsupported schema {} in urls entry #{}'.format(
|
||||
schema, no))
|
||||
schema, no + 1))
|
||||
continue
|
||||
|
||||
# Parse our url details of the server object as dictionary
|
||||
|
@ -436,7 +436,7 @@ class ConfigBase(URLBase):
|
|||
if _results is None:
|
||||
ConfigBase.logger.warning(
|
||||
'Unparseable {} based url; entry #{}'.format(
|
||||
schema, no))
|
||||
schema, no + 1))
|
||||
continue
|
||||
|
||||
# add our results to our global set
|
||||
|
@ -456,7 +456,7 @@ class ConfigBase(URLBase):
|
|||
schema = GET_SCHEMA_RE.match(_url)
|
||||
if schema is None:
|
||||
ConfigBase.logger.warning(
|
||||
'Unsupported schema in urls entry #{}'.format(no))
|
||||
'Unsupported schema in urls entry #{}'.format(no + 1))
|
||||
continue
|
||||
|
||||
# Ensure our schema is always in lower case
|
||||
|
@ -466,7 +466,7 @@ class ConfigBase(URLBase):
|
|||
if schema not in plugins.SCHEMA_MAP:
|
||||
ConfigBase.logger.warning(
|
||||
'Unsupported schema {} in urls entry #{}'.format(
|
||||
schema, no))
|
||||
schema, no + 1))
|
||||
continue
|
||||
|
||||
# Parse our url details of the server object as dictionary
|
||||
|
@ -511,7 +511,7 @@ class ConfigBase(URLBase):
|
|||
else:
|
||||
# Unsupported
|
||||
ConfigBase.logger.warning(
|
||||
'Unsupported apprise yaml entry #{}'.format(no))
|
||||
'Unsupported apprise yaml entry #{}'.format(no + 1))
|
||||
continue
|
||||
|
||||
# Track our entries
|
||||
|
@ -536,8 +536,8 @@ class ConfigBase(URLBase):
|
|||
_results['tag'] = global_tags
|
||||
|
||||
ConfigBase.logger.trace(
|
||||
'URL no.{} {} unpacked as:{}{}'
|
||||
.format(os.linesep, no, url, os.linesep.join(
|
||||
'URL #{}: {} unpacked as:{}{}'
|
||||
.format(no + 1, url, os.linesep, os.linesep.join(
|
||||
['{}="{}"'.format(k, a)
|
||||
for k, a in _results.items()])))
|
||||
|
||||
|
@ -557,7 +557,7 @@ class ConfigBase(URLBase):
|
|||
# the arguments are invalid or can not be used.
|
||||
ConfigBase.logger.warning(
|
||||
'Could not load apprise yaml entry #{}, item #{}'
|
||||
.format(no, entry))
|
||||
.format(no + 1, entry))
|
||||
continue
|
||||
|
||||
# if we reach here, we successfully loaded our data
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
import re
|
||||
import io
|
||||
import os
|
||||
from os.path import expanduser
|
||||
from .ConfigBase import ConfigBase
|
||||
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:
|
||||
# We're done early; it's not a good URL
|
||||
return results
|
||||
|
@ -158,5 +159,5 @@ class ConfigFile(ConfigBase):
|
|||
if not match:
|
||||
return None
|
||||
|
||||
results['path'] = match.group('path')
|
||||
results['path'] = expanduser(ConfigFile.unquote(match.group('path')))
|
||||
return results
|
||||
|
|
Loading…
Reference in New Issue