mirror of
https://github.com/janeczku/calibre-web
synced 2025-01-26 17:06:55 +00:00
Added environment variables for reconnect
This commit is contained in:
parent
57cd8160a0
commit
034ab73ccc
@ -159,7 +159,7 @@ def shutdown():
|
|||||||
# needed for docker applications, as changes on metadata.db from host are not visible to application
|
# needed for docker applications, as changes on metadata.db from host are not visible to application
|
||||||
@admi.route("/reconnect", methods=['GET'])
|
@admi.route("/reconnect", methods=['GET'])
|
||||||
def reconnect():
|
def reconnect():
|
||||||
if cli.args.r:
|
if cli.reconnect_enable:
|
||||||
calibre_db.reconnect_db(config, ub.app_DB_path)
|
calibre_db.reconnect_db(config, ub.app_DB_path)
|
||||||
return json.dumps({})
|
return json.dumps({})
|
||||||
else:
|
else:
|
||||||
|
@ -84,10 +84,14 @@ if args.k == "":
|
|||||||
|
|
||||||
# dry run updater
|
# dry run updater
|
||||||
dry_run = args.d or None
|
dry_run = args.d or None
|
||||||
|
# enable reconnect endpoint for docker database reconnect
|
||||||
|
reconnect_enable = args.r or os.environ.get("CALIBRE_RECONNECT", None)
|
||||||
# load covers from localhost
|
# load covers from localhost
|
||||||
allow_localhost = args.l or None
|
allow_localhost = args.l or os.environ.get("CALIBRE_LOCALHOST", None)
|
||||||
# handle and check ip address argument
|
# handle and check ip address argument
|
||||||
ip_address = args.i or None
|
ip_address = args.i or None
|
||||||
|
|
||||||
|
|
||||||
if ip_address:
|
if ip_address:
|
||||||
try:
|
try:
|
||||||
# try to parse the given ip address with socket
|
# try to parse the given ip address with socket
|
||||||
|
@ -81,7 +81,7 @@ if gdrive_support:
|
|||||||
if not logger.is_debug_enabled():
|
if not logger.is_debug_enabled():
|
||||||
logger.get('googleapiclient.discovery').setLevel(logger.logging.ERROR)
|
logger.get('googleapiclient.discovery').setLevel(logger.logging.ERROR)
|
||||||
else:
|
else:
|
||||||
log.debug("Cannot import pydrive,httplib2, using gdrive will not work: %s", importError)
|
log.debug("Cannot import pydrive, httplib2, using gdrive will not work: %s", importError)
|
||||||
|
|
||||||
|
|
||||||
class Singleton:
|
class Singleton:
|
||||||
@ -272,8 +272,7 @@ def getEbooksFolderId(drive=None):
|
|||||||
try:
|
try:
|
||||||
session.commit()
|
session.commit()
|
||||||
except OperationalError as ex:
|
except OperationalError as ex:
|
||||||
log.error("gdrive.db DB is not Writeable")
|
log.error_or_exception('Database error: %s', ex)
|
||||||
log.debug('Database error: %s', ex)
|
|
||||||
session.rollback()
|
session.rollback()
|
||||||
return gDriveId.gdrive_id
|
return gDriveId.gdrive_id
|
||||||
|
|
||||||
@ -322,8 +321,7 @@ def getFolderId(path, drive):
|
|||||||
else:
|
else:
|
||||||
currentFolderId = storedPathName.gdrive_id
|
currentFolderId = storedPathName.gdrive_id
|
||||||
except OperationalError as ex:
|
except OperationalError as ex:
|
||||||
log.error("gdrive.db DB is not Writeable")
|
log.error_or_exception('Database error: %s', ex)
|
||||||
log.debug('Database error: %s', ex)
|
|
||||||
session.rollback()
|
session.rollback()
|
||||||
except ApiRequestError as ex:
|
except ApiRequestError as ex:
|
||||||
log.error('{} {}'.format(ex.error['message'], path))
|
log.error('{} {}'.format(ex.error['message'], path))
|
||||||
@ -547,8 +545,7 @@ def deleteDatabaseOnChange():
|
|||||||
session.commit()
|
session.commit()
|
||||||
except (OperationalError, InvalidRequestError) as ex:
|
except (OperationalError, InvalidRequestError) as ex:
|
||||||
session.rollback()
|
session.rollback()
|
||||||
log.debug('Database error: %s', ex)
|
log.error_or_exception('Database error: %s', ex)
|
||||||
log.error(u"GDrive DB is not Writeable")
|
|
||||||
|
|
||||||
|
|
||||||
def updateGdriveCalibreFromLocal():
|
def updateGdriveCalibreFromLocal():
|
||||||
@ -566,8 +563,7 @@ def updateDatabaseOnEdit(ID,newPath):
|
|||||||
try:
|
try:
|
||||||
session.commit()
|
session.commit()
|
||||||
except OperationalError as ex:
|
except OperationalError as ex:
|
||||||
log.error("gdrive.db DB is not Writeable")
|
log.error_or_exception('Database error: %s', ex)
|
||||||
log.debug('Database error: %s', ex)
|
|
||||||
session.rollback()
|
session.rollback()
|
||||||
|
|
||||||
|
|
||||||
@ -577,8 +573,7 @@ def deleteDatabaseEntry(ID):
|
|||||||
try:
|
try:
|
||||||
session.commit()
|
session.commit()
|
||||||
except OperationalError as ex:
|
except OperationalError as ex:
|
||||||
log.error("gdrive.db DB is not Writeable")
|
log.error_or_exception('Database error: %s', ex)
|
||||||
log.debug('Database error: %s', ex)
|
|
||||||
session.rollback()
|
session.rollback()
|
||||||
|
|
||||||
|
|
||||||
@ -599,8 +594,7 @@ def get_cover_via_gdrive(cover_path):
|
|||||||
try:
|
try:
|
||||||
session.commit()
|
session.commit()
|
||||||
except OperationalError as ex:
|
except OperationalError as ex:
|
||||||
log.error("gdrive.db DB is not Writeable")
|
log.error_or_exception('Database error: %s', ex)
|
||||||
log.debug('Database error: %s', ex)
|
|
||||||
session.rollback()
|
session.rollback()
|
||||||
return df.metadata.get('webContentLink')
|
return df.metadata.get('webContentLink')
|
||||||
else:
|
else:
|
||||||
|
@ -435,8 +435,7 @@ def rename_all_authors(first_author, renamed_author, calibre_path="", localbook=
|
|||||||
new_author_path = os.path.join(calibre_path, new_author_rename_dir)
|
new_author_path = os.path.join(calibre_path, new_author_rename_dir)
|
||||||
shutil.move(os.path.normcase(old_author_path), os.path.normcase(new_author_path))
|
shutil.move(os.path.normcase(old_author_path), os.path.normcase(new_author_path))
|
||||||
except OSError as ex:
|
except OSError as ex:
|
||||||
log.error("Rename author from: %s to %s: %s", old_author_path, new_author_path, ex)
|
log.error_or_exception("Rename author from: %s to %s: %s", old_author_path, new_author_path, ex)
|
||||||
log.debug(ex, exc_info=True)
|
|
||||||
return _("Rename author from: '%(src)s' to '%(dest)s' failed with error: %(error)s",
|
return _("Rename author from: '%(src)s' to '%(dest)s' failed with error: %(error)s",
|
||||||
src=old_author_path, dest=new_author_path, error=str(ex))
|
src=old_author_path, dest=new_author_path, error=str(ex))
|
||||||
else:
|
else:
|
||||||
@ -550,8 +549,7 @@ def move_files_on_change(calibre_path, new_authordir, new_titledir, localbook, d
|
|||||||
# change location in database to new author/title path
|
# change location in database to new author/title path
|
||||||
localbook.path = os.path.join(new_authordir, new_titledir).replace('\\', '/')
|
localbook.path = os.path.join(new_authordir, new_titledir).replace('\\', '/')
|
||||||
except OSError as ex:
|
except OSError as ex:
|
||||||
log.error("Rename title from: %s to %s: %s", path, new_path, ex)
|
log.error_or_exception("Rename title from: %s to %s: %s", path, new_path, ex)
|
||||||
log.debug(ex, exc_info=True)
|
|
||||||
return _("Rename title from: '%(src)s' to '%(dest)s' failed with error: %(error)s",
|
return _("Rename title from: '%(src)s' to '%(dest)s' failed with error: %(error)s",
|
||||||
src=path, dest=new_path, error=str(ex))
|
src=path, dest=new_path, error=str(ex))
|
||||||
return False
|
return False
|
||||||
@ -572,8 +570,7 @@ def rename_files_on_change(first_author,
|
|||||||
if not gdrive and not renamed_author and not orignal_filepath and len(os.listdir(os.path.dirname(path))) == 0:
|
if not gdrive and not renamed_author and not orignal_filepath and len(os.listdir(os.path.dirname(path))) == 0:
|
||||||
shutil.rmtree(os.path.dirname(path))
|
shutil.rmtree(os.path.dirname(path))
|
||||||
except (OSError, FileNotFoundError) as ex:
|
except (OSError, FileNotFoundError) as ex:
|
||||||
log.error("Error in rename file in path %s", ex)
|
log.error_or_exception("Error in rename file in path %s", ex)
|
||||||
log.debug(ex, exc_info=True)
|
|
||||||
return _("Error in rename file in path: %(error)s", error=str(ex))
|
return _("Error in rename file in path: %(error)s", error=str(ex))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user