From b2f5853b12cf2497fa29a232ee79018099c47e73 Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Sat, 27 Jul 2024 18:42:21 +0200 Subject: [PATCH] Removed unused imports Rearranged imports to output all missing libs Update Testresults Updated requirements --- cps/MyLoginManager.py | 3 - cps/helper.py | 45 +- cps/main.py | 2 +- requirements.txt | 3 +- test/Calibre-Web TestSummary_Linux.html | 562 ++++++++++++++---------- 5 files changed, 353 insertions(+), 262 deletions(-) diff --git a/cps/MyLoginManager.py b/cps/MyLoginManager.py index 419b2e90..44907045 100644 --- a/cps/MyLoginManager.py +++ b/cps/MyLoginManager.py @@ -19,14 +19,11 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import ast -import hashlib from .cw_login import LoginManager from flask import session - class MyLoginManager(LoginManager): def _session_protection_failed(self): sess = session._get_current_object() diff --git a/cps/helper.py b/cps/helper.py index 37302075..004e1b0e 100644 --- a/cps/helper.py +++ b/cps/helper.py @@ -413,36 +413,6 @@ def rename_all_files_on_change(one_book, new_path, old_path, all_new_name, gdriv file_format.name = all_new_name -'''def rename_all_authors(first_author, renamed_author, calibre_path="", localbook=None, gdrive=False): - # Create new_author_dir from parameter or from database - # Create new title_dir from database and add id - if first_author: - new_authordir = get_valid_filename(first_author, chars=96) - for r in renamed_author: - new_author = calibre_db.session.query(db.Authors).filter(db.Authors.name == r).first() - old_author_dir = get_valid_filename(r, chars=96) - new_author_rename_dir = get_valid_filename(new_author.name, chars=96) - if gdrive: - g_file = gd.getFileFromEbooksFolder(None, old_author_dir) - if g_file: - gd.moveGdriveFolderRemote(g_file, new_author_rename_dir) - gd.updateDatabaseOnEdit(g_file['id'], new_author_rename_dir) - else: - if os.path.isdir(os.path.join(calibre_path, old_author_dir)): - old_author_path = os.path.join(calibre_path, old_author_dir) - new_author_path = os.path.join(calibre_path, new_author_rename_dir) - try: - shutil.move(os.path.normcase(old_author_path), os.path.normcase(new_author_path)) - except OSError as ex: - log.error("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", - src=old_author_path, dest=new_author_path, error=str(ex)) - else: - new_authordir = get_valid_filename(localbook.authors[0].name, chars=96) - return new_authordir''' - - def rename_author_path(first_author, old_author_dir, renamed_author, calibre_path="", gdrive=False): # Create new_author_dir from parameter or from database # Create new title_dir from database and add id @@ -459,12 +429,15 @@ def rename_author_path(first_author, old_author_dir, renamed_author, calibre_pat old_author_path = os.path.join(calibre_path, old_author_dir) new_author_path = os.path.join(calibre_path, new_author_rename_dir) try: - shutil.move(old_author_path, new_author_path) - except OSError as ex: - log.error("Rename author from: %s to %s: %s", old_author_path, new_author_path, ex) - log.debug(ex, exc_info=True) - raise Exception(_("Rename author from: '%(src)s' to '%(dest)s' failed with error: %(error)s", - src=old_author_path, dest=new_author_path, error=str(ex))) + os.rename(old_author_path, new_author_path) + except OSError: + try: + shutil.move(old_author_path, new_author_path) + except OSError as ex: + log.error("Rename author from: %s to %s: %s", old_author_path, new_author_path, ex) + log.error_or_exception(ex) + raise Exception(_("Rename author from: '%(src)s' to '%(dest)s' failed with error: %(error)s", + src=old_author_path, dest=new_author_path, error=str(ex))) return new_authordir # Moves files in file storage during author/title rename, or from temp dir to file storage diff --git a/cps/main.py b/cps/main.py index 6afb18af..1b3b40b4 100644 --- a/cps/main.py +++ b/cps/main.py @@ -20,7 +20,6 @@ import sys from . import create_app, limiter from .jinjia import jinjia -from .remotelogin import remotelogin from flask import request @@ -42,6 +41,7 @@ def main(): from .shelf import shelf from .tasks_status import tasks from .error_handler import init_errorhandler + from .remotelogin import remotelogin try: from .kobo import kobo, get_kobo_activated from .kobo_auth import kobo_auth diff --git a/requirements.txt b/requirements.txt index 0e3f86f5..460a7357 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ -Werkzeug<3.0.0 APScheduler>=3.6.3,<3.11.0 Babel>=1.3,<3.0 Flask-Babel>=0.11.1,<4.1.0 @@ -16,7 +15,7 @@ lxml>=4.9.1,<5.3.0 flask-wtf>=0.14.2,<1.3.0 chardet>=3.0.0,<4.1.0 advocate>=1.0.0,<1.1.0 -Flask-Limiter>=2.3.0,<3.6.0 +Flask-Limiter>=2.3.0,<3.9.0 regex>=2022.3.2,<2024.6.25 bleach>=6.0.0,<6.2.0 python-magic>=0.4.27,<0.5.0 diff --git a/test/Calibre-Web TestSummary_Linux.html b/test/Calibre-Web TestSummary_Linux.html index 1bdb3396..b21f11ff 100644 --- a/test/Calibre-Web TestSummary_Linux.html +++ b/test/Calibre-Web TestSummary_Linux.html @@ -37,20 +37,20 @@
-

Start Time: 2024-07-24 19:37:58

+

Start Time: 2024-07-29 06:08:20

-

Stop Time: 2024-07-25 02:52:34

+

Stop Time: 2024-07-29 13:40:23

-

Duration: 6h 1 min

+

Duration: 6h 9 min

@@ -234,11 +234,11 @@ - + TestBackupMetadata 21 - 21 - 0 + 20 + 1 0 0 @@ -248,11 +248,33 @@ - +
TestBackupMetadata - test_backup_all
- PASS + +
+ FAIL +
+ + + + @@ -462,12 +484,12 @@ - + TestCli 13 - 13 - 0 + 11 0 + 2 0 Detail @@ -566,11 +588,31 @@ - +
TestCli - test_no_database
- PASS + +
+ ERROR +
+ + + + @@ -584,22 +626,53 @@ - +
TestCli - test_writeonly_static_files
- PASS + +
+ ERROR +
+ + + + - + TestCliGdrivedb 4 - 4 - 0 + 3 0 + 1 0 Detail @@ -635,11 +708,31 @@ - +
TestCliGdrivedb - test_no_database
- PASS + +
+ ERROR +
+ + + + @@ -1014,11 +1107,11 @@ - + TestEditAdditionalBooks 20 - 18 - 0 + 17 + 1 0 2 @@ -1189,11 +1282,31 @@ - +
TestEditAdditionalBooks - test_writeonly_path
- PASS + +
+ FAIL +
+ + + + @@ -1617,11 +1730,11 @@ - + TestEditAuthors 9 - 9 - 0 + 5 + 4 0 0 @@ -1640,38 +1753,118 @@ - +
TestEditAuthors - test_change_capital_one_author_one_book
- PASS + +
+ FAIL +
+ + + + - +
TestEditAuthors - test_change_capital_one_author_two_books
- PASS + +
+ FAIL +
+ + + + - +
TestEditAuthors - test_change_capital_one_author_two_books_coauthor
- PASS + +
+ FAIL +
+ + + + - +
TestEditAuthors - test_change_capital_rename_co_author
- PASS + +
+ FAIL +
+ + + + @@ -1791,12 +1984,12 @@ - + TestEditAuthorsSmb 9 - 3 - 4 - 2 + 9 + 0 + 0 0 Detail @@ -1814,118 +2007,38 @@ - +
TestEditAuthorsSmb - test_change_capital_one_author_one_book
- -
- FAIL -
- - - - + PASS - +
TestEditAuthorsSmb - test_change_capital_one_author_two_books
- -
- FAIL -
- - - - + PASS - +
TestEditAuthorsSmb - test_change_capital_one_author_two_books_coauthor
- -
- FAIL -
- - - - + PASS - +
TestEditAuthorsSmb - test_change_capital_rename_co_author
- -
- FAIL -
- - - - + PASS @@ -1948,81 +2061,30 @@ AssertionError: <selenium.webdriver.remote.webelement.WebElement (session= - +
TestEditAuthorsSmb - test_rename_capital_on_upload
- -
- ERROR -
- - - - + PASS - +
TestEditAuthorsSmb - test_rename_tag_emphasis_mark_onupload
- -
- ERROR -
- - - - + PASS - + TestEditBooksList 19 - 19 - 0 + 18 + 1 0 0 @@ -2131,11 +2193,31 @@ dom.find/</<@chrome://remote/content/shared/DOM.sys.mjs:136:16 - +
TestEditBooksList - test_bookslist_edit_languages
- PASS + +
+ FAIL +
+ + + + @@ -2204,12 +2286,12 @@ dom.find/</<@chrome://remote/content/shared/DOM.sys.mjs:136:16 - + TestLoadMetadata 1 0 - 1 0 + 1 0 Detail @@ -2218,26 +2300,26 @@ dom.find/</<@chrome://remote/content/shared/DOM.sys.mjs:136:16 - +
TestLoadMetadata - test_load_metadata
- FAIL + ERROR
-