diff --git a/cps/__init__.py b/cps/__init__.py index f597aab5..3f92571b 100644 --- a/cps/__init__.py +++ b/cps/__init__.py @@ -166,6 +166,11 @@ def create_app(): config.config_goodreads_api_secret, config.config_use_goodreads) config.store_calibre_uuid(calibre_db, db.Library_Id) + # Register scheduled tasks + from .schedule import register_scheduled_tasks, register_startup_tasks + register_scheduled_tasks(config.schedule_reconnect) + register_startup_tasks() + return app diff --git a/cps/helper.py b/cps/helper.py index 7c76d180..7362eb9e 100644 --- a/cps/helper.py +++ b/cps/helper.py @@ -342,9 +342,9 @@ def edit_book_read_status(book_id, read_status=None): return "" -# Deletes a book fro the local filestorage, returns True if deleting is successfull, otherwise false +# Deletes a book from the local filestorage, returns True if deleting is successful, otherwise false def delete_book_file(book, calibrepath, book_format=None): - # check that path is 2 elements deep, check that target path has no subfolders + # check that path is 2 elements deep, check that target path has no sub folders if book.path.count('/') == 1: path = os.path.join(calibrepath, book.path) if book_format: @@ -679,7 +679,8 @@ def update_dir_structure(book_id, def delete_book(book, calibrepath, book_format): - clear_cover_thumbnail_cache(book.id) + if not book_format: + clear_cover_thumbnail_cache(book.id) ## here it breaks if config.config_use_google_drive: return delete_book_gdrive(book, book_format) else: @@ -1003,21 +1004,26 @@ def get_download_link(book_id, book_format, client): def clear_cover_thumbnail_cache(book_id): - WorkerThread.add(None, TaskClearCoverThumbnailCache(book_id), hidden=True) + if config.schedule_generate_book_covers: + WorkerThread.add(None, TaskClearCoverThumbnailCache(book_id), hidden=True) def replace_cover_thumbnail_cache(book_id): - WorkerThread.add(None, TaskClearCoverThumbnailCache(book_id), hidden=True) - WorkerThread.add(None, TaskGenerateCoverThumbnails(book_id), hidden=True) + if config.schedule_generate_book_covers: + WorkerThread.add(None, TaskClearCoverThumbnailCache(book_id), hidden=True) + WorkerThread.add(None, TaskGenerateCoverThumbnails(book_id), hidden=True) def delete_thumbnail_cache(): - WorkerThread.add(None, TaskClearCoverThumbnailCache(-1)) + if config.schedule_generate_book_covers: + WorkerThread.add(None, TaskClearCoverThumbnailCache(-1)) def add_book_to_thumbnail_cache(book_id): - WorkerThread.add(None, TaskGenerateCoverThumbnails(book_id), hidden=True) + if config.schedule_generate_book_covers: + WorkerThread.add(None, TaskGenerateCoverThumbnails(book_id), hidden=True) def update_thumbnail_cache(): - WorkerThread.add(None, TaskGenerateCoverThumbnails()) + if config.schedule_generate_book_covers: + WorkerThread.add(None, TaskGenerateCoverThumbnails()) diff --git a/cps/main.py b/cps/main.py index ccf03c15..16d288ac 100644 --- a/cps/main.py +++ b/cps/main.py @@ -22,13 +22,6 @@ from . import create_app from .jinjia import jinjia from .remotelogin import remotelogin -try: - from kobo import kobo, get_kobo_activated - from kobo_auth import kobo_auth - kobo_available = get_kobo_activated() -except (ImportError, AttributeError): # Catch also error for not installed flask-WTF (missing csrf decorator) - kobo_available = False - try: from oauth_bb import oauth oauth_available = True @@ -50,6 +43,12 @@ def main(): from .shelf import shelf from .tasks_status import tasks from .error_handler import init_errorhandler + try: + from .kobo import kobo, get_kobo_activated + from .kobo_auth import kobo_auth + kobo_available = get_kobo_activated() + except (ImportError, AttributeError): # Catch also error for not installed flask-WTF (missing csrf decorator) + kobo_available = False from . import web_server init_errorhandler() diff --git a/test/Calibre-Web TestSummary_Linux.html b/test/Calibre-Web TestSummary_Linux.html index df55a037..cf3e893d 100644 --- a/test/Calibre-Web TestSummary_Linux.html +++ b/test/Calibre-Web TestSummary_Linux.html @@ -37,20 +37,20 @@
Start Time: 2022-04-25 20:37:58
+Start Time: 2022-04-27 19:55:57
Stop Time: 2022-04-26 02:14:54
+Stop Time: 2022-04-28 01:28:47
Duration: 4h 44 min
+Duration: 4h 34 min
Traceback (most recent call last): - File "/home/ozzie/Development/calibre-web-test/test/test_edit_additional_books.py", line 461, in test_edit_book_identifier - self.assertEqual('Hallo1', list(result['identifier'][-1].keys())[0]) -AssertionError: 'Hallo1' != 'Hallo' -- Hallo1 -? - -+ Hallo-
Traceback (most recent call last): - File "/home/ozzie/Development/calibre-web-test/test/test_edit_additional_books.py", line 614, in test_edit_book_identifier_standard - self.assertEqual(final_length, reference_length) -AssertionError: 14 != 0-
Traceback (most recent call last): - File "/home/ozzie/Development/calibre-web-test/test/test_edit_additional_books.py", line 166, in test_upload_metadata_cbr - self.assertEqual('Test 执book', details['title']) -KeyError: 'title'-
Traceback (most recent call last): - File "/home/ozzie/Development/calibre-web-test/test/test_edit_additional_books.py", line 185, in test_upload_metadata_cbt - self.fill_basic_config({'config_uploading': 1}) - File "/home/ozzie/Development/calibre-web-test/test/helper_ui.py", line 387, in fill_basic_config - cls._fill_basic_config(elements) - File "/home/ozzie/Development/calibre-web-test/test/helper_ui.py", line 297, in _fill_basic_config - WebDriverWait(cls.driver, 5).until(EC.presence_of_element_located((By.ID, "config_port"))) - File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/selenium/webdriver/support/wait.py", line 89, in until - raise TimeoutException(message, screen, stacktrace) -selenium.common.exceptions.TimeoutException: Message: -Stacktrace: -WebDriverError@chrome://remote/content/shared/webdriver/Errors.jsm:183:5 -NoSuchElementError@chrome://remote/content/shared/webdriver/Errors.jsm:395:5 -element.find/</<@chrome://remote/content/marionette/element.js:300:16-
Traceback (most recent call last): - File "/home/ozzie/Development/calibre-web-test/test/test_edit_additional_books.py", line 810, in test_xss_comment_edit - self.check_element_on_page((By.ID, "edit_book")).click() -AttributeError: 'bool' object has no attribute 'click'-
Traceback (most recent call last): - File "/home/ozzie/Development/calibre-web-test/test/test_edit_additional_books.py", line 832, in test_xss_custom_comment_edit - self.check_element_on_page((By.ID, "edit_book")).click() -AttributeError: 'bool' object has no attribute 'click'-
Traceback (most recent call last): - File "/home/ozzie/Development/calibre-web-test/test/test_edit_additional_books.py", line 44, in tearDownClass - cls.stop_calibre_web() - File "/home/ozzie/Development/calibre-web-test/test/helper_ui.py", line 475, in stop_calibre_web - cls.driver.find_element(By.ID, 'admin_stop').click() - File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 1248, in find_element - return self.execute(Command.FIND_ELEMENT, { - File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 425, in execute - self.error_handler.check_response(response) - File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 247, in check_response - raise exception_class(message, screen, stacktrace) -selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: [id="admin_stop"] -Stacktrace: -WebDriverError@chrome://remote/content/shared/webdriver/Errors.jsm:183:5 -NoSuchElementError@chrome://remote/content/shared/webdriver/Errors.jsm:395:5 -element.find/</<@chrome://remote/content/marionette/element.js:300:16-
Traceback (most recent call last): - File "/home/ozzie/Development/calibre-web-test/test/test_thumbnail_env.py", line 26, in setUpClass - add_dependency(cls.json_line, cls.__name__) -AttributeError: type object 'TestThumbnailsEnv' has no attribute 'json_line'-