From 3c1b06872d9639c5ea52721049992ebb6272a283 Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Tue, 9 Feb 2021 18:04:49 +0100 Subject: [PATCH 1/2] Updated testresults Changed optional-requirements Prevent redirect 308 on / routes (#1854) --- cps/web.py | 4 +- test/Calibre-Web TestSummary_Linux.html | 92 +++++++++++++------------ 2 files changed, 51 insertions(+), 45 deletions(-) diff --git a/cps/web.py b/cps/web.py index 5b805ac8..09744baf 100644 --- a/cps/web.py +++ b/cps/web.py @@ -719,8 +719,8 @@ def index(page): return render_books_list("newest", sort_param, 1, page) -@web.route('//', defaults={'page': 1, 'book_id': "1"}) -@web.route('///', defaults={'page': 1, 'book_id': "1"}) +@web.route('//', defaults={'page': 1, 'book_id': 1}) +@web.route('///', defaults={'page': 1, 'book_id': 1}) @web.route('///', defaults={'page': 1}) @web.route('////') @login_required_if_no_ano diff --git a/test/Calibre-Web TestSummary_Linux.html b/test/Calibre-Web TestSummary_Linux.html index 365e47c8..702a2668 100644 --- a/test/Calibre-Web TestSummary_Linux.html +++ b/test/Calibre-Web TestSummary_Linux.html @@ -37,14 +37,14 @@
-

Start Time: 2021-02-01 19:02:39

+

Start Time: 2021-02-08 20:40:55

-

Stop Time: 2021-02-01 21:32:03

+

Stop Time: 2021-02-08 23:09:33

@@ -1190,11 +1190,11 @@ - + TestEditBooksOnGdrive 20 - 19 - 1 + 20 + 0 0 0 @@ -1375,31 +1375,11 @@ - +
TestEditBooksOnGdrive - test_watch_metadata
- -
- FAIL -
- - - - + PASS @@ -1615,12 +1595,12 @@ AssertionError: 'series' unexpectedly found in {'reader': ['epub'], 'title': 'te - + TestKoboSync 9 - 9 - 0 + 8 0 + 1 0 Detail @@ -1629,11 +1609,31 @@ AssertionError: 'series' unexpectedly found in {'reader': ['epub'], 'title': 'te - +
TestKoboSync - test_book_download
- PASS + +
+ ERROR +
+ + + + @@ -3400,8 +3400,8 @@ AssertionError: 'series' unexpectedly found in {'reader': ['epub'], 'title': 'te Total 299 291 - 1 0 + 1 7   @@ -3520,7 +3520,7 @@ AssertionError: 'series' unexpectedly found in {'reader': ['epub'], 'title': 'te SQLAlchemy - 1.3.22 + 1.3.23 Basic @@ -3556,7 +3556,7 @@ AssertionError: 'series' unexpectedly found in {'reader': ['epub'], 'title': 'te httplib2 - 0.18.1 + 0.19.0 TestEbookConvertCalibreGDrive @@ -3574,7 +3574,7 @@ AssertionError: 'series' unexpectedly found in {'reader': ['epub'], 'title': 'te PyDrive2 - 1.7.0 + 1.7.2 TestEbookConvertCalibreGDrive @@ -3592,7 +3592,7 @@ AssertionError: 'series' unexpectedly found in {'reader': ['epub'], 'title': 'te httplib2 - 0.18.1 + 0.19.0 TestEbookConvertGDriveKepubify @@ -3610,7 +3610,7 @@ AssertionError: 'series' unexpectedly found in {'reader': ['epub'], 'title': 'te PyDrive2 - 1.7.0 + 1.7.2 TestEbookConvertGDriveKepubify @@ -3652,7 +3652,7 @@ AssertionError: 'series' unexpectedly found in {'reader': ['epub'], 'title': 'te httplib2 - 0.18.1 + 0.19.0 TestEditBooksOnGdrive @@ -3670,7 +3670,7 @@ AssertionError: 'series' unexpectedly found in {'reader': ['epub'], 'title': 'te PyDrive2 - 1.7.0 + 1.7.2 TestEditBooksOnGdrive @@ -3688,7 +3688,7 @@ AssertionError: 'series' unexpectedly found in {'reader': ['epub'], 'title': 'te httplib2 - 0.18.1 + 0.19.0 TestSetupGdrive @@ -3700,7 +3700,7 @@ AssertionError: 'series' unexpectedly found in {'reader': ['epub'], 'title': 'te PyDrive2 - 1.7.0 + 1.7.2 TestSetupGdrive @@ -3716,6 +3716,12 @@ AssertionError: 'series' unexpectedly found in {'reader': ['epub'], 'title': 'te TestGoodreads + + python-Levenshtein + 0.12.2 + TestGoodreads + + jsonschema 3.2.0 @@ -3760,7 +3766,7 @@ AssertionError: 'series' unexpectedly found in {'reader': ['epub'], 'title': 'te From bbf609b8801d0af2209c94f4c26d6b5353b718f5 Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Sat, 13 Feb 2021 14:34:41 +0100 Subject: [PATCH 2/2] Fix #1859 (Upload of jpg files without installed imagemagick doesn't work) --- cps/helper.py | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/cps/helper.py b/cps/helper.py index 77d292eb..92cdb2fb 100644 --- a/cps/helper.py +++ b/cps/helper.py @@ -32,7 +32,7 @@ from tempfile import gettempdir import requests from babel.dates import format_datetime from babel.units import format_unit -from flask import send_from_directory, make_response, redirect, abort, url_for, request +from flask import send_from_directory, make_response, redirect, abort, url_for from flask_babel import gettext as _ from flask_login import current_user from sqlalchemy.sql.expression import true, false, and_, text @@ -592,22 +592,29 @@ def save_cover_from_url(url, book_path): def save_cover_from_filestorage(filepath, saved_filename, img): - if hasattr(img,"metadata"): - img.save(filename=os.path.join(filepath, saved_filename)) - img.close() - else: - # check if file path exists, otherwise create it, copy file to calibre path and delete temp file - if not os.path.exists(filepath): - try: - os.makedirs(filepath) - except OSError: - log.error(u"Failed to create path for cover") - return False, _(u"Failed to create path for cover") + # check if file path exists, otherwise create it, copy file to calibre path and delete temp file + if not os.path.exists(filepath): try: - img.save(os.path.join(filepath, saved_filename)) - except (IOError, OSError): - log.error(u"Cover-file is not a valid image file, or could not be stored") - return False, _(u"Cover-file is not a valid image file, or could not be stored") + os.makedirs(filepath) + except OSError: + log.error(u"Failed to create path for cover") + return False, _(u"Failed to create path for cover") + try: + # upload of jgp file without wand + if isinstance(img, requests.Response): + with open(os.path.join(filepath, saved_filename), 'wb') as f: + f.write(img.content) + else: + if hasattr(img, "metadata"): + # upload of jpg/png... via url + img.save(filename=os.path.join(filepath, saved_filename)) + img.close() + else: + # upload of jpg/png... from hdd + img.save(os.path.join(filepath, saved_filename)) + except (IOError, OSError): + log.error(u"Cover-file is not a valid image file, or could not be stored") + return False, _(u"Cover-file is not a valid image file, or could not be stored") return True, None