From 5c2ceef410f3c4b4f10c604e92357ee352ac7384 Mon Sep 17 00:00:00 2001 From: Chris Caron Date: Thu, 7 Mar 2019 20:47:55 -0500 Subject: [PATCH] don't parse files that are simply not there via CLI --- apprise/AppriseConfig.py | 11 ++++------- apprise/cli.py | 12 +++++++----- apprise/config/ConfigFile.py | 6 +++--- apprise/config/ConfigHTTP.py | 2 +- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/apprise/AppriseConfig.py b/apprise/AppriseConfig.py index fc12e20f..84255826 100644 --- a/apprise/AppriseConfig.py +++ b/apprise/AppriseConfig.py @@ -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: diff --git a/apprise/cli.py b/apprise/cli.py index 6604e9bf..c8bf4d21 100644 --- a/apprise/cli.py +++ b/apprise/cli.py @@ -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 diff --git a/apprise/config/ConfigFile.py b/apprise/config/ConfigFile.py index 5b086c7f..b3d77190 100644 --- a/apprise/config/ConfigFile.py +++ b/apprise/config/ConfigFile.py @@ -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 diff --git a/apprise/config/ConfigHTTP.py b/apprise/config/ConfigHTTP.py index 543d0aa2..2b1e8d3e 100644 --- a/apprise/config/ConfigHTTP.py +++ b/apprise/config/ConfigHTTP.py @@ -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))