From 0138ff9e160e1d88941736559a27e104228d43e2 Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Sat, 2 May 2020 10:18:01 +0200 Subject: [PATCH] Added additional config options --- cps/about.py | 2 +- cps/admin.py | 3 +- cps/config_sql.py | 6 ++-- cps/converter.py | 17 +++++------- cps/editbooks.py | 2 +- cps/helper.py | 4 +-- cps/templates/config_edit.html | 50 ++++++++++++++++++++-------------- cps/worker.py | 8 ++---- 8 files changed, 47 insertions(+), 45 deletions(-) diff --git a/cps/about.py b/cps/about.py index 863ec871..438163ab 100644 --- a/cps/about.py +++ b/cps/about.py @@ -90,6 +90,6 @@ def stats(): categorys = db.session.query(db.Tags).count() series = db.session.query(db.Series).count() _VERSIONS['ebook converter'] = _(converter.get_calibre_version()) - _VERSIONS['unrar'] = _(converter.get_version()) + _VERSIONS['unrar'] = _(converter.get_unrar_version()) return render_title_template('stats.html', bookcounter=counter, authorcounter=authors, versions=_VERSIONS, categorycounter=categorys, seriecounter=series, title=_(u"Statistics"), page="stat") diff --git a/cps/admin.py b/cps/admin.py index 5cec8e26..deac22a4 100644 --- a/cps/admin.py +++ b/cps/admin.py @@ -534,10 +534,9 @@ def _configuration_update_helper(): reboot_required |= _config_checkbox_int("config_kobo_sync") _config_checkbox_int("config_kobo_proxy") - - _config_int("config_ebookconverter") _config_string("config_calibre") _config_string("config_converterpath") + _config_string("config_kepubifypath") reboot_required |= _config_int("config_login_type") diff --git a/cps/config_sql.py b/cps/config_sql.py index 241e583a..2882e5df 100644 --- a/cps/config_sql.py +++ b/cps/config_sql.py @@ -87,7 +87,7 @@ class _Settings(_Base): config_use_goodreads = Column(Boolean, default=False) config_goodreads_api_key = Column(String) config_goodreads_api_secret = Column(String) - + config_register_email = Column(Boolean, default=False) config_login_type = Column(Integer, default=0) config_kobo_proxy = Column(Boolean, default=False) @@ -107,10 +107,12 @@ class _Settings(_Base): config_ldap_group_members_field = Column(String, default='memberUid') config_ldap_group_name = Column(String, default='calibreweb') - config_ebookconverter = Column(Integer, default=0) + # config_ebookconverter = Column(Integer, default=0) + config_kepubifypath = Column(String) config_converterpath = Column(String) config_calibre = Column(String) config_rarfile_location = Column(String) + config_upload_formats = Column(String) config_updatechannel = Column(Integer, default=constants.UPDATE_STABLE) diff --git a/cps/converter.py b/cps/converter.py index b8ad1372..99ac3a3e 100644 --- a/cps/converter.py +++ b/cps/converter.py @@ -29,8 +29,8 @@ log = logger.create() # _() necessary to make babel aware of string for translation _NOT_CONFIGURED = _('not configured') -_NOT_INSTALLED = 'not installed' -_EXECUTION_ERROR = 'Execution permissions missing' +_NOT_INSTALLED = _('not installed') +_EXECUTION_ERROR = _('Execution permissions missing') def _get_command_version(path, pattern, argument=None): @@ -49,14 +49,11 @@ def _get_command_version(path, pattern, argument=None): def get_calibre_version(): - version = None - if config.config_ebookconverter == 2: - version = _get_command_version(config.config_converterpath, r'ebook-convert.*\(calibre', '--version') - return version or _NOT_CONFIGURED + # version = None + # if config.config_ebookconverter == 2: + return _get_command_version(config.config_converterpath, r'ebook-convert.*\(calibre', '--version') \ + or _NOT_CONFIGURED def get_unrar_version(): - version = None - if config.config_ebookconverter == 2: - version = _get_command_version(config.config_converterpath, r'ebook-convert.*\(calibre', '--version') - return version or _NOT_CONFIGURED + return _get_command_version(config.config_rarfile_location, r'UNRAR.*\d') or _NOT_CONFIGURED diff --git a/cps/editbooks.py b/cps/editbooks.py index 8d5c9d7e..000ac384 100644 --- a/cps/editbooks.py +++ b/cps/editbooks.py @@ -264,7 +264,7 @@ def render_edit_book(book_id): # Option for showing convertbook button valid_source_formats=list() - if config.config_ebookconverter == 2: + if config.config_converterpath: for file in book.data: if file.format.lower() in constants.EXTENSIONS_CONVERT: valid_source_formats.append(file.format.lower()) diff --git a/cps/helper.py b/cps/helper.py index 0b4c17d2..13cdea80 100644 --- a/cps/helper.py +++ b/cps/helper.py @@ -142,7 +142,7 @@ def check_send_to_kindle(entry): """ if len(entry.data): bookformats = list() - if config.config_ebookconverter == 0: + if not config.config_converterpath: # no converter - only for mobi and pdf formats for ele in iter(entry.data): if 'MOBI' in ele.format: @@ -173,7 +173,7 @@ def check_send_to_kindle(entry): bookformats.append({'format': 'Pdf', 'convert': 0, 'text': _('Send %(format)s to Kindle', format='Pdf')}) - if config.config_ebookconverter == 2: + if config.config_converterpath: if 'EPUB' in formats and not 'MOBI' in formats: bookformats.append({'format': 'Mobi', 'convert':1, diff --git a/cps/templates/config_edit.html b/cps/templates/config_edit.html index 33d4a5e7..f5b9efbb 100644 --- a/cps/templates/config_edit.html +++ b/cps/templates/config_edit.html @@ -154,17 +154,29 @@
- +
+
+
+ + +
+
- +
+
+
+ + +
+
@@ -327,27 +339,23 @@
-
-
-
-
+ +
-
-
- - -
-
- - -
+
+ +
- {% if feature_support['rar'] %} -
- - -
- {% endif %} +
+ + +
+ {% if feature_support['rar'] %} +
+ + +
+ {% endif %}
diff --git a/cps/worker.py b/cps/worker.py index 04da7c92..0ede3246 100644 --- a/cps/worker.py +++ b/cps/worker.py @@ -297,7 +297,7 @@ class WorkerThread(threading.Thread): return try: - if config.config_ebookconverter == 2: + if config.config_converterpath: # Linux py2.7 encode as list without quotes no empty element for parameters # linux py3.x no encode and as list without quotes no empty element for parameters # windows py2.7 encode as string with quotes empty element for parameters is okay @@ -341,11 +341,7 @@ class WorkerThread(threading.Thread): if not ele.startswith('Traceback') and not ele.startswith(' File'): error_message = "Calibre failed with error: %s" % ele.strip('\n') - # kindlegen returncodes - # 0 = Info(prcgen):I1036: Mobi file built successfully - # 1 = Info(prcgen):I1037: Mobi file built with WARNINGS! - # 2 = Info(prcgen):I1038: MOBI file could not be generated because of errors! - if check == 0 and config.config_ebookconverter == 2: + if check == 0: cur_book = db.session.query(db.Books).filter(db.Books.id == bookid).first() if os.path.isfile(file_path + format_new_ext): new_format = db.Data(name=cur_book.data[0].name,