diff --git a/lazylibrarian/notifiers/__init__.py b/lazylibrarian/notifiers/__init__.py index b141b0901..14fc3c22e 100644 --- a/lazylibrarian/notifiers/__init__.py +++ b/lazylibrarian/notifiers/__init__.py @@ -26,6 +26,7 @@ import pushover import slack import tweet +import lazylibrarian from lazylibrarian import logger # online diff --git a/lazylibrarian/notifiers/email_notify.py b/lazylibrarian/notifiers/email_notify.py index 9c5b73e98..6c8f12cde 100644 --- a/lazylibrarian/notifiers/email_notify.py +++ b/lazylibrarian/notifiers/email_notify.py @@ -61,8 +61,10 @@ def _notify(message, event, force=False, files=None): for f in files: fsize = check_int(os.path.getsize(f), 0) if fsize > 20000000: - message.attach(MIMEText('%s is too large (%s) to email' % (os.path.basename(f), fsize))) + msg = '%s is too large (%s) to email' % (os.path.basename(f), fsize) + message.attach(MIMEText(msg)) else: + logger.debug('Attaching %s' % os.path.basename(f)) with open(f, "rb") as fil: part = MIMEApplication(fil.read(), Name=os.path.basename(f)) part['Content-Disposition'] = 'attachment; filename="%s"' % os.path.basename(f) @@ -103,21 +105,23 @@ def notify_snatch(self, title): def notify_download(self, title, bookid=None, force=False): if lazylibrarian.CONFIG['EMAIL_NOTIFY_ONDOWNLOAD']: - filename = '' files = None - event=notifyStrings[NOTIFY_DOWNLOAD] + event = notifyStrings[NOTIFY_DOWNLOAD] if bookid: myDB = database.DBConnection() data = myDB.match('SELECT BookFile,BookName from books where BookID=?', (bookid,)) try: filename = data['BookFile'] title = data['BookName'] + logger.debug('Found %s for bookid %s' % (filename, bookid)) except Exception: - data = myDB.match('SELECT IssueFile,Title,IssueDate from magazines where BookID=?', (bookid,)) + data = myDB.match('SELECT IssueFile,Title,IssueDate from issues where IssueID=?', (bookid,)) try: filename = data['IssueFile'] title = "%s - %s" % (data['Title'], data['IssueDate']) + logger.debug('Found %s for issueid %s' % (filename, bookid)) except Exception: + logger.debug("No download match for %s" % bookid) filename = '' if filename: files = [filename] # could add cover_image, opf