diff --git a/cps/tasks/thumbnail.py b/cps/tasks/thumbnail.py index 5bf0466b..e66da036 100644 --- a/cps/tasks/thumbnail.py +++ b/cps/tasks/thumbnail.py @@ -17,6 +17,7 @@ # along with this program. If not, see . import os +from shutil import copyfile, copyfileobj from urllib.request import urlopen from .. import constants @@ -188,14 +189,18 @@ class TaskGenerateCoverThumbnails(CalibreTask): try: stream = urlopen(web_content_link) with Image(file=stream) as img: + filename = self.cache.get_cache_file_path(thumbnail.filename, + constants.CACHE_TYPE_THUMBNAILS) height = get_resize_height(thumbnail.resolution) if img.height > height: width = get_resize_width(thumbnail.resolution, img.width, img.height) img.resize(width=width, height=height, filter='lanczos') img.format = thumbnail.format - filename = self.cache.get_cache_file_path(thumbnail.filename, - constants.CACHE_TYPE_THUMBNAILS) img.save(filename=filename) + else: + with open(filename, 'rb') as fd: + copyfileobj(stream, fd) + except Exception as ex: # Bubble exception to calling function self.log.debug('Error generating thumbnail file: ' + str(ex)) @@ -210,12 +215,15 @@ class TaskGenerateCoverThumbnails(CalibreTask): with Image(filename=book_cover_filepath) as img: height = get_resize_height(thumbnail.resolution) + filename = self.cache.get_cache_file_path(thumbnail.filename, constants.CACHE_TYPE_THUMBNAILS) if img.height > height: width = get_resize_width(thumbnail.resolution, img.width, img.height) img.resize(width=width, height=height, filter='lanczos') img.format = thumbnail.format - filename = self.cache.get_cache_file_path(thumbnail.filename, constants.CACHE_TYPE_THUMBNAILS) img.save(filename=filename) + else: + # take cover as is + copyfile(book_cover_filepath, filename) @property def name(self): diff --git a/test/Calibre-Web TestSummary_Linux.html b/test/Calibre-Web TestSummary_Linux.html index ee349d8d..735a1db2 100644 --- a/test/Calibre-Web TestSummary_Linux.html +++ b/test/Calibre-Web TestSummary_Linux.html @@ -37,20 +37,20 @@
-

Start Time: 2023-03-05 19:08:50

+

Start Time: 2023-03-20 06:27:14

-

Stop Time: 2023-03-06 01:50:49

+

Stop Time: 2023-03-20 13:00:29

-

Duration: 5h 46 min

+

Duration: 5h 35 min

