diff --git a/cps/db.py b/cps/db.py index ff392274..68e02b81 100644 --- a/cps/db.py +++ b/cps/db.py @@ -914,7 +914,8 @@ class CalibreDB: .filter(Languages.lang_code == None) .filter(self.common_filters()) .count()) - tags.append([Category(_("None"), "none"), no_lang_count]) + if no_lang_count: + tags.append([Category(_("None"), "none"), no_lang_count]) return sorted(tags, key=lambda x: x[0].name, reverse=reverse_order) else: if not languages: @@ -993,10 +994,12 @@ class Category: name = None id = None count = None + rating = None - def __init__(self, name, cat_id): + def __init__(self, name, cat_id, rating=None): self.name = name self.id = cat_id + self.rating = rating self.count = 1 '''class Count: diff --git a/cps/metadata_provider/amazon.py b/cps/metadata_provider/amazon.py index 7de0d415..da3aed79 100644 --- a/cps/metadata_provider/amazon.py +++ b/cps/metadata_provider/amazon.py @@ -56,13 +56,13 @@ class Amazon(Metadata): self, query: str, generic_cover: str = "", locale: str = "en" ) -> Optional[List[MetaRecord]]: #timer=time() - def inner(link,index) -> tuple[dict,int]: + def inner(link, index) -> [dict, int]: with self.session as session: try: r = session.get(f"https://www.amazon.com/{link}") r.raise_for_status() - except Exception as e: - log.warning(e) + except Exception as ex: + log.warning(ex) return long_soup = BS(r.text, "lxml") #~4sec :/ soup2 = long_soup.find("div", attrs={"cel_widget_id": "dpx-books-ppd_csm_instrumentation_wrapper"}) @@ -126,16 +126,16 @@ class Amazon(Metadata): headers=self.headers) results.raise_for_status() except requests.exceptions.HTTPError as e: - log.error_or_exception(e) - return None + log.error_or_exception(e) + return None except Exception as e: - log.warning(e) - return None + log.warning(e) + return None soup = BS(results.text, 'html.parser') links_list = [next(filter(lambda i: "digital-text" in i["href"], x.findAll("a")))["href"] for x in soup.findAll("div", attrs={"data-component-type": "s-search-result"})] with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor: fut = {executor.submit(inner, link, index) for index, link in enumerate(links_list[:5])} - val=list(map(lambda x : x.result() ,concurrent.futures.as_completed(fut))) - result=list(filter(lambda x: x, val)) + val = list(map(lambda x : x.result() ,concurrent.futures.as_completed(fut))) + result = list(filter(lambda x: x, val)) return [x[0] for x in sorted(result, key=itemgetter(1))] #sort by amazons listing order for best relevance diff --git a/cps/templates/list.html b/cps/templates/list.html index ed59661e..a9089823 100644 --- a/cps/templates/list.html +++ b/cps/templates/list.html @@ -29,7 +29,7 @@
Traceback (most recent call last): + File "/home/ozzie/Development/calibre-web-test/test/test_anonymous.py", line 405, in test_guest_change_visibility_category + self.assertEqual(books[0]['title'], 'Gênot') +AssertionError: 'None' != 'Gênot' +- None ++ Gênot+
Traceback (most recent call last): + File "/home/ozzie/Development/calibre-web-test/test/test_anonymous.py", line 259, in test_guest_change_visibility_language + self.assertEqual(books[1]['id'], 'eng') +AssertionError: 'none' != 'eng' +- none ++ eng+
Traceback (most recent call last): + File "/home/ozzie/Development/calibre-web-test/test/test_anonymous.py", line 322, in test_guest_change_visibility_publisher + self.assertEqual(books[0]['title'], 'Randomhäus') +AssertionError: 'None' != 'Randomhäus' +- None ++ Randomhäus+
Traceback (most recent call last): + File "/home/ozzie/Development/calibre-web-test/test/test_anonymous.py", line 364, in test_guest_change_visibility_rating + self.assertEqual(books[1]['id'], '2') +IndexError: list index out of range+
Traceback (most recent call last): + File "/home/ozzie/Development/calibre-web-test/test/test_anonymous.py", line 39, in tearDown + self.check_element_on_page((By.ID, "top_user")).click() +AttributeError: 'bool' object has no attribute 'click'+
Traceback (most recent call last): + File "/home/ozzie/Development/calibre-web-test/test/test_anonymous.py", line 289, in test_guest_change_visibility_series + self.assertTrue(self.check_element_on_page((By.ID, "flash_success"))) +AssertionError: False is not true+
Traceback (most recent call last): + File "/home/ozzie/Development/calibre-web-test/test/test_anonymous.py", line 39, in tearDown + self.check_element_on_page((By.ID, "top_user")).click() +AttributeError: 'bool' object has no attribute 'click'+
Traceback (most recent call last): + File "/home/ozzie/Development/calibre-web-test/test/test_anonymous.py", line 54, in test_guest_random_books_available + self.assertTrue(self.check_element_on_page((By.ID, "books_rand"))) +AssertionError: False is not true+
Traceback (most recent call last): + File "/home/ozzie/Development/calibre-web-test/test/test_anonymous.py", line 39, in tearDown + self.check_element_on_page((By.ID, "top_user")).click() +AttributeError: 'bool' object has no attribute 'click'+
Traceback (most recent call last): + File "/home/ozzie/Development/calibre-web-test/test/test_anonymous.py", line 384, in test_guest_restricted_settings_visibility + self.assertIsNone(rights['show_512']) +TypeError: 'bool' object is not subscriptable+
Traceback (most recent call last): + File "/home/ozzie/Development/calibre-web-test/test/test_anonymous.py", line 39, in tearDown + self.check_element_on_page((By.ID, "top_user")).click() +AttributeError: 'bool' object has no attribute 'click'+
Traceback (most recent call last): + File "/home/ozzie/Development/calibre-web-test/test/test_anonymous.py", line 135, in test_guest_visibility_sidebar + self.assertTrue(self.check_element_on_page((By.ID, "flash_success"))) +AssertionError: False is not true+
Traceback (most recent call last): + File "/home/ozzie/Development/calibre-web-test/test/test_anonymous.py", line 39, in tearDown + self.check_element_on_page((By.ID, "top_user")).click() +AttributeError: 'bool' object has no attribute 'click'+
Traceback (most recent call last): + File "/home/ozzie/Development/calibre-web-test/test/test_anonymous.py", line 26, in tearDownClass + cls.stop_calibre_web() + File "/home/ozzie/Development/calibre-web-test/test/helper_ui.py", line 446, 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_cli.py", line 316, in test_bind_to_single_interface + self.assertTrue(re.findall('Reached error page:\sabout:neterror\?e=connectionFailure', error)) +AssertionError: [] is not true+
Traceback (most recent call last): + File "/home/ozzie/Development/calibre-web-test/test/test_cli.py", line 446, in test_change_password + self.login("admin", "adm:in12") +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 + + +During handling of the above exception, another exception occurred: + +Traceback (most recent call last): + File "/home/ozzie/Development/calibre-web-test/test/test_cli.py", line 453, in test_change_password + self.assertFalse(e) +AssertionError: TimeoutException('', None, ['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', '']) is not false+
Traceback (most recent call last): + File "/home/ozzie/Development/calibre-web-test/test/test_cli.py", line 280, in test_cli_SSL_files + self.driver.get("https://127.0.0.1:8083") +selenium.common.exceptions.WebDriverException: Message: Reached error page: about:neterror?e=netTimeout&u=https%3A//127.0.0.1%3A8083/&c=UTF-8&d=The%20server%20at%20127.0.0.1%20is%20taking%20too%20long%20to%20respond. +Stacktrace: +WebDriverError@chrome://remote/content/shared/webdriver/Errors.jsm:183:5 +UnknownError@chrome://remote/content/shared/webdriver/Errors.jsm:510:5 +checkReadyState@chrome://remote/content/marionette/navigate.js:64:24 +onNavigation@chrome://remote/content/marionette/navigate.js:312:39 +emit@resource://gre/modules/EventEmitter.jsm:160:20 +receiveMessage@chrome://remote/content/marionette/actors/MarionetteEventsParent.jsm:44:25 + + +During handling of the above exception, another exception occurred: + +Traceback (most recent call last): + File "/home/ozzie/Development/calibre-web-test/test/test_cli.py", line 282, in test_cli_SSL_files + self.assertIsNone("Error", "HTTPS Connection could not established with key/cert file") +AssertionError: 'Error' is not None : HTTPS Connection could not established with key/cert file+
Traceback (most recent call last): + File "/home/ozzie/Development/calibre-web-test/test/test_cli.py", line 125, in test_cli_different_settings_database + self.fill_db_config({'config_calibre_dir': TEST_DB}) + File "/home/ozzie/Development/calibre-web-test/test/helper_ui.py", line 223, in fill_db_config + cls.login('admin', 'admin123') + File "/home/ozzie/Development/calibre-web-test/test/helper_ui.py", line 87, in login + WebDriverWait(cls.driver, 5).until(EC.presence_of_element_located((By.ID, "username"))) + 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_cli.py", line 408, in test_settingsdb_not_writeable + self.fill_db_config({'config_calibre_dir': TEST_DB}) +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 + + +During handling of the above exception, another exception occurred: + +Traceback (most recent call last): + File "/home/ozzie/Development/calibre-web-test/test/test_cli.py", line 413, in test_settingsdb_not_writeable + self.assertFalse(True, "Inital config failed with nonwriteable database") +AssertionError: True is not false : Inital config failed with nonwriteable database+
Traceback (most recent call last): + File "/home/ozzie/Development/calibre-web-test/test/test_delete_database.py", line 70, in test_delete_books_in_database + self.assertEqual(0, len(list_element)) +AssertionError: 0 != 1+