Database error is more detailed
renamed debug_or_exception to error_or_exception
This commit is contained in:
parent
2b31b6a306
commit
4379669cf8
34
cps/admin.py
34
cps/admin.py
|
@ -1216,10 +1216,10 @@ def _db_configuration_update_helper():
|
||||||
|
|
||||||
# gdrive_error drive setup
|
# gdrive_error drive setup
|
||||||
gdrive_error = _configuration_gdrive_helper(to_save)
|
gdrive_error = _configuration_gdrive_helper(to_save)
|
||||||
except (OperationalError, InvalidRequestError):
|
except (OperationalError, InvalidRequestError) as e:
|
||||||
ub.session.rollback()
|
ub.session.rollback()
|
||||||
log.error("Settings DB is not Writeable")
|
log.error_or_exception("Settings Database error: {}".format(e))
|
||||||
_db_configuration_result(_("Settings DB is not Writeable"), gdrive_error)
|
_db_configuration_result(_(u"Database error: %(error)s.", error=e.orig), gdrive_error)
|
||||||
try:
|
try:
|
||||||
metadata_db = os.path.join(to_save['config_calibre_dir'], "metadata.db")
|
metadata_db = os.path.join(to_save['config_calibre_dir'], "metadata.db")
|
||||||
if config.config_use_google_drive and is_gdrive_ready() and not os.path.exists(metadata_db):
|
if config.config_use_google_drive and is_gdrive_ready() and not os.path.exists(metadata_db):
|
||||||
|
@ -1332,10 +1332,10 @@ def _configuration_update_helper():
|
||||||
unrar_status = helper.check_unrar(config.config_rarfile_location)
|
unrar_status = helper.check_unrar(config.config_rarfile_location)
|
||||||
if unrar_status:
|
if unrar_status:
|
||||||
return _configuration_result(unrar_status)
|
return _configuration_result(unrar_status)
|
||||||
except (OperationalError, InvalidRequestError):
|
except (OperationalError, InvalidRequestError) as e:
|
||||||
ub.session.rollback()
|
ub.session.rollback()
|
||||||
log.error("Settings DB is not Writeable")
|
log.error_or_exception("Settings Database error: {}".format(e))
|
||||||
_configuration_result(_("Settings DB is not Writeable"))
|
_configuration_result(_(u"Database error: %(error)s.", error=e.orig))
|
||||||
|
|
||||||
config.save()
|
config.save()
|
||||||
if reboot_required:
|
if reboot_required:
|
||||||
|
@ -1430,10 +1430,10 @@ def _handle_new_user(to_save, content, languages, translations, kobo_support):
|
||||||
ub.session.rollback()
|
ub.session.rollback()
|
||||||
log.error("Found an existing account for {} or {}".format(content.name, content.email))
|
log.error("Found an existing account for {} or {}".format(content.name, content.email))
|
||||||
flash(_("Found an existing account for this e-mail address or name."), category="error")
|
flash(_("Found an existing account for this e-mail address or name."), category="error")
|
||||||
except OperationalError:
|
except OperationalError as e:
|
||||||
ub.session.rollback()
|
ub.session.rollback()
|
||||||
log.error("Settings DB is not Writeable")
|
log.error_or_exception("Settings Database error: {}".format(e))
|
||||||
flash(_("Settings DB is not Writeable"), category="error")
|
flash(_(u"Database error: %(error)s.", error=e.orig), category="error")
|
||||||
|
|
||||||
|
|
||||||
def _delete_user(content):
|
def _delete_user(content):
|
||||||
|
@ -1547,10 +1547,10 @@ def _handle_edit_user(to_save, content, languages, translations, kobo_support):
|
||||||
ub.session.rollback()
|
ub.session.rollback()
|
||||||
log.error("An unknown error occurred while changing user: {}".format(str(ex)))
|
log.error("An unknown error occurred while changing user: {}".format(str(ex)))
|
||||||
flash(_(u"An unknown error occurred. Please try again later."), category="error")
|
flash(_(u"An unknown error occurred. Please try again later."), category="error")
|
||||||
except OperationalError:
|
except OperationalError as e:
|
||||||
ub.session.rollback()
|
ub.session.rollback()
|
||||||
log.error("Settings DB is not Writeable")
|
log.error_or_exception("Settings Database error: {}".format(e))
|
||||||
flash(_("Settings DB is not Writeable"), category="error")
|
flash(_(u"Database error: %(error)s.", error=e.orig), category="error")
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
|
@ -1616,10 +1616,10 @@ def update_mailsettings():
|
||||||
_config_int(to_save, "mail_size", lambda y: int(y)*1024*1024)
|
_config_int(to_save, "mail_size", lambda y: int(y)*1024*1024)
|
||||||
try:
|
try:
|
||||||
config.save()
|
config.save()
|
||||||
except (OperationalError, InvalidRequestError):
|
except (OperationalError, InvalidRequestError) as e:
|
||||||
ub.session.rollback()
|
ub.session.rollback()
|
||||||
log.error("Settings DB is not Writeable")
|
log.error_or_exception("Settings Database error: {}".format(e))
|
||||||
flash(_("Settings DB is not Writeable"), category="error")
|
flash(_(u"Database error: %(error)s.", error=e.orig), category="error")
|
||||||
return edit_mailsettings()
|
return edit_mailsettings()
|
||||||
|
|
||||||
if to_save.get("test"):
|
if to_save.get("test"):
|
||||||
|
@ -1851,7 +1851,7 @@ def import_ldap_users():
|
||||||
try:
|
try:
|
||||||
new_users = services.ldap.get_group_members(config.config_ldap_group_name)
|
new_users = services.ldap.get_group_members(config.config_ldap_group_name)
|
||||||
except (services.ldap.LDAPException, TypeError, AttributeError, KeyError) as e:
|
except (services.ldap.LDAPException, TypeError, AttributeError, KeyError) as e:
|
||||||
log.debug_or_exception(e)
|
log.error_or_exception(e)
|
||||||
showtext['text'] = _(u'Error: %(ldaperror)s', ldaperror=e)
|
showtext['text'] = _(u'Error: %(ldaperror)s', ldaperror=e)
|
||||||
return json.dumps(showtext)
|
return json.dumps(showtext)
|
||||||
if not new_users:
|
if not new_users:
|
||||||
|
@ -1879,7 +1879,7 @@ def import_ldap_users():
|
||||||
try:
|
try:
|
||||||
user_data = services.ldap.get_object_details(user=user_identifier, query_filter=query_filter)
|
user_data = services.ldap.get_object_details(user=user_identifier, query_filter=query_filter)
|
||||||
except AttributeError as ex:
|
except AttributeError as ex:
|
||||||
log.debug_or_exception(ex)
|
log.error_or_exception(ex)
|
||||||
continue
|
continue
|
||||||
if user_data:
|
if user_data:
|
||||||
user_count, message = ldap_import_create_user(user, user_data)
|
user_count, message = ldap_import_create_user(user, user_data)
|
||||||
|
|
|
@ -597,7 +597,7 @@ class CalibreDB():
|
||||||
cc = conn.execute(text("SELECT id, datatype FROM custom_columns"))
|
cc = conn.execute(text("SELECT id, datatype FROM custom_columns"))
|
||||||
cls.setup_db_cc_classes(cc)
|
cls.setup_db_cc_classes(cc)
|
||||||
except OperationalError as e:
|
except OperationalError as e:
|
||||||
log.debug_or_exception(e)
|
log.error_or_exception(e)
|
||||||
|
|
||||||
cls.session_factory = scoped_session(sessionmaker(autocommit=False,
|
cls.session_factory = scoped_session(sessionmaker(autocommit=False,
|
||||||
autoflush=True,
|
autoflush=True,
|
||||||
|
@ -769,7 +769,7 @@ class CalibreDB():
|
||||||
len(query.all()))
|
len(query.all()))
|
||||||
entries = query.order_by(*order).offset(off).limit(pagesize).all()
|
entries = query.order_by(*order).offset(off).limit(pagesize).all()
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
log.debug_or_exception(ex)
|
log.error_or_exception(ex)
|
||||||
# display authors in right order
|
# display authors in right order
|
||||||
entries = self.order_authors(entries, True, join_archive_read)
|
entries = self.order_authors(entries, True, join_archive_read)
|
||||||
return entries, randm, pagination
|
return entries, randm, pagination
|
||||||
|
@ -792,7 +792,7 @@ class CalibreDB():
|
||||||
results = self.session.query(Authors).filter(Authors.sort == auth.lstrip().strip()).all()
|
results = self.session.query(Authors).filter(Authors.sort == auth.lstrip().strip()).all()
|
||||||
# ToDo: How to handle not found author name
|
# ToDo: How to handle not found author name
|
||||||
if not len(results):
|
if not len(results):
|
||||||
log.error("Author {} not found to display name in right order".format(auth))
|
log.error("Author {} not found to display name in right order".format(auth.strip()))
|
||||||
# error = True
|
# error = True
|
||||||
break
|
break
|
||||||
for r in results:
|
for r in results:
|
||||||
|
@ -974,5 +974,5 @@ def lcase(s):
|
||||||
return unidecode.unidecode(s.lower())
|
return unidecode.unidecode(s.lower())
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
log = logger.create()
|
log = logger.create()
|
||||||
log.debug_or_exception(ex)
|
log.error_or_exception(ex)
|
||||||
return s.lower()
|
return s.lower()
|
||||||
|
|
|
@ -337,7 +337,7 @@ def delete_book_from_table(book_id, book_format, jsonResponse):
|
||||||
kobo_sync_status.remove_synced_book(book.id, True)
|
kobo_sync_status.remove_synced_book(book.id, True)
|
||||||
calibre_db.session.commit()
|
calibre_db.session.commit()
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
log.debug_or_exception(ex)
|
log.error_or_exception(ex)
|
||||||
calibre_db.session.rollback()
|
calibre_db.session.rollback()
|
||||||
if jsonResponse:
|
if jsonResponse:
|
||||||
return json.dumps([{"location": url_for("editbook.edit_book", book_id=book_id),
|
return json.dumps([{"location": url_for("editbook.edit_book", book_id=book_id),
|
||||||
|
@ -663,8 +663,8 @@ def upload_single_file(request, book, book_id):
|
||||||
calibre_db.update_title_sort(config)
|
calibre_db.update_title_sort(config)
|
||||||
except (OperationalError, IntegrityError) as e:
|
except (OperationalError, IntegrityError) as e:
|
||||||
calibre_db.session.rollback()
|
calibre_db.session.rollback()
|
||||||
log.error('Database error: %s', e)
|
log.error_or_exception("Database error: {}".format(e))
|
||||||
flash(_(u"Database error: %(error)s.", error=e), category="error")
|
flash(_(u"Database error: %(error)s.", error=e.orig), category="error")
|
||||||
return redirect(url_for('web.show_book', book_id=book.id))
|
return redirect(url_for('web.show_book', book_id=book.id))
|
||||||
|
|
||||||
# Queue uploader info
|
# Queue uploader info
|
||||||
|
@ -756,7 +756,7 @@ def edit_book(book_id):
|
||||||
try:
|
try:
|
||||||
calibre_db.update_title_sort(config)
|
calibre_db.update_title_sort(config)
|
||||||
except sqliteOperationalError as e:
|
except sqliteOperationalError as e:
|
||||||
log.debug_or_exception(e)
|
log.error_or_exception(e)
|
||||||
calibre_db.session.rollback()
|
calibre_db.session.rollback()
|
||||||
|
|
||||||
# Show form
|
# Show form
|
||||||
|
@ -864,8 +864,13 @@ def edit_book(book_id):
|
||||||
calibre_db.session.rollback()
|
calibre_db.session.rollback()
|
||||||
flash(str(e), category="error")
|
flash(str(e), category="error")
|
||||||
return redirect(url_for('web.show_book', book_id=book.id))
|
return redirect(url_for('web.show_book', book_id=book.id))
|
||||||
|
except (OperationalError, IntegrityError) as e:
|
||||||
|
log.error_or_exception("Database error: {}".format(e))
|
||||||
|
calibre_db.session.rollback()
|
||||||
|
flash(_(u"Database error: %(error)s.", error=e.orig), category="error")
|
||||||
|
return redirect(url_for('web.show_book', book_id=book.id))
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
log.debug_or_exception(ex)
|
log.error_or_exception(ex)
|
||||||
calibre_db.session.rollback()
|
calibre_db.session.rollback()
|
||||||
flash(_("Error editing book, please check logfile for details"), category="error")
|
flash(_("Error editing book, please check logfile for details"), category="error")
|
||||||
return redirect(url_for('web.show_book', book_id=book.id))
|
return redirect(url_for('web.show_book', book_id=book.id))
|
||||||
|
@ -1103,8 +1108,8 @@ def upload():
|
||||||
return Response(json.dumps(resp), mimetype='application/json')
|
return Response(json.dumps(resp), mimetype='application/json')
|
||||||
except (OperationalError, IntegrityError) as e:
|
except (OperationalError, IntegrityError) as e:
|
||||||
calibre_db.session.rollback()
|
calibre_db.session.rollback()
|
||||||
log.error("Database error: %s", e)
|
log.error_or_exception("Database error: {}".format(e))
|
||||||
flash(_(u"Database error: %(error)s.", error=e), category="error")
|
flash(_(u"Database error: %(error)s.", error=e.orig), category="error")
|
||||||
return Response(json.dumps({"location": url_for("web.index")}), mimetype='application/json')
|
return Response(json.dumps({"location": url_for("web.index")}), mimetype='application/json')
|
||||||
|
|
||||||
|
|
||||||
|
@ -1234,7 +1239,7 @@ def edit_list_book(param):
|
||||||
calibre_db.session.commit()
|
calibre_db.session.commit()
|
||||||
except (OperationalError, IntegrityError) as e:
|
except (OperationalError, IntegrityError) as e:
|
||||||
calibre_db.session.rollback()
|
calibre_db.session.rollback()
|
||||||
log.error("Database error: {}".format(e))
|
log.error_or_exception("Database error: {}".format(e))
|
||||||
ret = Response(json.dumps({'success': False,
|
ret = Response(json.dumps({'success': False,
|
||||||
'msg': 'Database error: {}'.format(e.orig)}),
|
'msg': 'Database error: {}'.format(e.orig)}),
|
||||||
mimetype='application/json')
|
mimetype='application/json')
|
||||||
|
@ -1344,7 +1349,7 @@ def table_xchange_author_title():
|
||||||
calibre_db.session.commit()
|
calibre_db.session.commit()
|
||||||
except (OperationalError, IntegrityError) as e:
|
except (OperationalError, IntegrityError) as e:
|
||||||
calibre_db.session.rollback()
|
calibre_db.session.rollback()
|
||||||
log.error("Database error: %s", e)
|
log.error_or_exception("Database error: %s", e)
|
||||||
return json.dumps({'success': False})
|
return json.dumps({'success': False})
|
||||||
|
|
||||||
if config.config_use_google_drive:
|
if config.config_use_google_drive:
|
||||||
|
|
|
@ -152,7 +152,7 @@ try:
|
||||||
move(os.path.join(tmp_dir, "tmp_metadata.db"), dbpath)
|
move(os.path.join(tmp_dir, "tmp_metadata.db"), dbpath)
|
||||||
calibre_db.reconnect_db(config, ub.app_DB_path)
|
calibre_db.reconnect_db(config, ub.app_DB_path)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
log.debug_or_exception(ex)
|
log.error_or_exception(ex)
|
||||||
return ''
|
return ''
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -215,7 +215,7 @@ def getDrive(drive=None, gauth=None):
|
||||||
except RefreshError as e:
|
except RefreshError as e:
|
||||||
log.error("Google Drive error: %s", e)
|
log.error("Google Drive error: %s", e)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
log.debug_or_exception(ex)
|
log.error_or_exception(ex)
|
||||||
else:
|
else:
|
||||||
# Initialize the saved creds
|
# Initialize the saved creds
|
||||||
gauth.Authorize()
|
gauth.Authorize()
|
||||||
|
|
|
@ -713,7 +713,7 @@ def get_book_cover_internal(book, use_generic_cover_on_failure):
|
||||||
log.error('%s/cover.jpg not found on Google Drive', book.path)
|
log.error('%s/cover.jpg not found on Google Drive', book.path)
|
||||||
return get_cover_on_failure(use_generic_cover_on_failure)
|
return get_cover_on_failure(use_generic_cover_on_failure)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
log.debug_or_exception(ex)
|
log.error_or_exception(ex)
|
||||||
return get_cover_on_failure(use_generic_cover_on_failure)
|
return get_cover_on_failure(use_generic_cover_on_failure)
|
||||||
else:
|
else:
|
||||||
cover_file_path = os.path.join(config.config_calibre_dir, book.path)
|
cover_file_path = os.path.join(config.config_calibre_dir, book.path)
|
||||||
|
@ -861,7 +861,7 @@ def check_unrar(unrarLocation):
|
||||||
log.debug("unrar version %s", version)
|
log.debug("unrar version %s", version)
|
||||||
|
|
||||||
except (OSError, UnicodeDecodeError) as err:
|
except (OSError, UnicodeDecodeError) as err:
|
||||||
log.debug_or_exception(err)
|
log.error_or_exception(err)
|
||||||
return _('Error excecuting UnRar')
|
return _('Error excecuting UnRar')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ logging.addLevelName(logging.CRITICAL, "CRIT")
|
||||||
|
|
||||||
class _Logger(logging.Logger):
|
class _Logger(logging.Logger):
|
||||||
|
|
||||||
def debug_or_exception(self, message, stacklevel=2, *args, **kwargs):
|
def error_or_exception(self, message, stacklevel=2, *args, **kwargs):
|
||||||
if sys.version_info > (3, 7):
|
if sys.version_info > (3, 7):
|
||||||
if is_debug_enabled():
|
if is_debug_enabled():
|
||||||
self.exception(message, stacklevel=stacklevel, *args, **kwargs)
|
self.exception(message, stacklevel=stacklevel, *args, **kwargs)
|
||||||
|
|
|
@ -105,7 +105,7 @@ class Amazon(Metadata):
|
||||||
match.cover = ""
|
match.cover = ""
|
||||||
return match, index
|
return match, index
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.debug_or_exception(e)
|
log.error_or_exception(e)
|
||||||
return
|
return
|
||||||
|
|
||||||
val = list()
|
val = list()
|
||||||
|
@ -126,5 +126,5 @@ class Amazon(Metadata):
|
||||||
result = list(filter(lambda x: x, val))
|
result = list(filter(lambda x: x, val))
|
||||||
return [x[0] for x in sorted(result, key=itemgetter(1))] #sort by amazons listing order for best relevance
|
return [x[0] for x in sorted(result, key=itemgetter(1))] #sort by amazons listing order for best relevance
|
||||||
except requests.exceptions.HTTPError as e:
|
except requests.exceptions.HTTPError as e:
|
||||||
log.debug_or_exception(e)
|
log.error_or_exception(e)
|
||||||
return []
|
return []
|
||||||
|
|
|
@ -149,7 +149,7 @@ def bind_oauth_or_register(provider_id, provider_user_id, redirect_url, provider
|
||||||
log.info("Link to {} Succeeded".format(provider_name))
|
log.info("Link to {} Succeeded".format(provider_name))
|
||||||
return redirect(url_for('web.profile'))
|
return redirect(url_for('web.profile'))
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
log.debug_or_exception(ex)
|
log.error_or_exception(ex)
|
||||||
ub.session.rollback()
|
ub.session.rollback()
|
||||||
else:
|
else:
|
||||||
flash(_(u"Login failed, No User Linked With OAuth Account"), category="error")
|
flash(_(u"Login failed, No User Linked With OAuth Account"), category="error")
|
||||||
|
@ -197,7 +197,7 @@ def unlink_oauth(provider):
|
||||||
flash(_(u"Unlink to %(oauth)s Succeeded", oauth=oauth_check[provider]), category="success")
|
flash(_(u"Unlink to %(oauth)s Succeeded", oauth=oauth_check[provider]), category="success")
|
||||||
log.info("Unlink to {} Succeeded".format(oauth_check[provider]))
|
log.info("Unlink to {} Succeeded".format(oauth_check[provider]))
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
log.debug_or_exception(ex)
|
log.error_or_exception(ex)
|
||||||
ub.session.rollback()
|
ub.session.rollback()
|
||||||
flash(_(u"Unlink to %(oauth)s Failed", oauth=oauth_check[provider]), category="error")
|
flash(_(u"Unlink to %(oauth)s Failed", oauth=oauth_check[provider]), category="error")
|
||||||
except NoResultFound:
|
except NoResultFound:
|
||||||
|
|
|
@ -178,7 +178,7 @@ class CalibreTask:
|
||||||
self.run(*args)
|
self.run(*args)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
self._handleError(str(ex))
|
self._handleError(str(ex))
|
||||||
log.debug_or_exception(ex)
|
log.error_or_exception(ex)
|
||||||
|
|
||||||
self.end_time = datetime.now()
|
self.end_time = datetime.now()
|
||||||
|
|
||||||
|
|
44
cps/shelf.py
44
cps/shelf.py
|
@ -94,10 +94,10 @@ def add_to_shelf(shelf_id, book_id):
|
||||||
try:
|
try:
|
||||||
ub.session.merge(shelf)
|
ub.session.merge(shelf)
|
||||||
ub.session.commit()
|
ub.session.commit()
|
||||||
except (OperationalError, InvalidRequestError):
|
except (OperationalError, InvalidRequestError) as e:
|
||||||
ub.session.rollback()
|
ub.session.rollback()
|
||||||
log.error("Settings DB is not Writeable")
|
log.error_or_exception("Settings Database error: {}".format(e))
|
||||||
flash(_(u"Settings DB is not Writeable"), category="error")
|
flash(_(u"Database error: %(error)s.", error=e.orig), category="error")
|
||||||
if "HTTP_REFERER" in request.environ:
|
if "HTTP_REFERER" in request.environ:
|
||||||
return redirect(request.environ["HTTP_REFERER"])
|
return redirect(request.environ["HTTP_REFERER"])
|
||||||
else:
|
else:
|
||||||
|
@ -154,10 +154,10 @@ def search_to_shelf(shelf_id):
|
||||||
ub.session.merge(shelf)
|
ub.session.merge(shelf)
|
||||||
ub.session.commit()
|
ub.session.commit()
|
||||||
flash(_(u"Books have been added to shelf: %(sname)s", sname=shelf.name), category="success")
|
flash(_(u"Books have been added to shelf: %(sname)s", sname=shelf.name), category="success")
|
||||||
except (OperationalError, InvalidRequestError):
|
except (OperationalError, InvalidRequestError) as e:
|
||||||
ub.session.rollback()
|
ub.session.rollback()
|
||||||
log.error("Settings DB is not Writeable")
|
log.error_or_exception("Settings Database error: {}".format(e))
|
||||||
flash(_("Settings DB is not Writeable"), category="error")
|
flash(_(u"Database error: %(error)s.", error=e.orig), category="error")
|
||||||
else:
|
else:
|
||||||
log.error("Could not add books to shelf: {}".format(shelf.name))
|
log.error("Could not add books to shelf: {}".format(shelf.name))
|
||||||
flash(_(u"Could not add books to shelf: %(sname)s", sname=shelf.name), category="error")
|
flash(_(u"Could not add books to shelf: %(sname)s", sname=shelf.name), category="error")
|
||||||
|
@ -197,10 +197,10 @@ def remove_from_shelf(shelf_id, book_id):
|
||||||
ub.session.delete(book_shelf)
|
ub.session.delete(book_shelf)
|
||||||
shelf.last_modified = datetime.utcnow()
|
shelf.last_modified = datetime.utcnow()
|
||||||
ub.session.commit()
|
ub.session.commit()
|
||||||
except (OperationalError, InvalidRequestError):
|
except (OperationalError, InvalidRequestError) as e:
|
||||||
ub.session.rollback()
|
ub.session.rollback()
|
||||||
log.error("Settings DB is not Writeable")
|
log.error_or_exception("Settings Database error: {}".format(e))
|
||||||
flash(_("Settings DB is not Writeable"), category="error")
|
flash(_(u"Database error: %(error)s.", error=e.orig), category="error")
|
||||||
if "HTTP_REFERER" in request.environ:
|
if "HTTP_REFERER" in request.environ:
|
||||||
return redirect(request.environ["HTTP_REFERER"])
|
return redirect(request.environ["HTTP_REFERER"])
|
||||||
else:
|
else:
|
||||||
|
@ -273,12 +273,12 @@ def create_edit_shelf(shelf, page_title, page, shelf_id=False):
|
||||||
return redirect(url_for('shelf.show_shelf', shelf_id=shelf.id))
|
return redirect(url_for('shelf.show_shelf', shelf_id=shelf.id))
|
||||||
except (OperationalError, InvalidRequestError) as ex:
|
except (OperationalError, InvalidRequestError) as ex:
|
||||||
ub.session.rollback()
|
ub.session.rollback()
|
||||||
log.debug_or_exception(ex)
|
log.error_or_exception(ex)
|
||||||
log.error("Settings DB is not Writeable")
|
log.error_or_exception("Settings Database error: {}".format(ex))
|
||||||
flash(_("Settings DB is not Writeable"), category="error")
|
flash(_(u"Database error: %(error)s.", error=ex.orig), category="error")
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
ub.session.rollback()
|
ub.session.rollback()
|
||||||
log.debug_or_exception(ex)
|
log.error_or_exception(ex)
|
||||||
flash(_(u"There was an error"), category="error")
|
flash(_(u"There was an error"), category="error")
|
||||||
return render_title_template('shelf_edit.html',
|
return render_title_template('shelf_edit.html',
|
||||||
shelf=shelf,
|
shelf=shelf,
|
||||||
|
@ -337,10 +337,10 @@ def delete_shelf(shelf_id):
|
||||||
flash(_("Error deleting Shelf"), category="error")
|
flash(_("Error deleting Shelf"), category="error")
|
||||||
else:
|
else:
|
||||||
flash(_("Shelf successfully deleted"), category="success")
|
flash(_("Shelf successfully deleted"), category="success")
|
||||||
except InvalidRequestError:
|
except InvalidRequestError as e:
|
||||||
ub.session.rollback()
|
ub.session.rollback()
|
||||||
log.error("Settings DB is not Writeable")
|
log.error_or_exception("Settings Database error: {}".format(e))
|
||||||
flash(_("Settings DB is not Writeable"), category="error")
|
flash(_(u"Database error: %(error)s.", error=e.orig), category="error")
|
||||||
return redirect(url_for('web.index'))
|
return redirect(url_for('web.index'))
|
||||||
|
|
||||||
|
|
||||||
|
@ -374,10 +374,10 @@ def order_shelf(shelf_id):
|
||||||
# if order diffrent from before -> shelf.last_modified = datetime.utcnow()
|
# if order diffrent from before -> shelf.last_modified = datetime.utcnow()
|
||||||
try:
|
try:
|
||||||
ub.session.commit()
|
ub.session.commit()
|
||||||
except (OperationalError, InvalidRequestError):
|
except (OperationalError, InvalidRequestError) as e:
|
||||||
ub.session.rollback()
|
ub.session.rollback()
|
||||||
log.error("Settings DB is not Writeable")
|
log.error_or_exception("Settings Database error: {}".format(e))
|
||||||
flash(_("Settings DB is not Writeable"), category="error")
|
flash(_(u"Database error: %(error)s.", error=e.orig), category="error")
|
||||||
|
|
||||||
result = list()
|
result = list()
|
||||||
if shelf:
|
if shelf:
|
||||||
|
@ -450,10 +450,10 @@ def render_show_shelf(shelf_type, shelf_id, page_no, sort_param):
|
||||||
try:
|
try:
|
||||||
ub.session.query(ub.BookShelf).filter(ub.BookShelf.book_id == entry.book_id).delete()
|
ub.session.query(ub.BookShelf).filter(ub.BookShelf.book_id == entry.book_id).delete()
|
||||||
ub.session.commit()
|
ub.session.commit()
|
||||||
except (OperationalError, InvalidRequestError):
|
except (OperationalError, InvalidRequestError) as e:
|
||||||
ub.session.rollback()
|
ub.session.rollback()
|
||||||
log.error("Settings DB is not Writeable")
|
log.error_or_exception("Settings Database error: {}".format(e))
|
||||||
flash(_("Settings DB is not Writeable"), category="error")
|
flash(_(u"Database error: %(error)s.", error=e.orig), category="error")
|
||||||
|
|
||||||
return render_title_template(page,
|
return render_title_template(page,
|
||||||
entries=result,
|
entries=result,
|
||||||
|
|
|
@ -167,10 +167,10 @@ class TaskEmail(CalibreTask):
|
||||||
else:
|
else:
|
||||||
self.send_gmail_email(msg)
|
self.send_gmail_email(msg)
|
||||||
except MemoryError as e:
|
except MemoryError as e:
|
||||||
log.debug_or_exception(e, stacklevel=3)
|
log.error_or_exception(e, stacklevel=3)
|
||||||
self._handleError(u'MemoryError sending e-mail: {}'.format(str(e)))
|
self._handleError(u'MemoryError sending e-mail: {}'.format(str(e)))
|
||||||
except (smtplib.SMTPException, smtplib.SMTPAuthenticationError) as e:
|
except (smtplib.SMTPException, smtplib.SMTPAuthenticationError) as e:
|
||||||
log.debug_or_exception(e, stacklevel=3)
|
log.error_or_exception(e, stacklevel=3)
|
||||||
if hasattr(e, "smtp_error"):
|
if hasattr(e, "smtp_error"):
|
||||||
text = e.smtp_error.decode('utf-8').replace("\n", '. ')
|
text = e.smtp_error.decode('utf-8').replace("\n", '. ')
|
||||||
elif hasattr(e, "message"):
|
elif hasattr(e, "message"):
|
||||||
|
@ -181,10 +181,10 @@ class TaskEmail(CalibreTask):
|
||||||
text = ''
|
text = ''
|
||||||
self._handleError(u'Smtplib Error sending e-mail: {}'.format(text))
|
self._handleError(u'Smtplib Error sending e-mail: {}'.format(text))
|
||||||
except (socket.error) as e:
|
except (socket.error) as e:
|
||||||
log.debug_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(u'Socket Error sending e-mail: {}'.format(e.strerror))
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
log.debug_or_exception(ex, stacklevel=3)
|
log.error_or_exception(ex, stacklevel=3)
|
||||||
self._handleError(u'Error sending e-mail: {}'.format(ex))
|
self._handleError(u'Error sending e-mail: {}'.format(ex))
|
||||||
|
|
||||||
def send_standard_email(self, msg):
|
def send_standard_email(self, msg):
|
||||||
|
@ -257,7 +257,7 @@ class TaskEmail(CalibreTask):
|
||||||
data = file_.read()
|
data = file_.read()
|
||||||
file_.close()
|
file_.close()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
log.debug_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(u'The requested file could not be read. Maybe wrong permissions?')
|
||||||
return None
|
return None
|
||||||
return data
|
return data
|
||||||
|
|
|
@ -853,5 +853,5 @@ def session_commit(success=None, _session=None):
|
||||||
log.info(success)
|
log.info(success)
|
||||||
except (exc.OperationalError, exc.InvalidRequestError) as e:
|
except (exc.OperationalError, exc.InvalidRequestError) as e:
|
||||||
s.rollback()
|
s.rollback()
|
||||||
log.debug_or_exception(e)
|
log.error_or_exception(e)
|
||||||
return ""
|
return ""
|
||||||
|
|
|
@ -117,7 +117,7 @@ class Updater(threading.Thread):
|
||||||
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(u'Possible Reason for error: update file could not be saved in temp dir')
|
||||||
log.debug_or_exception(ex)
|
log.error_or_exception(ex)
|
||||||
self.pause()
|
self.pause()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -1375,7 +1375,7 @@ def render_adv_search_results(term, offset=None, order=None, limit=None):
|
||||||
try:
|
try:
|
||||||
q = adv_search_custom_columns(cc, term, q)
|
q = adv_search_custom_columns(cc, term, q)
|
||||||
except AttributeError as ex:
|
except AttributeError as ex:
|
||||||
log.debug_or_exception(ex)
|
log.error_or_exception(ex)
|
||||||
flash(_("Error on search for custom columns, please restart Calibre-Web"), category="error")
|
flash(_("Error on search for custom columns, please restart Calibre-Web"), category="error")
|
||||||
|
|
||||||
q = q.order_by(*sort_param).all()
|
q = q.order_by(*sort_param).all()
|
||||||
|
@ -1437,7 +1437,7 @@ def serve_book(book_id, book_format, anyname):
|
||||||
df = getFileFromEbooksFolder(book.path, data.name + "." + book_format)
|
df = getFileFromEbooksFolder(book.path, data.name + "." + book_format)
|
||||||
return do_gdrive_download(df, headers, (book_format.upper() == 'TXT'))
|
return do_gdrive_download(df, headers, (book_format.upper() == 'TXT'))
|
||||||
except AttributeError as ex:
|
except AttributeError as ex:
|
||||||
log.debug_or_exception(ex)
|
log.error_or_exception(ex)
|
||||||
return "File Not Found"
|
return "File Not Found"
|
||||||
else:
|
else:
|
||||||
if book_format.upper() == 'TXT':
|
if book_format.upper() == 'TXT':
|
||||||
|
|
Loading…
Reference in New Issue
Block a user