Commit 89223760 authored by Ozzieisaacs's avatar Ozzieisaacs

Merge branch 'master' into Develop

parents 0fc18bf3 9a8a1f75
...@@ -683,9 +683,10 @@ def _configuration_update_helper(): ...@@ -683,9 +683,10 @@ def _configuration_update_helper():
reboot_required |= reboot reboot_required |= reboot
# Rarfile Content configuration # Rarfile Content configuration
_config_string(to_save, "config_rarfile_location") _config_string(to_save, "config_rarfile_location")
unrar_status = helper.check_unrar(config.config_rarfile_location) if "config_rarfile_location" in to_save:
if unrar_status: unrar_status = helper.check_unrar(config.config_rarfile_location)
return _configuration_result(unrar_status, gdriveError) if unrar_status:
return _configuration_result(unrar_status, gdriveError)
try: try:
metadata_db = os.path.join(config.config_calibre_dir, "metadata.db") metadata_db = os.path.join(config.config_calibre_dir, "metadata.db")
......
...@@ -77,7 +77,6 @@ class _Settings(_Base): ...@@ -77,7 +77,6 @@ class _Settings(_Base):
config_uploading = Column(SmallInteger, default=0) config_uploading = Column(SmallInteger, default=0)
config_anonbrowse = Column(SmallInteger, default=0) config_anonbrowse = Column(SmallInteger, default=0)
config_public_reg = Column(SmallInteger, default=0) config_public_reg = Column(SmallInteger, default=0)
config_register_email = Column(SmallInteger, default=0)
config_remote_login = Column(Boolean, default=False) config_remote_login = Column(Boolean, default=False)
config_kobo_sync = Column(Boolean, default=False) config_kobo_sync = Column(Boolean, default=False)
......
...@@ -572,8 +572,7 @@ class CalibreDB(threading.Thread): ...@@ -572,8 +572,7 @@ class CalibreDB(threading.Thread):
authorterms = re.split("[, ]+", term) authorterms = re.split("[, ]+", term)
for authorterm in authorterms: for authorterm in authorterms:
q.append(Books.authors.any(func.lower(Authors.name).ilike("%" + authorterm + "%"))) q.append(Books.authors.any(func.lower(Authors.name).ilike("%" + authorterm + "%")))
return self.session.query(Books).filter(self.common_filters(True)).filter(
return self.session.query(Books).filter(self.common_filters()).filter(
or_(Books.tags.any(func.lower(Tags.name).ilike("%" + term + "%")), or_(Books.tags.any(func.lower(Tags.name).ilike("%" + term + "%")),
Books.series.any(func.lower(Series.name).ilike("%" + term + "%")), Books.series.any(func.lower(Series.name).ilike("%" + term + "%")),
Books.authors.any(and_(*q)), Books.authors.any(and_(*q)),
......
...@@ -278,7 +278,7 @@ def render_edit_book(book_id): ...@@ -278,7 +278,7 @@ def render_edit_book(book_id):
# Determine what formats don't already exist # Determine what formats don't already exist
if config.config_converterpath: if config.config_converterpath:
allowed_conversion_formats = constants.EXTENSIONS_CONVERT.copy() allowed_conversion_formats = constants.EXTENSIONS_CONVERT[:]
for file in book.data: for file in book.data:
if file.format.lower() in allowed_conversion_formats: if file.format.lower() in allowed_conversion_formats:
allowed_conversion_formats.remove(file.format.lower()) allowed_conversion_formats.remove(file.format.lower())
......
...@@ -31,8 +31,6 @@ from datetime import datetime, timedelta ...@@ -31,8 +31,6 @@ from datetime import datetime, timedelta
from tempfile import gettempdir from tempfile import gettempdir
import requests import requests
from babel import Locale as LC
from babel.core import UnknownLocaleError
from babel.dates import format_datetime from babel.dates import format_datetime
from babel.units import format_unit from babel.units import format_unit
from flask import send_from_directory, make_response, redirect, abort from flask import send_from_directory, make_response, redirect, abort
...@@ -56,6 +54,7 @@ except ImportError: ...@@ -56,6 +54,7 @@ except ImportError:
try: try:
from PIL import Image as PILImage from PIL import Image as PILImage
from PIL import UnidentifiedImageError
use_PIL = True use_PIL = True
except ImportError: except ImportError:
use_PIL = False use_PIL = False
...@@ -532,8 +531,19 @@ def get_book_cover_internal(book, use_generic_cover_on_failure): ...@@ -532,8 +531,19 @@ def get_book_cover_internal(book, use_generic_cover_on_failure):
# saves book cover from url # saves book cover from url
def save_cover_from_url(url, book_path): def save_cover_from_url(url, book_path):
img = requests.get(url, timeout=10) # ToDo: Error Handling try:
return save_cover(img, book_path) img = requests.get(url, timeout=(10, 200)) # ToDo: Error Handling
img.raise_for_status()
return save_cover(img, book_path)
except (requests.exceptions.HTTPError,
requests.exceptions.ConnectionError,
requests.exceptions.Timeout) as ex:
log.info(u'Cover Download Error %s', ex)
return False, _("Error Downloading Cover")
except UnidentifiedImageError as ex:
log.info(u'File Format Error %s', ex)
return False, _("Cover Format Error")
def save_cover_from_filestorage(filepath, saved_filename, img): def save_cover_from_filestorage(filepath, saved_filename, img):
...@@ -768,7 +778,7 @@ def get_download_link(book_id, book_format, client): ...@@ -768,7 +778,7 @@ def get_download_link(book_id, book_format, client):
book_format = book_format.split(".")[0] book_format = book_format.split(".")[0]
book = calibre_db.get_filtered_book(book_id) book = calibre_db.get_filtered_book(book_id)
if book: if book:
data1 = data = calibre_db.get_book_format(book.id, book_format.upper()) data1 = calibre_db.get_book_format(book.id, book_format.upper())
else: else:
abort(404) abort(404)
if data1: if data1:
......
...@@ -157,12 +157,12 @@ def create_access_log(log_file, log_name, formatter): ...@@ -157,12 +157,12 @@ def create_access_log(log_file, log_name, formatter):
if log_file == DEFAULT_ACCESS_LOG: if log_file == DEFAULT_ACCESS_LOG:
raise raise
file_handler = RotatingFileHandler(DEFAULT_ACCESS_LOG, maxBytes=50000, backupCount=2) file_handler = RotatingFileHandler(DEFAULT_ACCESS_LOG, maxBytes=50000, backupCount=2)
log_file = "access.log" log_file = ""
file_handler.setFormatter(formatter) file_handler.setFormatter(formatter)
access_log.addHandler(file_handler) access_log.addHandler(file_handler)
return access_log, \ return access_log, \
"access.log" if _absolute_log_file(log_file, DEFAULT_ACCESS_LOG) == DEFAULT_ACCESS_LOG else log_file "" if _absolute_log_file(log_file, DEFAULT_ACCESS_LOG) == DEFAULT_ACCESS_LOG else log_file
# Enable logging of smtp lib debug output # Enable logging of smtp lib debug output
......
...@@ -57,7 +57,7 @@ def connect(key=None, secret=None, enabled=True): ...@@ -57,7 +57,7 @@ def connect(key=None, secret=None, enabled=True):
def get_author_info(author_name): def get_author_info(author_name):
now = time.time() now = time.time()
author_info = None # _AUTHORS_CACHE.get(author_name, None) author_info = _AUTHORS_CACHE.get(author_name, None)
if author_info: if author_info:
if now < author_info._timestamp + _CACHE_TIMEOUT: if now < author_info._timestamp + _CACHE_TIMEOUT:
return author_info return author_info
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
{% endfor %} {% endfor %}
</div> </div>
{% if title == "Series" %} {% if data == "series" %}
<button class="update-view btn btn-primary" href="#" data-target="series_view" data-view="grid">Grid</button> <button class="update-view btn btn-primary" href="#" data-target="series_view" data-view="grid">Grid</button>
{% endif %} {% endif %}
</div> </div>
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -589,7 +589,7 @@ def get_languages_json(): ...@@ -589,7 +589,7 @@ def get_languages_json():
@login_required_if_no_ano @login_required_if_no_ano
def get_matching_tags(): def get_matching_tags():
tag_dict = {'tags': []} tag_dict = {'tags': []}
q = calibre_db.session.query(db.Books) q = calibre_db.session.query(db.Books).filter(calibre_db.common_filters(True))
calibre_db.session.connection().connection.connection.create_function("lower", 1, db.lcase) calibre_db.session.connection().connection.connection.create_function("lower", 1, db.lcase)
author_input = request.args.get('author_name') or '' author_input = request.args.get('author_name') or ''
title_input = request.args.get('book_title') or '' title_input = request.args.get('book_title') or ''
...@@ -657,7 +657,7 @@ def books_list(data, sort, book_id, page): ...@@ -657,7 +657,7 @@ def books_list(data, sort, book_id, page):
abort(404) abort(404)
elif data == "discover": elif data == "discover":
if current_user.check_visibility(constants.SIDEBAR_RANDOM): if current_user.check_visibility(constants.SIDEBAR_RANDOM):
entries, __, pagination = calibre_db.calibre_db.fill_indexpage(page, db.Books, True, [func.randomblob(2)]) entries, __, pagination = calibre_db.fill_indexpage(page, db.Books, True, [func.randomblob(2)])
pagination = Pagination(1, config.config_books_per_page, config.config_books_per_page) pagination = Pagination(1, config.config_books_per_page, config.config_books_per_page)
return render_title_template('discover.html', entries=entries, pagination=pagination, id=book_id, return render_title_template('discover.html', entries=entries, pagination=pagination, id=book_id,
title=_(u"Discover (Random Books)"), page="discover") title=_(u"Discover (Random Books)"), page="discover")
...@@ -1022,7 +1022,7 @@ def advanced_search(): ...@@ -1022,7 +1022,7 @@ def advanced_search():
# Build custom columns names # Build custom columns names
cc = get_cc_columns(filter_config_custom_read=True) cc = get_cc_columns(filter_config_custom_read=True)
calibre_db.session.connection().connection.connection.create_function("lower", 1, db.lcase) calibre_db.session.connection().connection.connection.create_function("lower", 1, db.lcase)
q = calibre_db.session.query(db.Books).filter(calibre_db.common_filters()).order_by(db.Books.sort) q = calibre_db.session.query(db.Books).filter(calibre_db.common_filters(True)).order_by(db.Books.sort)
include_tag_inputs = request.args.getlist('include_tag') include_tag_inputs = request.args.getlist('include_tag')
exclude_tag_inputs = request.args.getlist('exclude_tag') exclude_tag_inputs = request.args.getlist('exclude_tag')
...@@ -1641,8 +1641,8 @@ def profile(): ...@@ -1641,8 +1641,8 @@ def profile():
def read_book(book_id, book_format): def read_book(book_id, book_format):
book = calibre_db.get_filtered_book(book_id) book = calibre_db.get_filtered_book(book_id)
if not book: if not book:
flash(_(u"Error opening eBook. File does not exist or file is not accessible:"), category="error") flash(_(u"Error opening eBook. File does not exist or file is not accessible"), category="error")
log.debug(u"Error opening eBook. File does not exist or file is not accessible:") log.debug(u"Error opening eBook. File does not exist or file is not accessible")
return redirect(url_for("web.index")) return redirect(url_for("web.index"))
# check if book has bookmark # check if book has bookmark
...@@ -1681,8 +1681,8 @@ def read_book(book_id, book_format): ...@@ -1681,8 +1681,8 @@ def read_book(book_id, book_format):
# if book_format.lower() == fileext: # if book_format.lower() == fileext:
# return render_title_template('readcbr.html', comicfile=book_id, # return render_title_template('readcbr.html', comicfile=book_id,
# extension=fileext, title=_(u"Read a Book"), book=book) # extension=fileext, title=_(u"Read a Book"), book=book)
log.debug(u"Error opening eBook. File does not exist or file is not accessible:") log.debug(u"Error opening eBook. File does not exist or file is not accessible")
flash(_(u"Error opening eBook. File does not exist or file is not accessible."), category="error") flash(_(u"Error opening eBook. File does not exist or file is not accessible"), category="error")
return redirect(url_for("web.index")) return redirect(url_for("web.index"))
...@@ -1693,8 +1693,8 @@ def show_book(book_id): ...@@ -1693,8 +1693,8 @@ def show_book(book_id):
if entries: if entries:
for index in range(0, len(entries.languages)): for index in range(0, len(entries.languages)):
try: try:
entries.languages[index].language_name = LC.parse(entries.languages[index].lang_code).get_language_name( entries.languages[index].language_name = LC.parse(entries.languages[index].lang_code)\
get_locale()) .get_language_name(get_locale())
except UnknownLocaleError: except UnknownLocaleError:
entries.languages[index].language_name = _( entries.languages[index].language_name = _(
isoLanguages.get(part3=entries.languages[index].lang_code).name) isoLanguages.get(part3=entries.languages[index].lang_code).name)
...@@ -1743,6 +1743,6 @@ def show_book(book_id): ...@@ -1743,6 +1743,6 @@ def show_book(book_id):
is_xhr=request.headers.get('X-Requested-With')=='XMLHttpRequest', title=entries.title, books_shelfs=book_in_shelfs, is_xhr=request.headers.get('X-Requested-With')=='XMLHttpRequest', title=entries.title, books_shelfs=book_in_shelfs,
have_read=have_read, is_archived=is_archived, kindle_list=kindle_list, reader_list=reader_list, page="book") have_read=have_read, is_archived=is_archived, kindle_list=kindle_list, reader_list=reader_list, page="book")
else: else:
log.debug(u"Error opening eBook. File does not exist or file is not accessible:") log.debug(u"Error opening eBook. File does not exist or file is not accessible")
flash(_(u"Error opening eBook. File does not exist or file is not accessible:"), category="error") flash(_(u"Error opening eBook. File does not exist or file is not accessible"), category="error")
return redirect(url_for("web.index")) return redirect(url_for("web.index"))
...@@ -24,7 +24,10 @@ import smtplib ...@@ -24,7 +24,10 @@ import smtplib
import socket import socket
import time import time
import threading import threading
import queue try:
import queue
except ImportError:
import Queue as queue
from glob import glob from glob import glob
from shutil import copyfile from shutil import copyfile
from datetime import datetime from datetime import datetime
...@@ -278,18 +281,6 @@ class WorkerThread(threading.Thread): ...@@ -278,18 +281,6 @@ class WorkerThread(threading.Thread):
self.doLock.acquire() self.doLock.acquire()
index = self.current index = self.current
self.doLock.release() self.doLock.release()
'''dbpath = os.path.join(config.config_calibre_dir, "metadata.db")
engine = create_engine('sqlite://',
echo=False,
isolation_level="SERIALIZABLE",
connect_args={'check_same_thread': True})
engine.execute("attach database '{}' as calibre;".format(dbpath))
conn = engine.connect()
Session = scoped_session(sessionmaker(autocommit=False,
autoflush=False,
bind=engine))
w_session = Session()
engine.execute("attach database '{}' as calibre;".format(dbpath))'''
file_path = self.queue[index]['file_path'] file_path = self.queue[index]['file_path']
book_id = self.queue[index]['bookid'] book_id = self.queue[index]['bookid']
format_old_ext = u'.' + self.queue[index]['settings']['old_book_format'].lower() format_old_ext = u'.' + self.queue[index]['settings']['old_book_format'].lower()
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment