mirror of
https://github.com/janeczku/calibre-web
synced 2024-11-24 18:47:23 +00:00
Removed unnecessary Unicode "u"
This commit is contained in:
parent
8022b1bb36
commit
43ee85fbb5
12
cps/admin.py
12
cps/admin.py
@ -145,9 +145,9 @@ def shutdown():
|
|||||||
ub.dispose()
|
ub.dispose()
|
||||||
|
|
||||||
if task == 0:
|
if task == 0:
|
||||||
show_text['text'] = _(u'Server restarted, please reload page.')
|
show_text['text'] = _('Server restarted, please reload page.')
|
||||||
else:
|
else:
|
||||||
show_text['text'] = _(u'Performing Server shutdown, please close window.')
|
show_text['text'] = _('Performing Server shutdown, please close window.')
|
||||||
# stop gevent/tornado server
|
# stop gevent/tornado server
|
||||||
web_server.stop(task == 0)
|
web_server.stop(task == 0)
|
||||||
return json.dumps(show_text)
|
return json.dumps(show_text)
|
||||||
@ -155,10 +155,10 @@ def shutdown():
|
|||||||
if task == 2:
|
if task == 2:
|
||||||
log.warning("reconnecting to calibre database")
|
log.warning("reconnecting to calibre database")
|
||||||
calibre_db.reconnect_db(config, ub.app_DB_path)
|
calibre_db.reconnect_db(config, ub.app_DB_path)
|
||||||
show_text['text'] = _(u'Success! Database Reconnected')
|
show_text['text'] = _('Success! Database Reconnected')
|
||||||
return json.dumps(show_text)
|
return json.dumps(show_text)
|
||||||
|
|
||||||
show_text['text'] = _(u'Unknown command')
|
show_text['text'] = _('Unknown command')
|
||||||
return json.dumps(show_text), 400
|
return json.dumps(show_text), 400
|
||||||
|
|
||||||
|
|
||||||
@ -169,7 +169,7 @@ def queue_metadata_backup():
|
|||||||
show_text = {}
|
show_text = {}
|
||||||
log.warning("Queuing all books for metadata backup")
|
log.warning("Queuing all books for metadata backup")
|
||||||
helper.set_all_metadata_dirty()
|
helper.set_all_metadata_dirty()
|
||||||
show_text['text'] = _(u'Success! Books queued for Metadata Backup')
|
show_text['text'] = _('Success! Books queued for Metadata Backup')
|
||||||
return json.dumps(show_text)
|
return json.dumps(show_text)
|
||||||
|
|
||||||
|
|
||||||
@ -202,7 +202,7 @@ def update_thumbnails():
|
|||||||
def admin():
|
def admin():
|
||||||
version = updater_thread.get_current_version_info()
|
version = updater_thread.get_current_version_info()
|
||||||
if version is False:
|
if version is False:
|
||||||
commit = _(u'Unknown')
|
commit = _('Unknown')
|
||||||
else:
|
else:
|
||||||
if 'datetime' in version:
|
if 'datetime' in version:
|
||||||
commit = version['datetime']
|
commit = version['datetime']
|
||||||
|
@ -138,7 +138,7 @@ def get_comic_info(tmp_file_path, original_file_name, original_file_extension, r
|
|||||||
file_path=tmp_file_path,
|
file_path=tmp_file_path,
|
||||||
extension=original_file_extension,
|
extension=original_file_extension,
|
||||||
title=original_file_name,
|
title=original_file_name,
|
||||||
author=u'Unknown',
|
author='Unknown',
|
||||||
cover=_extract_cover(tmp_file_path, original_file_extension, rar_executable),
|
cover=_extract_cover(tmp_file_path, original_file_extension, rar_executable),
|
||||||
description="",
|
description="",
|
||||||
tags="",
|
tags="",
|
||||||
|
@ -69,7 +69,7 @@ class _Settings(_Base):
|
|||||||
config_certfile = Column(String)
|
config_certfile = Column(String)
|
||||||
config_keyfile = Column(String)
|
config_keyfile = Column(String)
|
||||||
config_trustedhosts = Column(String, default='')
|
config_trustedhosts = Column(String, default='')
|
||||||
config_calibre_web_title = Column(String, default=u'Calibre-Web')
|
config_calibre_web_title = Column(String, default='Calibre-Web')
|
||||||
config_books_per_page = Column(Integer, default=60)
|
config_books_per_page = Column(Integer, default=60)
|
||||||
config_random_books = Column(Integer, default=4)
|
config_random_books = Column(Integer, default=4)
|
||||||
config_authors_max = Column(Integer, default=0)
|
config_authors_max = Column(Integer, default=0)
|
||||||
|
18
cps/db.py
18
cps/db.py
@ -192,7 +192,7 @@ class Comments(Base):
|
|||||||
return self.text
|
return self.text
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return u"<Comments({0})>".format(self.text)
|
return "<Comments({0})>".format(self.text)
|
||||||
|
|
||||||
|
|
||||||
class Tags(Base):
|
class Tags(Base):
|
||||||
@ -208,7 +208,7 @@ class Tags(Base):
|
|||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return u"<Tags('{0})>".format(self.name)
|
return "<Tags('{0})>".format(self.name)
|
||||||
|
|
||||||
|
|
||||||
class Authors(Base):
|
class Authors(Base):
|
||||||
@ -228,7 +228,7 @@ class Authors(Base):
|
|||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return u"<Authors('{0},{1}{2}')>".format(self.name, self.sort, self.link)
|
return "<Authors('{0},{1}{2}')>".format(self.name, self.sort, self.link)
|
||||||
|
|
||||||
|
|
||||||
class Series(Base):
|
class Series(Base):
|
||||||
@ -246,7 +246,7 @@ class Series(Base):
|
|||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return u"<Series('{0},{1}')>".format(self.name, self.sort)
|
return "<Series('{0},{1}')>".format(self.name, self.sort)
|
||||||
|
|
||||||
|
|
||||||
class Ratings(Base):
|
class Ratings(Base):
|
||||||
@ -262,7 +262,7 @@ class Ratings(Base):
|
|||||||
return self.rating
|
return self.rating
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return u"<Ratings('{0}')>".format(self.rating)
|
return "<Ratings('{0}')>".format(self.rating)
|
||||||
|
|
||||||
|
|
||||||
class Languages(Base):
|
class Languages(Base):
|
||||||
@ -281,7 +281,7 @@ class Languages(Base):
|
|||||||
return self.lang_code
|
return self.lang_code
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return u"<Languages('{0}')>".format(self.lang_code)
|
return "<Languages('{0}')>".format(self.lang_code)
|
||||||
|
|
||||||
|
|
||||||
class Publishers(Base):
|
class Publishers(Base):
|
||||||
@ -299,7 +299,7 @@ class Publishers(Base):
|
|||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return u"<Publishers('{0},{1}')>".format(self.name, self.sort)
|
return "<Publishers('{0},{1}')>".format(self.name, self.sort)
|
||||||
|
|
||||||
|
|
||||||
class Data(Base):
|
class Data(Base):
|
||||||
@ -323,7 +323,7 @@ class Data(Base):
|
|||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return u"<Data('{0},{1}{2}{3}')>".format(self.book, self.format, self.uncompressed_size, self.name)
|
return "<Data('{0},{1}{2}{3}')>".format(self.book, self.format, self.uncompressed_size, self.name)
|
||||||
|
|
||||||
|
|
||||||
class Metadata_Dirtied(Base):
|
class Metadata_Dirtied(Base):
|
||||||
@ -377,7 +377,7 @@ class Books(Base):
|
|||||||
self.has_cover = (has_cover != None)
|
self.has_cover = (has_cover != None)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return u"<Books('{0},{1}{2}{3}{4}{5}{6}{7}{8}')>".format(self.title, self.sort, self.author_sort,
|
return "<Books('{0},{1}{2}{3}{4}{5}{6}{7}{8}')>".format(self.title, self.sort, self.author_sort,
|
||||||
self.timestamp, self.pubdate, self.series_index,
|
self.timestamp, self.pubdate, self.series_index,
|
||||||
self.last_modified, self.path, self.has_cover)
|
self.last_modified, self.path, self.has_cover)
|
||||||
|
|
||||||
|
@ -573,9 +573,9 @@ def table_xchange_author_title():
|
|||||||
|
|
||||||
|
|
||||||
def merge_metadata(to_save, meta):
|
def merge_metadata(to_save, meta):
|
||||||
if to_save.get('author_name', "") == _(u'Unknown'):
|
if to_save.get('author_name', "") == _('Unknown'):
|
||||||
to_save['author_name'] = ''
|
to_save['author_name'] = ''
|
||||||
if to_save.get('book_title', "") == _(u'Unknown'):
|
if to_save.get('book_title', "") == _('Unknown'):
|
||||||
to_save['book_title'] = ''
|
to_save['book_title'] = ''
|
||||||
for s_field, m_field in [
|
for s_field, m_field in [
|
||||||
('tags', 'tags'), ('author_name', 'author'), ('series', 'series'),
|
('tags', 'tags'), ('author_name', 'author'), ('series', 'series'),
|
||||||
@ -611,7 +611,7 @@ def prepare_authors(authr):
|
|||||||
|
|
||||||
# we have all author names now
|
# we have all author names now
|
||||||
if input_authors == ['']:
|
if input_authors == ['']:
|
||||||
input_authors = [_(u'Unknown')] # prevent empty Author
|
input_authors = [_('Unknown')] # prevent empty Author
|
||||||
|
|
||||||
renamed = list()
|
renamed = list()
|
||||||
for in_aut in input_authors:
|
for in_aut in input_authors:
|
||||||
@ -628,7 +628,7 @@ def prepare_authors(authr):
|
|||||||
|
|
||||||
|
|
||||||
def prepare_authors_on_upload(title, authr):
|
def prepare_authors_on_upload(title, authr):
|
||||||
if title != _(u'Unknown') and authr != _(u'Unknown'):
|
if title != _('Unknown') and authr != _('Unknown'):
|
||||||
entry = calibre_db.check_exists_book(authr, title)
|
entry = calibre_db.check_exists_book(authr, title)
|
||||||
if entry:
|
if entry:
|
||||||
log.info("Uploaded book probably exists in library")
|
log.info("Uploaded book probably exists in library")
|
||||||
@ -771,7 +771,7 @@ def delete_whole_book(book_id, book):
|
|||||||
|
|
||||||
# check if only this book links to:
|
# check if only this book links to:
|
||||||
# author, language, series, tags, custom columns
|
# author, language, series, tags, custom columns
|
||||||
modify_database_object([u''], book.authors, db.Authors, calibre_db.session, 'author')
|
modify_database_object([''], book.authors, db.Authors, calibre_db.session, 'author')
|
||||||
modify_database_object([u''], book.tags, db.Tags, calibre_db.session, 'tags')
|
modify_database_object([u''], book.tags, db.Tags, calibre_db.session, 'tags')
|
||||||
modify_database_object([u''], book.series, db.Series, calibre_db.session, 'series')
|
modify_database_object([u''], book.series, db.Series, calibre_db.session, 'series')
|
||||||
modify_database_object([u''], book.languages, db.Languages, calibre_db.session, 'languages')
|
modify_database_object([u''], book.languages, db.Languages, calibre_db.session, 'languages')
|
||||||
|
@ -80,13 +80,13 @@ def get_epub_info(tmp_file_path, original_file_name, original_file_extension):
|
|||||||
if epub_metadata['subject'] == 'Unknown':
|
if epub_metadata['subject'] == 'Unknown':
|
||||||
epub_metadata['subject'] = ''
|
epub_metadata['subject'] = ''
|
||||||
|
|
||||||
if epub_metadata['publisher'] == u'Unknown':
|
if epub_metadata['publisher'] == 'Unknown':
|
||||||
epub_metadata['publisher'] = ''
|
epub_metadata['publisher'] = ''
|
||||||
|
|
||||||
if epub_metadata['date'] == u'Unknown':
|
if epub_metadata['date'] == 'Unknown':
|
||||||
epub_metadata['date'] = ''
|
epub_metadata['date'] = ''
|
||||||
|
|
||||||
if epub_metadata['description'] == u'Unknown':
|
if epub_metadata['description'] == 'Unknown':
|
||||||
description = tree.xpath("//*[local-name() = 'description']/text()")
|
description = tree.xpath("//*[local-name() = 'description']/text()")
|
||||||
if len(description) > 0:
|
if len(description) > 0:
|
||||||
epub_metadata['description'] = description
|
epub_metadata['description'] = description
|
||||||
|
14
cps/fb2.py
14
cps/fb2.py
@ -38,19 +38,19 @@ def get_fb2_info(tmp_file_path, original_file_extension):
|
|||||||
if len(last_name):
|
if len(last_name):
|
||||||
last_name = last_name[0]
|
last_name = last_name[0]
|
||||||
else:
|
else:
|
||||||
last_name = u''
|
last_name = ''
|
||||||
middle_name = element.xpath('fb:middle-name/text()', namespaces=ns)
|
middle_name = element.xpath('fb:middle-name/text()', namespaces=ns)
|
||||||
if len(middle_name):
|
if len(middle_name):
|
||||||
middle_name = middle_name[0]
|
middle_name = middle_name[0]
|
||||||
else:
|
else:
|
||||||
middle_name = u''
|
middle_name = ''
|
||||||
first_name = element.xpath('fb:first-name/text()', namespaces=ns)
|
first_name = element.xpath('fb:first-name/text()', namespaces=ns)
|
||||||
if len(first_name):
|
if len(first_name):
|
||||||
first_name = first_name[0]
|
first_name = first_name[0]
|
||||||
else:
|
else:
|
||||||
first_name = u''
|
first_name = ''
|
||||||
return (first_name + u' '
|
return (first_name + ' '
|
||||||
+ middle_name + u' '
|
+ middle_name + ' '
|
||||||
+ last_name)
|
+ last_name)
|
||||||
|
|
||||||
author = str(", ".join(map(get_author, authors)))
|
author = str(", ".join(map(get_author, authors)))
|
||||||
@ -59,12 +59,12 @@ def get_fb2_info(tmp_file_path, original_file_extension):
|
|||||||
if len(title):
|
if len(title):
|
||||||
title = str(title[0])
|
title = str(title[0])
|
||||||
else:
|
else:
|
||||||
title = u''
|
title = ''
|
||||||
description = tree.xpath('/fb:FictionBook/fb:description/fb:publish-info/fb:book-name/text()', namespaces=ns)
|
description = tree.xpath('/fb:FictionBook/fb:description/fb:publish-info/fb:book-name/text()', namespaces=ns)
|
||||||
if len(description):
|
if len(description):
|
||||||
description = str(description[0])
|
description = str(description[0])
|
||||||
else:
|
else:
|
||||||
description = u''
|
description = ''
|
||||||
|
|
||||||
return BookMeta(
|
return BookMeta(
|
||||||
file_path=tmp_file_path,
|
file_path=tmp_file_path,
|
||||||
|
@ -55,7 +55,7 @@ def authenticate_google_drive():
|
|||||||
try:
|
try:
|
||||||
authUrl = gdriveutils.Gauth.Instance().auth.GetAuthUrl()
|
authUrl = gdriveutils.Gauth.Instance().auth.GetAuthUrl()
|
||||||
except gdriveutils.InvalidConfigError:
|
except gdriveutils.InvalidConfigError:
|
||||||
flash(_(u'Google Drive setup not completed, try to deactivate and activate Google Drive again'),
|
flash(_('Google Drive setup not completed, try to deactivate and activate Google Drive again'),
|
||||||
category="error")
|
category="error")
|
||||||
return redirect(url_for('web.index'))
|
return redirect(url_for('web.index'))
|
||||||
return redirect(authUrl)
|
return redirect(authUrl)
|
||||||
@ -91,9 +91,9 @@ def watch_gdrive():
|
|||||||
config.save()
|
config.save()
|
||||||
except HttpError as e:
|
except HttpError as e:
|
||||||
reason=json.loads(e.content)['error']['errors'][0]
|
reason=json.loads(e.content)['error']['errors'][0]
|
||||||
if reason['reason'] == u'push.webhookUrlUnauthorized':
|
if reason['reason'] == 'push.webhookUrlUnauthorized':
|
||||||
flash(_(u'Callback domain is not verified, '
|
flash(_('Callback domain is not verified, '
|
||||||
u'please follow steps to verify domain in google developer console'), category="error")
|
'please follow steps to verify domain in google developer console'), category="error")
|
||||||
else:
|
else:
|
||||||
flash(reason['message'], category="error")
|
flash(reason['message'], category="error")
|
||||||
|
|
||||||
|
@ -556,7 +556,7 @@ def updateGdriveCalibreFromLocal():
|
|||||||
|
|
||||||
# update gdrive.db on edit of books title
|
# update gdrive.db on edit of books title
|
||||||
def updateDatabaseOnEdit(ID,newPath):
|
def updateDatabaseOnEdit(ID,newPath):
|
||||||
sqlCheckPath = newPath if newPath[-1] == '/' else newPath + u'/'
|
sqlCheckPath = newPath if newPath[-1] == '/' else newPath + '/'
|
||||||
storedPathName = session.query(GdriveId).filter(GdriveId.gdrive_id == ID).first()
|
storedPathName = session.query(GdriveId).filter(GdriveId.gdrive_id == ID).first()
|
||||||
if storedPathName:
|
if storedPathName:
|
||||||
storedPathName.path = sqlCheckPath
|
storedPathName.path = sqlCheckPath
|
||||||
|
@ -95,11 +95,11 @@ def convert_book_format(book_id, calibre_path, old_book_format, new_book_format,
|
|||||||
if ereader_mail:
|
if ereader_mail:
|
||||||
settings = config.get_mail_settings()
|
settings = config.get_mail_settings()
|
||||||
settings['subject'] = _('Send to eReader') # pretranslate Subject for Email
|
settings['subject'] = _('Send to eReader') # pretranslate Subject for Email
|
||||||
settings['body'] = _(u'This Email has been sent via Calibre-Web.')
|
settings['body'] = _('This Email has been sent via Calibre-Web.')
|
||||||
else:
|
else:
|
||||||
settings = dict()
|
settings = dict()
|
||||||
link = '<a href="{}">{}</a>'.format(url_for('web.show_book', book_id=book.id), escape(book.title)) # prevent xss
|
link = '<a href="{}">{}</a>'.format(url_for('web.show_book', book_id=book.id), escape(book.title)) # prevent xss
|
||||||
txt = u"{} -> {}: {}".format(
|
txt = "{} -> {}: {}".format(
|
||||||
old_book_format.upper(),
|
old_book_format.upper(),
|
||||||
new_book_format.upper(),
|
new_book_format.upper(),
|
||||||
link)
|
link)
|
||||||
@ -111,9 +111,9 @@ def convert_book_format(book_id, calibre_path, old_book_format, new_book_format,
|
|||||||
|
|
||||||
# Texts are not lazy translated as they are supposed to get send out as is
|
# Texts are not lazy translated as they are supposed to get send out as is
|
||||||
def send_test_mail(ereader_mail, user_name):
|
def send_test_mail(ereader_mail, user_name):
|
||||||
WorkerThread.add(user_name, TaskEmail(_(u'Calibre-Web Test Email'), None, None,
|
WorkerThread.add(user_name, TaskEmail(_('Calibre-Web Test Email'), None, None,
|
||||||
config.get_mail_settings(), ereader_mail, N_("Test Email"),
|
config.get_mail_settings(), ereader_mail, N_("Test Email"),
|
||||||
_(u'This Email has been sent via Calibre-Web.')))
|
_('This Email has been sent via Calibre-Web.')))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ def send_registration_mail(e_mail, user_name, default_password, resend=False):
|
|||||||
txt += "Regards,\r\n\r\n"
|
txt += "Regards,\r\n\r\n"
|
||||||
txt += "Calibre-Web"
|
txt += "Calibre-Web"
|
||||||
WorkerThread.add(None, TaskEmail(
|
WorkerThread.add(None, TaskEmail(
|
||||||
subject=_(u'Get Started with Calibre-Web'),
|
subject=_('Get Started with Calibre-Web'),
|
||||||
filepath=None,
|
filepath=None,
|
||||||
attachment=None,
|
attachment=None,
|
||||||
settings=config.get_mail_settings(),
|
settings=config.get_mail_settings(),
|
||||||
@ -187,7 +187,7 @@ def check_send_to_ereader(entry):
|
|||||||
book_formats.extend(check_send_to_ereader_with_converter(formats))
|
book_formats.extend(check_send_to_ereader_with_converter(formats))
|
||||||
return book_formats
|
return book_formats
|
||||||
else:
|
else:
|
||||||
log.error(u'Cannot find book entry %d', entry.id)
|
log.error('Cannot find book entry %d', entry.id)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@ -213,10 +213,10 @@ def send_mail(book_id, book_format, convert, ereader_mail, calibrepath, user_id)
|
|||||||
|
|
||||||
if convert == 1:
|
if convert == 1:
|
||||||
# returns None if success, otherwise errormessage
|
# returns None if success, otherwise errormessage
|
||||||
return convert_book_format(book_id, calibrepath, u'epub', book_format.lower(), user_id, ereader_mail)
|
return convert_book_format(book_id, calibrepath, 'epub', book_format.lower(), user_id, ereader_mail)
|
||||||
if convert == 2:
|
if convert == 2:
|
||||||
# returns None if success, otherwise errormessage
|
# returns None if success, otherwise errormessage
|
||||||
return convert_book_format(book_id, calibrepath, u'azw3', book_format.lower(), user_id, ereader_mail)
|
return convert_book_format(book_id, calibrepath, 'azw3', book_format.lower(), user_id, ereader_mail)
|
||||||
|
|
||||||
for entry in iter(book.data):
|
for entry in iter(book.data):
|
||||||
if entry.format.upper() == book_format.upper():
|
if entry.format.upper() == book_format.upper():
|
||||||
@ -225,7 +225,7 @@ def send_mail(book_id, book_format, convert, ereader_mail, calibrepath, user_id)
|
|||||||
email_text = N_("%(book)s send to eReader", book=link)
|
email_text = N_("%(book)s send to eReader", book=link)
|
||||||
WorkerThread.add(user_id, TaskEmail(_("Send to eReader"), book.path, converted_file_name,
|
WorkerThread.add(user_id, TaskEmail(_("Send to eReader"), book.path, converted_file_name,
|
||||||
config.get_mail_settings(), ereader_mail,
|
config.get_mail_settings(), ereader_mail,
|
||||||
email_text, _(u'This Email has been sent via Calibre-Web.')))
|
email_text, _('This Email has been sent via Calibre-Web.')))
|
||||||
return
|
return
|
||||||
return _("The requested file could not be read. Maybe wrong permissions?")
|
return _("The requested file could not be read. Maybe wrong permissions?")
|
||||||
|
|
||||||
@ -235,16 +235,16 @@ def get_valid_filename(value, replace_whitespace=True, chars=128):
|
|||||||
Returns the given string converted to a string that can be used for a clean
|
Returns the given string converted to a string that can be used for a clean
|
||||||
filename. Limits num characters to 128 max.
|
filename. Limits num characters to 128 max.
|
||||||
"""
|
"""
|
||||||
if value[-1:] == u'.':
|
if value[-1:] == '.':
|
||||||
value = value[:-1]+u'_'
|
value = value[:-1]+'_'
|
||||||
value = value.replace("/", "_").replace(":", "_").strip('\0')
|
value = value.replace("/", "_").replace(":", "_").strip('\0')
|
||||||
if config.config_unicode_filename:
|
if config.config_unicode_filename:
|
||||||
value = (unidecode.unidecode(value))
|
value = (unidecode.unidecode(value))
|
||||||
if replace_whitespace:
|
if replace_whitespace:
|
||||||
# *+:\"/<>? are replaced by _
|
# *+:\"/<>? are replaced by _
|
||||||
value = re.sub(r'[*+:\\\"/<>?]+', u'_', value, flags=re.U)
|
value = re.sub(r'[*+:\\\"/<>?]+', '_', value, flags=re.U)
|
||||||
# pipe has to be replaced with comma
|
# pipe has to be replaced with comma
|
||||||
value = re.sub(r'[|]+', u',', value, flags=re.U)
|
value = re.sub(r'[|]+', ',', value, flags=re.U)
|
||||||
|
|
||||||
value = value.encode('utf-8')[:chars].decode('utf-8', errors='ignore').strip()
|
value = value.encode('utf-8')[:chars].decode('utf-8', errors='ignore').strip()
|
||||||
|
|
||||||
@ -416,8 +416,8 @@ def clean_author_database(renamed_author, calibre_path="", local_book=None, gdri
|
|||||||
g_file = gd.getFileFromEbooksFolder(all_new_path,
|
g_file = gd.getFileFromEbooksFolder(all_new_path,
|
||||||
file_format.name + '.' + file_format.format.lower())
|
file_format.name + '.' + file_format.format.lower())
|
||||||
if g_file:
|
if g_file:
|
||||||
gd.moveGdriveFileRemote(g_file, all_new_name + u'.' + file_format.format.lower())
|
gd.moveGdriveFileRemote(g_file, all_new_name + '.' + file_format.format.lower())
|
||||||
gd.updateDatabaseOnEdit(g_file['id'], all_new_name + u'.' + file_format.format.lower())
|
gd.updateDatabaseOnEdit(g_file['id'], all_new_name + '.' + file_format.format.lower())
|
||||||
else:
|
else:
|
||||||
log.error("File {} not found on gdrive"
|
log.error("File {} not found on gdrive"
|
||||||
.format(all_new_path, file_format.name + '.' + file_format.format.lower()))
|
.format(all_new_path, file_format.name + '.' + file_format.format.lower()))
|
||||||
@ -510,25 +510,25 @@ def update_dir_structure_gdrive(book_id, first_author, renamed_author):
|
|||||||
authordir = book.path.split('/')[0]
|
authordir = book.path.split('/')[0]
|
||||||
titledir = book.path.split('/')[1]
|
titledir = book.path.split('/')[1]
|
||||||
new_authordir = rename_all_authors(first_author, renamed_author, gdrive=True)
|
new_authordir = rename_all_authors(first_author, renamed_author, gdrive=True)
|
||||||
new_titledir = get_valid_filename(book.title, chars=96) + u" (" + str(book_id) + u")"
|
new_titledir = get_valid_filename(book.title, chars=96) + " (" + str(book_id) + ")"
|
||||||
|
|
||||||
if titledir != new_titledir:
|
if titledir != new_titledir:
|
||||||
g_file = gd.getFileFromEbooksFolder(os.path.dirname(book.path), titledir)
|
g_file = gd.getFileFromEbooksFolder(os.path.dirname(book.path), titledir)
|
||||||
if g_file:
|
if g_file:
|
||||||
gd.moveGdriveFileRemote(g_file, new_titledir)
|
gd.moveGdriveFileRemote(g_file, new_titledir)
|
||||||
book.path = book.path.split('/')[0] + u'/' + new_titledir
|
book.path = book.path.split('/')[0] + '/' + new_titledir
|
||||||
gd.updateDatabaseOnEdit(g_file['id'], book.path) # only child folder affected
|
gd.updateDatabaseOnEdit(g_file['id'], book.path) # only child folder affected
|
||||||
else:
|
else:
|
||||||
return _(u'File %(file)s not found on Google Drive', file=book.path) # file not found
|
return _('File %(file)s not found on Google Drive', file=book.path) # file not found
|
||||||
|
|
||||||
if authordir != new_authordir and authordir not in renamed_author:
|
if authordir != new_authordir and authordir not in renamed_author:
|
||||||
g_file = gd.getFileFromEbooksFolder(os.path.dirname(book.path), new_titledir)
|
g_file = gd.getFileFromEbooksFolder(os.path.dirname(book.path), new_titledir)
|
||||||
if g_file:
|
if g_file:
|
||||||
gd.moveGdriveFolderRemote(g_file, new_authordir)
|
gd.moveGdriveFolderRemote(g_file, new_authordir)
|
||||||
book.path = new_authordir + u'/' + book.path.split('/')[1]
|
book.path = new_authordir + '/' + book.path.split('/')[1]
|
||||||
gd.updateDatabaseOnEdit(g_file['id'], book.path)
|
gd.updateDatabaseOnEdit(g_file['id'], book.path)
|
||||||
else:
|
else:
|
||||||
return _(u'File %(file)s not found on Google Drive', file=authordir) # file not found
|
return _('File %(file)s not found on Google Drive', file=authordir) # file not found
|
||||||
|
|
||||||
# change location in database to new author/title path
|
# change location in database to new author/title path
|
||||||
book.path = os.path.join(new_authordir, new_titledir).replace('\\', '/')
|
book.path = os.path.join(new_authordir, new_titledir).replace('\\', '/')
|
||||||
@ -600,7 +600,7 @@ def delete_book_gdrive(book, book_format):
|
|||||||
gd.deleteDatabaseEntry(g_file['id'])
|
gd.deleteDatabaseEntry(g_file['id'])
|
||||||
g_file.Trash()
|
g_file.Trash()
|
||||||
else:
|
else:
|
||||||
error = _(u'Book path %(path)s not found on Google Drive', path=book.path) # file not found
|
error = _('Book path %(path)s not found on Google Drive', path=book.path) # file not found
|
||||||
|
|
||||||
return error is None, error
|
return error is None, error
|
||||||
|
|
||||||
|
@ -295,8 +295,8 @@ if ub.oauth_support:
|
|||||||
@oauth_error.connect_via(oauthblueprints[0]['blueprint'])
|
@oauth_error.connect_via(oauthblueprints[0]['blueprint'])
|
||||||
def github_error(blueprint, error, error_description=None, error_uri=None):
|
def github_error(blueprint, error, error_description=None, error_uri=None):
|
||||||
msg = (
|
msg = (
|
||||||
u"OAuth error from {name}! "
|
"OAuth error from {name}! "
|
||||||
u"error={error} description={description} uri={uri}"
|
"error={error} description={description} uri={uri}"
|
||||||
).format(
|
).format(
|
||||||
name=blueprint.name,
|
name=blueprint.name,
|
||||||
error=error,
|
error=error,
|
||||||
@ -308,8 +308,8 @@ if ub.oauth_support:
|
|||||||
@oauth_error.connect_via(oauthblueprints[1]['blueprint'])
|
@oauth_error.connect_via(oauthblueprints[1]['blueprint'])
|
||||||
def google_error(blueprint, error, error_description=None, error_uri=None):
|
def google_error(blueprint, error, error_description=None, error_uri=None):
|
||||||
msg = (
|
msg = (
|
||||||
u"OAuth error from {name}! "
|
"OAuth error from {name}! "
|
||||||
u"error={error} description={description} uri={uri}"
|
"error={error} description={description} uri={uri}"
|
||||||
).format(
|
).format(
|
||||||
name=blueprint.name,
|
name=blueprint.name,
|
||||||
error=error,
|
error=error,
|
||||||
|
@ -328,7 +328,7 @@ def feed_format(book_id):
|
|||||||
@requires_basic_auth_if_no_ano
|
@requires_basic_auth_if_no_ano
|
||||||
def feed_languagesindex():
|
def feed_languagesindex():
|
||||||
off = request.args.get("offset") or 0
|
off = request.args.get("offset") or 0
|
||||||
if current_user.filter_language() == u"all":
|
if current_user.filter_language() == "all":
|
||||||
languages = calibre_db.speaking_language()
|
languages = calibre_db.speaking_language()
|
||||||
else:
|
else:
|
||||||
languages = calibre_db.session.query(db.Languages).filter(
|
languages = calibre_db.session.query(db.Languages).filter(
|
||||||
|
@ -189,14 +189,14 @@ def extend_search_term(searchterm,
|
|||||||
format_date(datetime.strptime(pub_start, "%Y-%m-%d"),
|
format_date(datetime.strptime(pub_start, "%Y-%m-%d"),
|
||||||
format='medium')])
|
format='medium')])
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pub_start = u""
|
pub_start = ""
|
||||||
if pub_end:
|
if pub_end:
|
||||||
try:
|
try:
|
||||||
searchterm.extend([_("Published before ") +
|
searchterm.extend([_("Published before ") +
|
||||||
format_date(datetime.strptime(pub_end, "%Y-%m-%d"),
|
format_date(datetime.strptime(pub_end, "%Y-%m-%d"),
|
||||||
format='medium')])
|
format='medium')])
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pub_end = u""
|
pub_end = ""
|
||||||
elements = {'tag': db.Tags, 'serie':db.Series, 'shelf':ub.Shelf}
|
elements = {'tag': db.Tags, 'serie':db.Series, 'shelf':ub.Shelf}
|
||||||
for key, db_element in elements.items():
|
for key, db_element in elements.items():
|
||||||
tag_names = calibre_db.session.query(db_element).filter(db_element.id.in_(tags['include_' + key])).all()
|
tag_names = calibre_db.session.query(db_element).filter(db_element.id.in_(tags['include_' + key])).all()
|
||||||
@ -267,13 +267,13 @@ def render_adv_search_results(term, offset=None, order=None, limit=None):
|
|||||||
column_start = term.get('custom_column_' + str(c.id) + '_start')
|
column_start = term.get('custom_column_' + str(c.id) + '_start')
|
||||||
column_end = term.get('custom_column_' + str(c.id) + '_end')
|
column_end = term.get('custom_column_' + str(c.id) + '_end')
|
||||||
if column_start:
|
if column_start:
|
||||||
search_term.extend([u"{} >= {}".format(c.name,
|
search_term.extend(["{} >= {}".format(c.name,
|
||||||
format_date(datetime.strptime(column_start, "%Y-%m-%d").date(),
|
format_date(datetime.strptime(column_start, "%Y-%m-%d").date(),
|
||||||
format='medium')
|
format='medium')
|
||||||
)])
|
)])
|
||||||
cc_present = True
|
cc_present = True
|
||||||
if column_end:
|
if column_end:
|
||||||
search_term.extend([u"{} <= {}".format(c.name,
|
search_term.extend(["{} <= {}".format(c.name,
|
||||||
format_date(datetime.strptime(column_end, "%Y-%m-%d").date(),
|
format_date(datetime.strptime(column_end, "%Y-%m-%d").date(),
|
||||||
format='medium')
|
format='medium')
|
||||||
)])
|
)])
|
||||||
@ -366,7 +366,7 @@ def render_prepare_search_form(cc):
|
|||||||
.filter(calibre_db.common_filters()) \
|
.filter(calibre_db.common_filters()) \
|
||||||
.group_by(db.Data.format)\
|
.group_by(db.Data.format)\
|
||||||
.order_by(db.Data.format).all()
|
.order_by(db.Data.format).all()
|
||||||
if current_user.filter_language() == u"all":
|
if current_user.filter_language() == "all":
|
||||||
languages = calibre_db.speaking_language()
|
languages = calibre_db.speaking_language()
|
||||||
else:
|
else:
|
||||||
languages = None
|
languages = None
|
||||||
|
@ -64,7 +64,7 @@ class TaskConvert(CalibreTask):
|
|||||||
if df:
|
if df:
|
||||||
datafile = os.path.join(config.config_calibre_dir,
|
datafile = os.path.join(config.config_calibre_dir,
|
||||||
cur_book.path,
|
cur_book.path,
|
||||||
data.name + u"." + self.settings['old_book_format'].lower())
|
data.name + "." + self.settings['old_book_format'].lower())
|
||||||
if not os.path.exists(os.path.join(config.config_calibre_dir, cur_book.path)):
|
if not os.path.exists(os.path.join(config.config_calibre_dir, cur_book.path)):
|
||||||
os.makedirs(os.path.join(config.config_calibre_dir, cur_book.path))
|
os.makedirs(os.path.join(config.config_calibre_dir, cur_book.path))
|
||||||
df.GetContentFile(datafile)
|
df.GetContentFile(datafile)
|
||||||
@ -78,7 +78,7 @@ class TaskConvert(CalibreTask):
|
|||||||
|
|
||||||
filename = self._convert_ebook_format()
|
filename = self._convert_ebook_format()
|
||||||
if config.config_use_google_drive:
|
if config.config_use_google_drive:
|
||||||
os.remove(self.file_path + u'.' + self.settings['old_book_format'].lower())
|
os.remove(self.file_path + '.' + self.settings['old_book_format'].lower())
|
||||||
|
|
||||||
if filename:
|
if filename:
|
||||||
if config.config_use_google_drive:
|
if config.config_use_google_drive:
|
||||||
@ -107,8 +107,8 @@ class TaskConvert(CalibreTask):
|
|||||||
local_db = db.CalibreDB(expire_on_commit=False, init=True)
|
local_db = db.CalibreDB(expire_on_commit=False, init=True)
|
||||||
file_path = self.file_path
|
file_path = self.file_path
|
||||||
book_id = self.book_id
|
book_id = self.book_id
|
||||||
format_old_ext = u'.' + self.settings['old_book_format'].lower()
|
format_old_ext = '.' + self.settings['old_book_format'].lower()
|
||||||
format_new_ext = u'.' + self.settings['new_book_format'].lower()
|
format_new_ext = '.' + self.settings['new_book_format'].lower()
|
||||||
|
|
||||||
# check to see if destination format already exists - or if book is in database
|
# check to see if destination format already exists - or if book is in database
|
||||||
# if it does - mark the conversion task as complete and return a success
|
# if it does - mark the conversion task as complete and return a success
|
||||||
|
@ -166,7 +166,7 @@ class TaskEmail(CalibreTask):
|
|||||||
self.send_gmail_email(msg)
|
self.send_gmail_email(msg)
|
||||||
except MemoryError as e:
|
except MemoryError as e:
|
||||||
log.error_or_exception(e, stacklevel=3)
|
log.error_or_exception(e, stacklevel=3)
|
||||||
self._handleError(u'MemoryError sending e-mail: {}'.format(str(e)))
|
self._handleError('MemoryError sending e-mail: {}'.format(str(e)))
|
||||||
except (smtplib.SMTPException, smtplib.SMTPAuthenticationError) as e:
|
except (smtplib.SMTPException, smtplib.SMTPAuthenticationError) as e:
|
||||||
log.error_or_exception(e, stacklevel=3)
|
log.error_or_exception(e, stacklevel=3)
|
||||||
if hasattr(e, "smtp_error"):
|
if hasattr(e, "smtp_error"):
|
||||||
@ -177,13 +177,13 @@ class TaskEmail(CalibreTask):
|
|||||||
text = '\n'.join(e.args)
|
text = '\n'.join(e.args)
|
||||||
else:
|
else:
|
||||||
text = ''
|
text = ''
|
||||||
self._handleError(u'Smtplib Error sending e-mail: {}'.format(text))
|
self._handleError('Smtplib Error sending e-mail: {}'.format(text))
|
||||||
except (socket.error) as e:
|
except (socket.error) as e:
|
||||||
log.error_or_exception(e, stacklevel=3)
|
log.error_or_exception(e, stacklevel=3)
|
||||||
self._handleError(u'Socket Error sending e-mail: {}'.format(e.strerror))
|
self._handleError('Socket Error sending e-mail: {}'.format(e.strerror))
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
log.error_or_exception(ex, stacklevel=3)
|
log.error_or_exception(ex, stacklevel=3)
|
||||||
self._handleError(u'Error sending e-mail: {}'.format(ex))
|
self._handleError('Error sending e-mail: {}'.format(ex))
|
||||||
|
|
||||||
def send_standard_email(self, msg):
|
def send_standard_email(self, msg):
|
||||||
use_ssl = int(self.settings.get('mail_use_ssl', 0))
|
use_ssl = int(self.settings.get('mail_use_ssl', 0))
|
||||||
@ -257,7 +257,7 @@ class TaskEmail(CalibreTask):
|
|||||||
file_.close()
|
file_.close()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
log.error_or_exception(e, stacklevel=3)
|
log.error_or_exception(e, stacklevel=3)
|
||||||
log.error(u'The requested file could not be read. Maybe wrong permissions?')
|
log.error('The requested file could not be read. Maybe wrong permissions?')
|
||||||
return None
|
return None
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ class TaskGenerateCoverThumbnails(CalibreTask):
|
|||||||
|
|
||||||
if generated > 0:
|
if generated > 0:
|
||||||
total_generated += generated
|
total_generated += generated
|
||||||
self.message = N_(u'Generated %(count)s cover thumbnails', count=total_generated)
|
self.message = N_('Generated %(count)s cover thumbnails', count=total_generated)
|
||||||
|
|
||||||
# Check if job has been cancelled or ended
|
# Check if job has been cancelled or ended
|
||||||
if self.stat == STAT_CANCELLED:
|
if self.stat == STAT_CANCELLED:
|
||||||
|
@ -61,19 +61,19 @@ def render_task_status(tasklist):
|
|||||||
# localize the task status
|
# localize the task status
|
||||||
if isinstance(task.stat, int):
|
if isinstance(task.stat, int):
|
||||||
if task.stat == STAT_WAITING:
|
if task.stat == STAT_WAITING:
|
||||||
ret['status'] = _(u'Waiting')
|
ret['status'] = _('Waiting')
|
||||||
elif task.stat == STAT_FAIL:
|
elif task.stat == STAT_FAIL:
|
||||||
ret['status'] = _(u'Failed')
|
ret['status'] = _('Failed')
|
||||||
elif task.stat == STAT_STARTED:
|
elif task.stat == STAT_STARTED:
|
||||||
ret['status'] = _(u'Started')
|
ret['status'] = _('Started')
|
||||||
elif task.stat == STAT_FINISH_SUCCESS:
|
elif task.stat == STAT_FINISH_SUCCESS:
|
||||||
ret['status'] = _(u'Finished')
|
ret['status'] = _('Finished')
|
||||||
elif task.stat == STAT_ENDED:
|
elif task.stat == STAT_ENDED:
|
||||||
ret['status'] = _(u'Ended')
|
ret['status'] = _('Ended')
|
||||||
elif task.stat == STAT_CANCELLED:
|
elif task.stat == STAT_CANCELLED:
|
||||||
ret['status'] = _(u'Cancelled')
|
ret['status'] = _('Cancelled')
|
||||||
else:
|
else:
|
||||||
ret['status'] = _(u'Unknown Status')
|
ret['status'] = _('Unknown Status')
|
||||||
|
|
||||||
ret['taskMessage'] = "{}: {}".format(task.name, task.message) if task.message else task.name
|
ret['taskMessage'] = "{}: {}".format(task.name, task.message) if task.message else task.name
|
||||||
ret['progress'] = "{} %".format(int(task.progress * 100))
|
ret['progress'] = "{} %".format(int(task.progress * 100))
|
||||||
|
@ -492,7 +492,7 @@ class Registration(Base):
|
|||||||
allow = Column(Integer)
|
allow = Column(Integer)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return u"<Registration('{0}')>".format(self.domain)
|
return "<Registration('{0}')>".format(self.domain)
|
||||||
|
|
||||||
|
|
||||||
class RemoteAuthToken(Base):
|
class RemoteAuthToken(Base):
|
||||||
@ -810,7 +810,7 @@ def create_admin_user(_session):
|
|||||||
|
|
||||||
def init_db_thread():
|
def init_db_thread():
|
||||||
global app_DB_path
|
global app_DB_path
|
||||||
engine = create_engine(u'sqlite:///{0}'.format(app_DB_path), echo=False)
|
engine = create_engine('sqlite:///{0}'.format(app_DB_path), echo=False)
|
||||||
|
|
||||||
Session = scoped_session(sessionmaker())
|
Session = scoped_session(sessionmaker())
|
||||||
Session.configure(bind=engine)
|
Session.configure(bind=engine)
|
||||||
@ -823,7 +823,7 @@ def init_db(app_db_path, user_credentials=None):
|
|||||||
global app_DB_path
|
global app_DB_path
|
||||||
|
|
||||||
app_DB_path = app_db_path
|
app_DB_path = app_db_path
|
||||||
engine = create_engine(u'sqlite:///{0}'.format(app_db_path), echo=False)
|
engine = create_engine('sqlite:///{0}'.format(app_db_path), echo=False)
|
||||||
|
|
||||||
Session = scoped_session(sessionmaker())
|
Session = scoped_session(sessionmaker())
|
||||||
Session.configure(bind=engine)
|
Session.configure(bind=engine)
|
||||||
@ -858,7 +858,7 @@ def init_db(app_db_path, user_credentials=None):
|
|||||||
|
|
||||||
|
|
||||||
def get_new_session_instance():
|
def get_new_session_instance():
|
||||||
new_engine = create_engine(u'sqlite:///{0}'.format(app_DB_path), echo=False)
|
new_engine = create_engine('sqlite:///{0}'.format(app_DB_path), echo=False)
|
||||||
new_session = scoped_session(sessionmaker())
|
new_session = scoped_session(sessionmaker())
|
||||||
new_session.configure(bind=new_engine)
|
new_session.configure(bind=new_engine)
|
||||||
|
|
||||||
|
@ -75,29 +75,29 @@ class Updater(threading.Thread):
|
|||||||
def do_work(self):
|
def do_work(self):
|
||||||
try:
|
try:
|
||||||
self.status = 1
|
self.status = 1
|
||||||
log.debug(u'Download update file')
|
log.debug('Download update file')
|
||||||
headers = {'Accept': 'application/vnd.github.v3+json'}
|
headers = {'Accept': 'application/vnd.github.v3+json'}
|
||||||
r = requests.get(self._get_request_path(), stream=True, headers=headers, timeout=(10, 600))
|
r = requests.get(self._get_request_path(), stream=True, headers=headers, timeout=(10, 600))
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
|
|
||||||
self.status = 2
|
self.status = 2
|
||||||
log.debug(u'Opening zipfile')
|
log.debug('Opening zipfile')
|
||||||
z = zipfile.ZipFile(BytesIO(r.content))
|
z = zipfile.ZipFile(BytesIO(r.content))
|
||||||
self.status = 3
|
self.status = 3
|
||||||
log.debug(u'Extracting zipfile')
|
log.debug('Extracting zipfile')
|
||||||
tmp_dir = gettempdir()
|
tmp_dir = gettempdir()
|
||||||
z.extractall(tmp_dir)
|
z.extractall(tmp_dir)
|
||||||
folder_name = os.path.join(tmp_dir, z.namelist()[0])[:-1]
|
folder_name = os.path.join(tmp_dir, z.namelist()[0])[:-1]
|
||||||
if not os.path.isdir(folder_name):
|
if not os.path.isdir(folder_name):
|
||||||
self.status = 11
|
self.status = 11
|
||||||
log.info(u'Extracted contents of zipfile not found in temp folder')
|
log.info('Extracted contents of zipfile not found in temp folder')
|
||||||
self.pause()
|
self.pause()
|
||||||
return False
|
return False
|
||||||
self.status = 4
|
self.status = 4
|
||||||
log.debug(u'Replacing files')
|
log.debug('Replacing files')
|
||||||
if self.update_source(folder_name, constants.BASE_DIR):
|
if self.update_source(folder_name, constants.BASE_DIR):
|
||||||
self.status = 6
|
self.status = 6
|
||||||
log.debug(u'Preparing restart of server')
|
log.debug('Preparing restart of server')
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
self.web_server.stop(True)
|
self.web_server.stop(True)
|
||||||
self.status = 7
|
self.status = 7
|
||||||
@ -107,20 +107,20 @@ class Updater(threading.Thread):
|
|||||||
self.status = 13
|
self.status = 13
|
||||||
|
|
||||||
except requests.exceptions.HTTPError as ex:
|
except requests.exceptions.HTTPError as ex:
|
||||||
log.error(u'HTTP Error %s', ex)
|
log.error('HTTP Error %s', ex)
|
||||||
self.status = 8
|
self.status = 8
|
||||||
except requests.exceptions.ConnectionError:
|
except requests.exceptions.ConnectionError:
|
||||||
log.error(u'Connection error')
|
log.error('Connection error')
|
||||||
self.status = 9
|
self.status = 9
|
||||||
except requests.exceptions.Timeout:
|
except requests.exceptions.Timeout:
|
||||||
log.error(u'Timeout while establishing connection')
|
log.error('Timeout while establishing connection')
|
||||||
self.status = 10
|
self.status = 10
|
||||||
except (requests.exceptions.RequestException, zipfile.BadZipFile):
|
except (requests.exceptions.RequestException, zipfile.BadZipFile):
|
||||||
self.status = 11
|
self.status = 11
|
||||||
log.error(u'General error')
|
log.error('General error')
|
||||||
except (IOError, OSError) as ex:
|
except (IOError, OSError) as ex:
|
||||||
self.status = 12
|
self.status = 12
|
||||||
log.error(u'Possible Reason for error: update file could not be saved in temp dir')
|
log.error('Possible Reason for error: update file could not be saved in temp dir')
|
||||||
log.error_or_exception(ex)
|
log.error_or_exception(ex)
|
||||||
self.pause()
|
self.pause()
|
||||||
return False
|
return False
|
||||||
@ -386,13 +386,13 @@ class Updater(threading.Thread):
|
|||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
update_data = r.json()
|
update_data = r.json()
|
||||||
except requests.exceptions.HTTPError as e:
|
except requests.exceptions.HTTPError as e:
|
||||||
status['message'] = _(u'HTTP Error') + ' ' + str(e)
|
status['message'] = _('HTTP Error') + ' ' + str(e)
|
||||||
except requests.exceptions.ConnectionError:
|
except requests.exceptions.ConnectionError:
|
||||||
status['message'] = _(u'Connection error')
|
status['message'] = _('Connection error')
|
||||||
except requests.exceptions.Timeout:
|
except requests.exceptions.Timeout:
|
||||||
status['message'] = _(u'Timeout while establishing connection')
|
status['message'] = _('Timeout while establishing connection')
|
||||||
except (requests.exceptions.RequestException, ValueError):
|
except (requests.exceptions.RequestException, ValueError):
|
||||||
status['message'] = _(u'General error')
|
status['message'] = _('General error')
|
||||||
return status, update_data
|
return status, update_data
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -428,18 +428,18 @@ class Updater(threading.Thread):
|
|||||||
if status['message'] != '':
|
if status['message'] != '':
|
||||||
return json.dumps(status)
|
return json.dumps(status)
|
||||||
if 'object' not in commit or 'url' not in commit['object']:
|
if 'object' not in commit or 'url' not in commit['object']:
|
||||||
status['message'] = _(u'Unexpected data while reading update information')
|
status['message'] = _('Unexpected data while reading update information')
|
||||||
return json.dumps(status)
|
return json.dumps(status)
|
||||||
try:
|
try:
|
||||||
if commit['object']['sha'] == status['current_commit_hash']:
|
if commit['object']['sha'] == status['current_commit_hash']:
|
||||||
status.update({
|
status.update({
|
||||||
'update': False,
|
'update': False,
|
||||||
'success': True,
|
'success': True,
|
||||||
'message': _(u'No update available. You already have the latest version installed')
|
'message': _('No update available. You already have the latest version installed')
|
||||||
})
|
})
|
||||||
return json.dumps(status)
|
return json.dumps(status)
|
||||||
except (TypeError, KeyError):
|
except (TypeError, KeyError):
|
||||||
status['message'] = _(u'Unexpected data while reading update information')
|
status['message'] = _('Unexpected data while reading update information')
|
||||||
return json.dumps(status)
|
return json.dumps(status)
|
||||||
|
|
||||||
# a new update is available
|
# a new update is available
|
||||||
@ -454,7 +454,7 @@ class Updater(threading.Thread):
|
|||||||
log.debug("A new update is available.")
|
log.debug("A new update is available.")
|
||||||
status['success'] = True
|
status['success'] = True
|
||||||
status['message'] = _(
|
status['message'] = _(
|
||||||
u'A new update is available. Click on the button below to update to the latest version.')
|
'A new update is available. Click on the button below to update to the latest version.')
|
||||||
|
|
||||||
new_commit_date = datetime.datetime.strptime(
|
new_commit_date = datetime.datetime.strptime(
|
||||||
update_data['committer']['date'], '%Y-%m-%dT%H:%M:%SZ') - tz
|
update_data['committer']['date'], '%Y-%m-%dT%H:%M:%SZ') - tz
|
||||||
@ -471,7 +471,7 @@ class Updater(threading.Thread):
|
|||||||
status['history'] = parents[::-1]
|
status['history'] = parents[::-1]
|
||||||
except (IndexError, KeyError):
|
except (IndexError, KeyError):
|
||||||
status['success'] = False
|
status['success'] = False
|
||||||
status['message'] = _(u'Could not fetch update information')
|
status['message'] = _('Could not fetch update information')
|
||||||
log.error("Could not fetch update information")
|
log.error("Could not fetch update information")
|
||||||
return json.dumps(status)
|
return json.dumps(status)
|
||||||
return ''
|
return ''
|
||||||
@ -482,7 +482,7 @@ class Updater(threading.Thread):
|
|||||||
'update': True,
|
'update': True,
|
||||||
'success': True,
|
'success': True,
|
||||||
'message': _(
|
'message': _(
|
||||||
u'Click on the button below to update to the latest stable version.'),
|
'Click on the button below to update to the latest stable version.'),
|
||||||
'history': parents
|
'history': parents
|
||||||
})
|
})
|
||||||
self.updateFile = commit[0]['zipball_url']
|
self.updateFile = commit[0]['zipball_url']
|
||||||
@ -490,8 +490,8 @@ class Updater(threading.Thread):
|
|||||||
status.update({
|
status.update({
|
||||||
'update': True,
|
'update': True,
|
||||||
'success': True,
|
'success': True,
|
||||||
'message': _(u'A new update is available. Click on the button below to '
|
'message': _('A new update is available. Click on the button below to '
|
||||||
u'update to version: %(version)s', version=commit[0]['tag_name']),
|
'update to version: %(version)s', version=commit[0]['tag_name']),
|
||||||
'history': parents
|
'history': parents
|
||||||
})
|
})
|
||||||
self.updateFile = commit[0]['zipball_url']
|
self.updateFile = commit[0]['zipball_url']
|
||||||
|
@ -83,7 +83,7 @@ def process(tmp_file_path, original_file_name, original_file_extension, rarExecu
|
|||||||
|
|
||||||
if meta and meta.title.strip() and meta.author.strip():
|
if meta and meta.title.strip() and meta.author.strip():
|
||||||
if meta.author.lower() == 'unknown':
|
if meta.author.lower() == 'unknown':
|
||||||
meta = meta._replace(author=_(u'Unknown'))
|
meta = meta._replace(author=_('Unknown'))
|
||||||
return meta
|
return meta
|
||||||
return default_meta(tmp_file_path, original_file_name, original_file_extension)
|
return default_meta(tmp_file_path, original_file_name, original_file_extension)
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ def default_meta(tmp_file_path, original_file_name, original_file_extension):
|
|||||||
file_path=tmp_file_path,
|
file_path=tmp_file_path,
|
||||||
extension=original_file_extension,
|
extension=original_file_extension,
|
||||||
title=original_file_name,
|
title=original_file_name,
|
||||||
author=_(u'Unknown'),
|
author=_('Unknown'),
|
||||||
cover=None,
|
cover=None,
|
||||||
description="",
|
description="",
|
||||||
tags="",
|
tags="",
|
||||||
@ -173,7 +173,7 @@ def pdf_meta(tmp_file_path, original_file_name, original_file_extension):
|
|||||||
languages = xmp_info['languages']
|
languages = xmp_info['languages']
|
||||||
publisher = xmp_info['publisher']
|
publisher = xmp_info['publisher']
|
||||||
else:
|
else:
|
||||||
author = u'Unknown'
|
author = 'Unknown'
|
||||||
title = ''
|
title = ''
|
||||||
languages = [""]
|
languages = [""]
|
||||||
publisher = ""
|
publisher = ""
|
||||||
@ -182,7 +182,7 @@ def pdf_meta(tmp_file_path, original_file_name, original_file_extension):
|
|||||||
|
|
||||||
if doc_info:
|
if doc_info:
|
||||||
if author == '':
|
if author == '':
|
||||||
author = ' & '.join(split_authors([doc_info.author])) if doc_info.author else u'Unknown'
|
author = ' & '.join(split_authors([doc_info.author])) if doc_info.author else 'Unknown'
|
||||||
if title == '':
|
if title == '':
|
||||||
title = doc_info.title if doc_info.title else original_file_name
|
title = doc_info.title if doc_info.title else original_file_name
|
||||||
if subject == '':
|
if subject == '':
|
||||||
@ -239,7 +239,7 @@ def get_magick_version():
|
|||||||
if not use_generic_pdf_cover:
|
if not use_generic_pdf_cover:
|
||||||
ret['Image Magick'] = ImageVersion.MAGICK_VERSION
|
ret['Image Magick'] = ImageVersion.MAGICK_VERSION
|
||||||
else:
|
else:
|
||||||
ret['Image Magick'] = u'not installed'
|
ret['Image Magick'] = 'not installed'
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
10
cps/web.py
10
cps/web.py
@ -739,10 +739,10 @@ def render_read_books(page, are_read, as_xml=False, order=None):
|
|||||||
return entries, pagination
|
return entries, pagination
|
||||||
else:
|
else:
|
||||||
if are_read:
|
if are_read:
|
||||||
name = _(u'Read Books') + ' (' + str(pagination.total_count) + ')'
|
name = _('Read Books') + ' (' + str(pagination.total_count) + ')'
|
||||||
page_name = "read"
|
page_name = "read"
|
||||||
else:
|
else:
|
||||||
name = _(u'Unread Books') + ' (' + str(pagination.total_count) + ')'
|
name = _('Unread Books') + ' (' + str(pagination.total_count) + ')'
|
||||||
page_name = "unread"
|
page_name = "unread"
|
||||||
return render_title_template('index.html', random=random, entries=entries, pagination=pagination,
|
return render_title_template('index.html', random=random, entries=entries, pagination=pagination,
|
||||||
title=name, page=page_name, order=order[1])
|
title=name, page=page_name, order=order[1])
|
||||||
@ -765,7 +765,7 @@ def render_archived_books(page, sort_param):
|
|||||||
True,
|
True,
|
||||||
True, config.config_read_column)
|
True, config.config_read_column)
|
||||||
|
|
||||||
name = _(u'Archived Books') + ' (' + str(len(archived_book_ids)) + ')'
|
name = _('Archived Books') + ' (' + str(len(archived_book_ids)) + ')'
|
||||||
page_name = "archived"
|
page_name = "archived"
|
||||||
return render_title_template('index.html', random=random, entries=entries, pagination=pagination,
|
return render_title_template('index.html', random=random, entries=entries, pagination=pagination,
|
||||||
title=name, page=page_name, order=sort_param[1])
|
title=name, page=page_name, order=sort_param[1])
|
||||||
@ -917,7 +917,7 @@ def author_list():
|
|||||||
for entry in author_copy:
|
for entry in author_copy:
|
||||||
entry.Authors.name = entry.Authors.name.replace('|', ',')
|
entry.Authors.name = entry.Authors.name.replace('|', ',')
|
||||||
return render_title_template('list.html', entries=author_copy, folder='web.books_list', charlist=char_list,
|
return render_title_template('list.html', entries=author_copy, folder='web.books_list', charlist=char_list,
|
||||||
title=u"Authors", page="authorlist", data='author', order=order_no)
|
title="Authors", page="authorlist", data='author', order=order_no)
|
||||||
else:
|
else:
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
@ -1066,7 +1066,7 @@ def formats_list():
|
|||||||
@web.route("/language")
|
@web.route("/language")
|
||||||
@login_required_if_no_ano
|
@login_required_if_no_ano
|
||||||
def language_overview():
|
def language_overview():
|
||||||
if current_user.check_visibility(constants.SIDEBAR_LANGUAGE) and current_user.filter_language() == u"all":
|
if current_user.check_visibility(constants.SIDEBAR_LANGUAGE) and current_user.filter_language() == "all":
|
||||||
order_no = 0 if current_user.get_view_property('language', 'dir') == 'desc' else 1
|
order_no = 0 if current_user.get_view_property('language', 'dir') == 'desc' else 1
|
||||||
languages = calibre_db.speaking_language(reverse_order=not order_no, with_count=True)
|
languages = calibre_db.speaking_language(reverse_order=not order_no, with_count=True)
|
||||||
char_list = generate_char_list(languages)
|
char_list = generate_char_list(languages)
|
||||||
|
Loading…
Reference in New Issue
Block a user