@@ -236,120 +236,380 @@ TestBackupMetadata - 14 - 13 - 0 + 16 1 + 1 + 14 0 - Detail + Detail - +
TestBackupMetadata - test_backup_all
- PASS + +
+ FAIL +
+ + + + - +
TestBackupMetadata - test_backup_change_book_author
- PASS - - - - - - -
TestBackupMetadata - test_backup_change_book_custom_bool
+ +
+ ERROR +
+ + + - PASS - +
TestBackupMetadata - test_backup_change_book_description
- PASS + +
+ ERROR +
+ + + + - +
TestBackupMetadata - test_backup_change_book_language
- PASS + +
+ ERROR +
+ + + + - +
TestBackupMetadata - test_backup_change_book_publisher
- PASS + +
+ ERROR +
+ + + + - +
TestBackupMetadata - test_backup_change_book_publishing_date
- PASS + +
+ ERROR +
+ + + + - +
TestBackupMetadata - test_backup_change_book_rating
- PASS - - - - - - -
TestBackupMetadata - test_backup_change_book_read_status
+ +
+ ERROR +
+ + + - PASS - +
TestBackupMetadata - test_backup_change_book_seriesindex
- PASS + +
+ ERROR +
+ + + + - +
TestBackupMetadata - test_backup_change_book_tags
- PASS + +
+ ERROR +
+ + + + + + + + + + +
TestBackupMetadata - test_backup_change_book_title
+ + +
+ ERROR +
+ + + + + + + + + + +
TestBackupMetadata - test_backup_change_custom_bool
+ + +
+ ERROR +
+ + + + -
TestBackupMetadata - test_backup_change_book_title
+
TestBackupMetadata - test_backup_change_custom_float
@@ -364,11 +624,13 @@
Traceback (most recent call last):
-  File "/home/ozzie/Development/calibre-web-test/test/test_backup_metadata.py", line 224, in test_backup_change_book_title
-    self.edit_book(7, content={'title': 'Buuko'})
-  File "/home/ozzie/Development/calibre-web-test/test/helper_ui.py", line 1772, in edit_book
-    ele.send_keys(Keys.CONTROL, "a")
-AttributeError: 'bool' object has no attribute 'send_keys'
+ File "/home/ozzie/Development/calibre-web-test/test/test_backup_metadata.py", line 389, in test_backup_change_custom_float + metadata = read_opf_metadata(meta_path) + File "/home/ozzie/Development/calibre-web-test/test/test_backup_metadata.py", line 21, in read_opf_metadata + with codecs.open(filename, "r", "utf-8") as f: + File "/usr/lib/python3.10/codecs.py", line 905, in open + file = builtins.open(filename, mode, buffering) +FileNotFoundError: [Errno 2] No such file or directory: '/home/ozzie/Development/Dokumente/tüst db/Asterix Lionherd/comicdemo (3)/metadata.opf'
@@ -378,7 +640,73 @@ AttributeError: 'bool' object has no attribute 'send_keys' - + + +
TestBackupMetadata - test_backup_change_custom_int
+ + +
+ ERROR +
+ + + + + + + + + + +
TestBackupMetadata - test_backup_change_custom_rating
+ + +
+ ERROR +
+ + + + + + + + +
TestBackupMetadata - test_gdrive
@@ -387,11 +715,35 @@ AttributeError: 'bool' object has no attribute 'send_keys' - +
TestBackupMetadata - test_upload_book
- PASS + +
+ ERROR +
+ + + + @@ -1524,11 +1876,11 @@ AttributeError: 'bool' object has no attribute 'send_keys' - + TestEditAuthorsGdrive 6 - 6 - 0 + 5 + 1 0 0 @@ -1556,11 +1908,31 @@ AttributeError: 'bool' object has no attribute 'send_keys' - +
TestEditAuthorsGdrive - test_change_capital_one_author_two_books
- PASS + +
+ FAIL +
+ + + + @@ -1770,13 +2142,13 @@ AttributeError: 'bool' object has no attribute 'send_keys' - + TestLoadMetadata 1 - 0 - 0 1 0 + 0 + 0 Detail @@ -1784,42 +2156,22 @@ AttributeError: 'bool' object has no attribute 'send_keys' - +
TestLoadMetadata - test_load_metadata
- -
- ERROR -
- - - - + PASS - + TestEditBooksOnGdrive 18 - 18 - 0 + 16 0 + 2 0 Detail @@ -1837,11 +2189,42 @@ IndexError: list index out of range - +
TestEditBooksOnGdrive - test_edit_author
- PASS + +
+ ERROR +
+ + + + @@ -1963,11 +2346,31 @@ IndexError: list index out of range - +
TestEditBooksOnGdrive - test_edit_title
- PASS + +
+ ERROR +
+ + + + @@ -3848,8 +4251,8 @@ IndexError: list index out of range TestThumbnails 8 - 2 - 5 + 6 + 1 0 1 @@ -3868,89 +4271,29 @@ IndexError: list index out of range - +
TestThumbnails - test_cache_of_deleted_book
- -
- FAIL -
- - - - + PASS - +
TestThumbnails - test_cover_cache_on_database_change
- -
- FAIL -
- - - - + PASS - +
TestThumbnails - test_cover_change_on_upload_new_cover
- -
- FAIL -
- - - - + PASS @@ -3964,31 +4307,11 @@ AssertionError: 2 not less than or equal to 1 - +
TestThumbnails - test_cover_on_upload_book
- -
- FAIL -
- - - - + PASS @@ -4019,9 +4342,9 @@ AssertionError: 2 not less than or equal to 1
Traceback (most recent call last):
-  File "/home/ozzie/Development/calibre-web-test/test/test_thumbnails.py", line 320, in test_sideloaded_book
-    self.assertGreaterEqual(diff(BytesIO(list_cover), BytesIO(new_list_cover), delete_diff_file=True), 0.04)
-AssertionError: 0.0036014628073451605 not greater than or equal to 0.04
+ File "/home/ozzie/Development/calibre-web-test/test/test_thumbnails.py", line 310, in test_sideloaded_book + self.assertAlmostEqual(diff(BytesIO(list_cover), BytesIO(old_list_cover), delete_diff_file=True), 0.0, +AssertionError: 0.007264083411142234 != 0.0 within 0.0001 delta (0.007264083411142234 difference)
@@ -5100,10 +5423,10 @@ AssertionError: 0.0036014628073451605 not greater than or equal to 0.04 Total - 445 - 431 - 5 - 2 + 447 + 421 + 3 + 16 7   @@ -5240,7 +5563,7 @@ AssertionError: 0.0036014628073451605 not greater than or equal to 0.04 pypdf - 3.5.1 + 3.5.2 Basic @@ -5258,7 +5581,7 @@ AssertionError: 0.0036014628073451605 not greater than or equal to 0.04 SQLAlchemy - 1.4.46 + 1.4.47 Basic @@ -5288,7 +5611,7 @@ AssertionError: 0.0036014628073451605 not greater than or equal to 0.04 google-api-python-client - 2.80.0 + 2.81.0 TestCliGdrivedb @@ -5318,7 +5641,7 @@ AssertionError: 0.0036014628073451605 not greater than or equal to 0.04 google-api-python-client - 2.80.0 + 2.81.0 TestEbookConvertCalibreGDrive @@ -5348,7 +5671,7 @@ AssertionError: 0.0036014628073451605 not greater than or equal to 0.04 google-api-python-client - 2.80.0 + 2.81.0 TestEbookConvertGDriveKepubify @@ -5390,7 +5713,7 @@ AssertionError: 0.0036014628073451605 not greater than or equal to 0.04 google-api-python-client - 2.80.0 + 2.81.0 TestEditAuthorsGdrive @@ -5426,7 +5749,7 @@ AssertionError: 0.0036014628073451605 not greater than or equal to 0.04 google-api-python-client - 2.80.0 + 2.81.0 TestEditBooksOnGdrive @@ -5468,7 +5791,7 @@ AssertionError: 0.0036014628073451605 not greater than or equal to 0.04 google-api-python-client - 2.80.0 + 2.81.0 TestSetupGdrive @@ -5558,7 +5881,7 @@ AssertionError: 0.0036014628073451605 not greater than or equal to 0.04