From 6ca388100d64023bf922f2994d81b9fe8fdd9904 Mon Sep 17 00:00:00 2001
From: darodi <4682830+darodi@users.noreply.github.com>
Date: Thu, 6 Jul 2023 01:45:01 +0200
Subject: [PATCH] refactor display when kindlegen is missing
display_kindlegen_missing
---
README.md | 8 ++++---
kindlecomicconverter/KCC_gui.py | 40 ++++++++++++++++-----------------
2 files changed, 25 insertions(+), 23 deletions(-)
diff --git a/README.md b/README.md
index 92ba2417..1e25eb9f 100644
--- a/README.md
+++ b/README.md
@@ -67,9 +67,11 @@ $ sudo apt-get install -y python3 python3-dev libpng-dev libjpeg-dev p7zip-full
$ sudo apt-get install qt5dxcb-plugin
```
-- KindleGen ~~[deprecated link](http://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000765211)~~ v2.9+ in a directory reachable by your _PATH_ or in _KCC_ directory *(For MOBI generation)
- - It can be found in [Kindle Previewer](https://www.amazon.com/Kindle-Previewer/b?ie=UTF8&node=21381691011)
- `Amazon Kindle Previewer 3 Folder\lib\fc\bin`, the usual location in windows is in windows is `C:\Users\user\AppData\Local\Amazon\Kindle Previewer 3\lib\fc\bin\`
+- KindleGen ~~[(deprecated link)](http://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000765211)~~ v2.9+ (For MOBI generation)
+ - should be placed in a directory reachable by your _PATH_ or in _KCC_ directory
+ - `KindleGen` can be found in [Kindle Previewer](https://www.amazon.com/Kindle-Previewer/b?ie=UTF8&node=21381691011)
+ `Amazon Kindle Previewer 3 Folder\lib\fc\bin`, the usual location in windows is in windows is `C:\Users\user\AppData\Local\Amazon\Kindle Previewer 3\lib\fc\bin\`
+ - `KindleGen` can be also be found in [Kindle Comic Creator](https://www.amazon.com/b?node=23496309011)
- [7z](http://www.7-zip.org/download.html) *(For CBZ/ZIP, CBR/RAR, 7z/CB7 support)*
- Unrar (no rar in 7z on Fedora)
diff --git a/kindlecomicconverter/KCC_gui.py b/kindlecomicconverter/KCC_gui.py
index e2392770..212c9720 100644
--- a/kindlecomicconverter/KCC_gui.py
+++ b/kindlecomicconverter/KCC_gui.py
@@ -743,18 +743,25 @@ def convertStart(self):
self.detectKindleGen()
if not self.kindleGen:
GUI.jobList.clear()
- self.addMessage('Cannot find KindleGen! MOBI conversion is unavailable!', 'error')
- if sys.platform.startswith('win'):
- self.addMessage('Download it and place EXE in KCC directory.', 'error')
- elif sys.platform.startswith('darwin'):
- self.addMessage('Install it using Homebrew.', 'error')
- else:
- self.addMessage('Download it and place executable in /usr/local/bin directory.', 'error')
+ self.display_kindlegen_missing()
self.needClean = True
return
self.worker.start()
+ def display_kindlegen_missing(self):
+ self.addMessage('Cannot find KindleGen from '
+ 'Kindle Comic Creator or '
+ ''
+ 'Kindle Previewer! MOBI conversion is unavailable!', 'error')
+ if sys.platform.startswith('win'):
+ self.addMessage('Download it and place EXE in KCC directory.', 'error')
+ elif sys.platform.startswith('darwin'):
+ self.addMessage(''
+ 'Install the kindle-comic-creator cask using Homebrew to enable MOBI conversion',
+ 'error')
+ else:
+ self.addMessage('Download it and place executable in /usr/local/bin directory.', 'error')
+
def saveSettings(self, event):
if self.conversionAlive:
GUI.convertButton.setEnabled(False)
@@ -848,22 +855,15 @@ def detectKindleGen(self, startup=False):
if 'Amazon kindlegen' in line:
versionCheck = line.split('V')[1].split(' ')[0]
if StrictVersion(versionCheck) < StrictVersion('2.9'):
- self.addMessage('Your KindleGen is outdated! MOBI conversion might fail.', 'warning')
+ self.addMessage('Your KindleGen'
+ ' is outdated! MOBI conversion might fail.', 'warning')
break
else:
self.kindleGen = False
if startup:
- self.addMessage('Cannot find '
- 'KindleGen! MOBI conversion will be unavailable!', 'error')
- if sys.platform.startswith('win'):
- self.addMessage('Download it and place EXE in KCC directory.', 'error')
- elif sys.platform.startswith('darwin'):
- self.addMessage('Install it using Homebrew: '
- 'brew install --cask kindle-comic-creator or '
- 'brew install --cask kindle-previewer', 'error')
- else:
- self.addMessage('Download it and place executable in /usr/local/bin directory.', 'error')
+ self.display_kindlegen_missing()
+
+
def __init__(self, kccapp, kccwindow):
global APP, MW, GUI