1
0
mirror of https://github.com/janeczku/calibre-web synced 2025-10-19 17:47:39 +00:00

Refactor (settings database, etc...)

This commit is contained in:
Jan Broer
2015-08-02 21:23:24 +02:00
parent d514722fa7
commit aef608aa10
8 changed files with 164 additions and 42 deletions

View File

@@ -25,7 +25,7 @@ def update_download(book_id, user_id):
ub.session.commit()
def make_mobi(book_id):
kindlegen = os.path.join(config.MAIN_DIR, "kindlegen")
kindlegen = os.path.join(config.MAIN_DIR, "vendor", "kindlegen")
if not os.path.exists(kindlegen):
return False
book = db.session.query(db.Books).filter(db.Books.id == book_id).first()
@@ -54,9 +54,10 @@ def send_mail(book_id, kindle_mail):
is_mobi = False
is_epub = False
settings = ub.get_mail_settings()
# create MIME message
msg = MIMEMultipart()
msg['From'] = config.MAIL_FROM
msg['From'] = settings["mail_from"]
msg['To'] = kindle_mail
msg['Subject'] = 'Sent to Kindle'
text = 'This email has been automatically sent by library.'
@@ -93,10 +94,10 @@ def send_mail(book_id, kindle_mail):
# send email
try:
mail_server = smtplib.SMTP(host=config.MAIL_SERVER,
port=config.MAIL_PORT)
mail_server.login(config.MAIL_LOGIN, config.MAIL_PASSWORD)
mail_server.sendmail(config.MAIL_LOGIN, kindle_mail, msg)
mail_server = smtplib.SMTP(host=settings["mail_server"],
port=settings["mail_port"])
mail_server.login(settings["mail_login"], settings["mail_password"])
mail_server.sendmail(settings["mail_login"], kindle_mail, msg)
mail_server.close()
except smtplib.SMTPException:
traceback.print_exc()