Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
help='path for exported OPML (defaults to stdout)')
args = parser.parse_args(*args, **kwargs)
if args.verbose:
LOG.setLevel(max(_logging.DEBUG, _logging.ERROR - 10 * args.verbose))
try:
if not args.config:
args.config = None
feeds = Feeds(datafile=args.data, configfiles=args.config)
if args.func != cmd_new:
lock = args.func not in [cmd_list, cmd_opmlexport]
feeds.load(lock=lock)
args.func(feeds=feeds, args=args)
except RSS2EmailError as e:
e.log()
_sys.exit(1)
LOG.warning(_pprint.pformat(self.parsed))
LOG.warning('rss2email', __version__)
LOG.warning('feedparser', _feedparser.__version__)
LOG.warning('html2text', _html2text.__version__)
LOG.warning('Python', _sys.version)
LOG.warning('=== END HERE ===')
class HTTPError (ProcessingError):
def __init__(self, status, feed, **kwargs):
message = 'HTTP status {} fetching feed {}'.format(status, feed)
super(FeedError, self).__init__(feed=feed, message=message)
self.status = status
class FeedsError (RSS2EmailError):
def __init__(self, feeds=None, message=None, **kwargs):
if message is None:
message = 'error with feeds'
super(FeedsError, self).__init__(message=message, **kwargs)
self.feeds = feeds
class DataFileError (FeedsError):
def __init__(self, feeds, message=None):
if message is None:
message = 'problem with the feed data file {}'.format(
feeds.datafile)
super(DataFileError, self).__init__(feeds=feeds, message=message)
class NoDataFile (DataFileError):
message = ''
super(SendmailError, self).__init__(message=message)
self.status = status
self.stdout = stdout
self.stderr = stderr
def log(self):
super(SendmailError, self).log()
LOG.warning((
'Error attempting to send email via sendmail. You may need '
'to configure rss2email to use an SMTP server. Please refer '
'to the rss2email documentation or website ({}) for complete '
'documentation.').format(__url__))
class FeedError (RSS2EmailError):
def __init__(self, feed, message=None):
if message is None:
message = 'error with feed {}'.format(feed.name)
super(FeedError, self).__init__(message=message)
self.feed = feed
class InvalidFeedName (FeedError):
def __init__(self, name, **kwargs):
message = "invalid feed name '{}'".format(name)
super(InvalidFeedName, self).__init__(message=message, **kwargs)
class ProcessingError (FeedError):
def __init__(self, parsed, feed, **kwargs):
if message is None:
def __init__(self, message):
super(RSS2EmailError, self).__init__(message)
class TimeoutError (RSS2EmailError):
def __init__(self, time_limited_function, message=None):
if message is None:
if time_limited_function.error is not None:
message = (
'error while running time limited function: {}'.format(
time_limited_function.error[1]))
else:
message = '{} second timeout exceeded'.format(
time_limited_function.timeout)
super(TimeoutError, self).__init__(message=message)
self.time_limited_function = time_limited_function
class NoValidEncodingError (RSS2EmailError, ValueError):
def __init__(self, string, encodings):
message = 'no valid encoding for {} in {}'.format(string, encodings)
super(NoValidEncodingError, self).__init__(message=message)
self.string = string
self.encodings = encodings
class SMTPConnectionError (ValueError, RSS2EmailError):
def __init__(self, server, message=None):
if message is None:
message = 'could not connect to mail server {}'.format(server)
super(SMTPConnectionError, self).__init__(message=message)
self.server = server
def log(self):
super(SMTPConnectionError, self).log()
else:
message = '{} second timeout exceeded'.format(
time_limited_function.timeout)
super(TimeoutError, self).__init__(message=message)
self.time_limited_function = time_limited_function
class NoValidEncodingError (RSS2EmailError, ValueError):
def __init__(self, string, encodings):
message = 'no valid encoding for {} in {}'.format(string, encodings)
super(NoValidEncodingError, self).__init__(message=message)
self.string = string
self.encodings = encodings
class SMTPConnectionError (ValueError, RSS2EmailError):
def __init__(self, server, message=None):
if message is None:
message = 'could not connect to mail server {}'.format(server)
super(SMTPConnectionError, self).__init__(message=message)
self.server = server
def log(self):
super(SMTPConnectionError, self).log()
LOG.warning(
'check your config file to confirm that smtp-server and other '
'mail server settings are configured properly')
if hasattr(self.__cause__, 'reason'):
LOG.error('reason: {}'.format(self.__cause__.reason))
class SMTPAuthenticationError (SMTPConnectionError):
if hasattr(_socket, e):
_SOCKET_ERRORS.append(getattr(_socket, e))
_SOCKET_ERRORS = tuple(_SOCKET_ERRORS)
class RSS2EmailError (Exception):
def __init__(self, message):
super(RSS2EmailError, self).__init__(message)
def log(self):
LOG.error(str(self))
if self.__cause__ is not None:
LOG.error('cause: {}'.format(self.__cause__))
class TimeoutError (RSS2EmailError):
def __init__(self, time_limited_function, message=None):
if message is None:
if time_limited_function.error is not None:
message = (
'error while running time limited function: {}'.format(
time_limited_function.error[1]))
else:
message = '{} second timeout exceeded'.format(
time_limited_function.timeout)
super(TimeoutError, self).__init__(message=message)
self.time_limited_function = time_limited_function
class NoValidEncodingError (RSS2EmailError, ValueError):
def __init__(self, string, encodings):
message = 'no valid encoding for {} in {}'.format(string, encodings)
"'r2e new' first.")
class NoToEmailAddress (FeedsError, FeedError):
def __init__(self, **kwargs):
message = 'no target email address has been defined'
super(NoToEmailAddress, self).__init__(message=message, **kwargs)
def log(self):
super(NoToEmailAddress, self).log()
LOG.warning(
"please run 'r2e email emailaddress' or "
"'r2e add name url emailaddress'.")
class OPMLReadError (RSS2EmailError):
def __init__(self, **kwargs):
message = 'error reading OPML'
super(RSS2EmailError, self).__init__(message=message, **kwargs)
class Config (_configparser.ConfigParser):
def __init__(self, **kwargs):
super(Config, self).__init__(dict_type=_collections.OrderedDict)
def _setup(self, section='DEFAULT'):
_html2text.UNICODE_SNOB = self.getboolean(
section, 'unicode-snob', fallback=False)
_html2text.LINKS_EACH_PARAGRAPH = self.getboolean(
section, 'links-after-each-paragaph', fallback=False)
_html2text.BODY_WIDTH = self.getint(section, 'body-width', fallback=0)
if hasattr(self.__cause__, 'reason'):
LOG.error('reason: {}'.format(self.__cause__.reason))
class SMTPAuthenticationError (SMTPConnectionError):
def __init__(self, server, username):
message = (
'could not authenticate with mail server {} as user {}'.format(
server, username))
super(SMTPConnectionError, self).__init__(
server=server, message=message)
self.server = server
self.username = username
class SendmailError (RSS2EmailError):
def __init__(self, status=None, stdout=None, stderr=None):
if status:
message = 'sendmail exited with code {}'.format(status)
else:
message = ''
super(SendmailError, self).__init__(message=message)
self.status = status
self.stdout = stdout
self.stderr = stderr
def log(self):
super(SendmailError, self).log()
LOG.warning((
'Error attempting to send email via sendmail. You may need '
'to configure rss2email to use an SMTP server. Please refer '
'to the rss2email documentation or website ({}) for complete '