From 2a5e9a97bbaeaa92f989374d47b531b01e8a6ad3 Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Thu, 24 Mar 2022 18:19:41 +0100 Subject: [PATCH] Fix #2349 (import error on python <3.7 dataclasses solved) --- cps/search_metadata.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cps/search_metadata.py b/cps/search_metadata.py index d72273f6..79e27554 100644 --- a/cps/search_metadata.py +++ b/cps/search_metadata.py @@ -23,7 +23,7 @@ import json import os import sys # from time import time -from dataclasses import asdict + from flask import Blueprint, Response, request, url_for from flask_login import current_user @@ -32,7 +32,7 @@ from sqlalchemy.exc import InvalidRequestError, OperationalError from sqlalchemy.orm.attributes import flag_modified from cps.services.Metadata import Metadata -from . import constants, get_locale, logger, ub +from . import constants, get_locale, logger, ub, web_server # current_milli_time = lambda: int(round(time() * 1000)) @@ -40,6 +40,14 @@ meta = Blueprint("metadata", __name__) log = logger.create() +try: + from dataclasses import asdict +except ImportError: + log.info('*** "dataclasses" is needed for calibre-web to run. Please install it using pip: "pip install dataclasses" ***') + print('*** "dataclasses" is needed for calibre-web to run. Please install it using pip: "pip install dataclasses" ***') + web_server.stop(True) + sys.exit(6) + new_list = list() meta_dir = os.path.join(constants.BASE_DIR, "cps", "metadata_provider") modules = os.listdir(os.path.join(constants.BASE_DIR, "cps", "metadata_provider"))