mirror of
https://github.com/caronc/apprise.git
synced 2025-01-21 05:19:01 +01:00
don't parse files that are simply not there via CLI
This commit is contained in:
parent
838370f441
commit
5c2ceef410
@ -114,7 +114,7 @@ class AppriseConfig(object):
|
||||
continue
|
||||
|
||||
elif not isinstance(_config, six.string_types):
|
||||
logging.error(
|
||||
logging.warning(
|
||||
"An invalid configuration (type={}) was specified.".format(
|
||||
type(_config)))
|
||||
return_status = False
|
||||
@ -125,9 +125,6 @@ class AppriseConfig(object):
|
||||
instance = AppriseConfig.instantiate(_config, asset=asset, tag=tag)
|
||||
if not isinstance(instance, ConfigBase):
|
||||
return_status = False
|
||||
logging.error(
|
||||
"Failed to load configuration url: {}".format(_config),
|
||||
)
|
||||
continue
|
||||
|
||||
# Add our initialized plugin to our server listings
|
||||
@ -195,7 +192,7 @@ class AppriseConfig(object):
|
||||
|
||||
# Some basic validation
|
||||
if schema not in config.SCHEMA_MAP:
|
||||
logger.error('Unsupported schema {}.'.format(schema))
|
||||
logger.debug('Unsupported schema {}.'.format(schema))
|
||||
return None
|
||||
|
||||
# Parse our url details of the server object as dictionary containing
|
||||
@ -204,7 +201,7 @@ class AppriseConfig(object):
|
||||
|
||||
if not results:
|
||||
# Failed to parse the server URL
|
||||
logger.error('Unparseable URL {}.'.format(url))
|
||||
logger.debug('Unparseable URL {}.'.format(url))
|
||||
return None
|
||||
|
||||
# Build a list of tags to associate with the newly added notifications
|
||||
@ -222,7 +219,7 @@ class AppriseConfig(object):
|
||||
|
||||
except Exception:
|
||||
# the arguments are invalid or can not be used.
|
||||
logger.error('Could not load URL: %s' % url)
|
||||
logger.debug('Could not load URL: %s' % url)
|
||||
return None
|
||||
|
||||
else:
|
||||
|
@ -27,6 +27,8 @@
|
||||
import click
|
||||
import logging
|
||||
import sys
|
||||
from os.path import isfile
|
||||
from os.path import expanduser
|
||||
|
||||
from . import NotifyType
|
||||
from . import Apprise
|
||||
@ -116,14 +118,14 @@ def main(title, body, config, urls, notification_type, theme, tag, verbose,
|
||||
else:
|
||||
logger.setLevel(logging.ERROR)
|
||||
|
||||
if version:
|
||||
print_version_msg()
|
||||
sys.exit(0)
|
||||
|
||||
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
|
||||
ch.setFormatter(formatter)
|
||||
logger.addHandler(ch)
|
||||
|
||||
if version:
|
||||
print_version_msg()
|
||||
sys.exit(0)
|
||||
|
||||
# Prepare our asset
|
||||
asset = AppriseAsset(theme=theme)
|
||||
|
||||
@ -133,7 +135,7 @@ def main(title, body, config, urls, notification_type, theme, tag, verbose,
|
||||
# Load our configuration if no URLs or specified configuration was
|
||||
# identified on the command line
|
||||
a.add(AppriseConfig(
|
||||
paths=DEFAULT_SEARCH_PATHS
|
||||
paths=[f for f in DEFAULT_SEARCH_PATHS if isfile(expanduser(f))]
|
||||
if not (config or urls) else config), asset=asset)
|
||||
|
||||
# Load our inventory up
|
||||
|
@ -96,7 +96,7 @@ class ConfigFile(ConfigBase):
|
||||
except OSError:
|
||||
# getsize() can throw this acception if the file is missing
|
||||
# and or simply isn't accessible
|
||||
self.logger.debug(
|
||||
self.logger.error(
|
||||
'File is not accessible: {}'.format(path))
|
||||
return None
|
||||
|
||||
@ -126,7 +126,7 @@ class ConfigFile(ConfigBase):
|
||||
|
||||
# Could not open and/or read the file; this is not a problem since
|
||||
# we scan a lot of default paths.
|
||||
self.logger.debug(
|
||||
self.logger.error(
|
||||
'File can not be opened for read: {}'.format(path))
|
||||
return None
|
||||
|
||||
@ -138,7 +138,7 @@ class ConfigFile(ConfigBase):
|
||||
# YAML Filename Detected
|
||||
self.default_config_format = ConfigFormat.YAML
|
||||
|
||||
self.logger.debug('Read Config File: %s' % (path))
|
||||
self.logger.debug('Succesfully read config file: %s' % (path))
|
||||
|
||||
# Return our response object
|
||||
return response
|
||||
|
@ -246,7 +246,7 @@ class ConfigHTTP(ConfigBase):
|
||||
# already set.
|
||||
|
||||
except requests.RequestException as e:
|
||||
self.logger.warning(
|
||||
self.logger.error(
|
||||
'A Connection error occured retrieving HTTP '
|
||||
'configuration from %s.' % self.host)
|
||||
self.logger.debug('Socket Exception: %s' % str(e))
|
||||
|
Loading…
Reference in New Issue
Block a user