Skip to content

Commit

Permalink
Merge pull request #896 from philborman/master
Browse files Browse the repository at this point in the history
Extra debug messages
  • Loading branch information
philborman authored Jul 4, 2017
2 parents 89a9e68 + 5ceaf5d commit 3367f8f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions lazylibrarian/notifiers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import pushover
import slack
import tweet
import lazylibrarian
from lazylibrarian import logger

# online
Expand Down
12 changes: 8 additions & 4 deletions lazylibrarian/notifiers/email_notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3367f8f

Please sign in to comment.