diff --git a/README.md b/README.md
index f6965b6..2a97d61 100644
--- a/README.md
+++ b/README.md
@@ -69,48 +69,48 @@ CLI version of **KCC** is intended for power users. It is not idiot-proof like G
### Standalone `kcc-c2e.py` usage:
```
-Usage: kcc-c2e [options] comic_file|comic_folder
-
-Options:
- MAIN:
- -p PROFILE, --profile=PROFILE
+Usage: kcc-c2e [options] comic_file|comic_folder
+
+Options:
+ MAIN:
+ -p PROFILE, --profile=PROFILE
Device profile (Available options: K1, K2, K345, KDX,
- KPW, KV, KoMT, KoG, KoGHD, KoA, KoAHD, KoAH2O) [Default=KV]
- -m, --manga-style Manga style (right-to-left reading and splitting)
- -w, --webtoon Webtoon processing mode
-
- OUTPUT SETTINGS:
- -o OUTPUT, --output=OUTPUT
- Output generated file to specified directory or file
- -t TITLE, --title=TITLE
- Comic title [Default=filename or directory name]
- -f FORMAT, --format=FORMAT
- Output format (Available options: Auto, MOBI, EPUB,
- CBZ) [Default=Auto]
- -b, --batchsplit Split output into multiple files
-
- PROCESSING:
- -u, --upscale Resize images smaller than device's resolution
- -s, --stretch Stretch images to device's resolution
- -r SPLITTER, --splitter=SPLITTER
- Double page parsing mode. 0: Split 1: Rotate 2: Both [Default=0]
- -g GAMMA, --gamma=GAMMA
- Apply gamma correction to linearize the image [Default=Auto]
- --hq Enable high quality Panel View
- --blackborders Disable autodetection and force black borders
- --whiteborders Disable autodetection and force white borders
- --forcecolor Don't convert images to grayscale
- --forcepng Create PNG files instead JPEG
- --nocutpagenumbers Don't try to cut page numbers from images
-
- CUSTOM PROFILE:
- --customwidth=CUSTOMWIDTH
- Replace screen width provided by device profile
- --customheight=CUSTOMHEIGHT
- Replace screen height provided by device profile
-
- OTHER:
- -h, --help Show this help message and exit
+ KPW, KV, KoMT, KoG, KoGHD, KoA, KoAHD, KoAH2O) [Default=KV]
+ -m, --manga-style Manga style (right-to-left reading and splitting)
+ -w, --webtoon Webtoon processing mode
+
+ OUTPUT SETTINGS:
+ -o OUTPUT, --output=OUTPUT
+ Output generated file to specified directory or file
+ -t TITLE, --title=TITLE
+ Comic title [Default=filename or directory name]
+ -f FORMAT, --format=FORMAT
+ Output format (Available options: Auto, MOBI, EPUB, CBZ)
+ [Default=Auto]
+ -b, --batchsplit Split output into multiple files
+
+ PROCESSING:
+ -u, --upscale Resize images smaller than device's resolution
+ -s, --stretch Stretch images to device's resolution
+ -r SPLITTER, --splitter=SPLITTER
+ Double page parsing mode. 0: Split 1: Rotate 2: Both [Default=0]
+ -g GAMMA, --gamma=GAMMA
+ Apply gamma correction to linearize the image [Default=Auto]
+ --hq Enable high quality Panel View
+ --blackborders Disable autodetection and force black borders
+ --whiteborders Disable autodetection and force white borders
+ --forcecolor Don't convert images to grayscale
+ --forcepng Create PNG files instead JPEG
+ --nocutpagenumbers Don't try to cut page numbers from images
+
+ CUSTOM PROFILE:
+ --customwidth=CUSTOMWIDTH
+ Replace screen width provided by device profile
+ --customheight=CUSTOMHEIGHT
+ Replace screen height provided by device profile
+
+ OTHER:
+ -h, --help Show this help message and exit
```
### Standalone `kcc-c2p.py` usage:
diff --git a/kcc.iss b/kcc.iss
index 054a5e4..501a72e 100644
--- a/kcc.iss
+++ b/kcc.iss
@@ -48,7 +48,6 @@ Source: "LICENSE.txt"; DestDir: "{app}"; Flags: ignoreversion solidbreak
Source: "other\windows\Additional-LICENSE.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "other\windows\UnRAR.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "other\windows\7za.exe"; DestDir: "{app}"; Flags: ignoreversion
-Source: "other\windows\vc_redist.x64.exe"; DestDir: "{tmp}"; Flags: ignoreversion deleteafterinstall
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
@@ -56,7 +55,6 @@ Name: "{group}\Readme"; Filename: "https://github.com/ciromattia/kcc#kcc"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
[Run]
-Filename: "{tmp}\vc_redist.x64.exe"; Parameters: "/quiet"; StatusMsg: "Installing Microsoft Visual C++ 2015 Redistributable Package..."
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall
[Messages]
diff --git a/kcc/KCC_gui.py b/kcc/KCC_gui.py
index 56fea24..be36490 100644
--- a/kcc/KCC_gui.py
+++ b/kcc/KCC_gui.py
@@ -184,7 +184,7 @@ class VersionThread(QtCore.QThread):
move(path[0], path[0] + '.exe')
MW.hideProgressBar.emit()
MW.modeConvert.emit(1)
- Popen(path[0] + '.exe /SP- /silent /noicons')
+ Popen(path[0] + '.exe /SP- /silent /noicons', stdout=PIPE, stderr=STDOUT, stdin=PIPE, shell=True)
MW.forceShutdown.emit()
except Exception:
MW.addMessage.emit('Failed to download update!', 'warning', False)
@@ -865,10 +865,10 @@ class KCCGUI(KCC_ui.Ui_KCC):
os.chmod('/usr/local/bin/kindlegen', 0o755)
except Exception:
pass
- kindleGenExitCode = Popen('kindlegen -locale en', stdout=PIPE, stderr=STDOUT, shell=True)
+ kindleGenExitCode = Popen('kindlegen -locale en', stdout=PIPE, stderr=STDOUT, stdin=PIPE, shell=True)
if kindleGenExitCode.wait() == 0:
self.kindleGen = True
- versionCheck = Popen('kindlegen -locale en', stdout=PIPE, stderr=STDOUT, shell=True)
+ versionCheck = Popen('kindlegen -locale en', stdout=PIPE, stderr=STDOUT, stdin=PIPE, shell=True)
for line in versionCheck.stdout:
line = line.decode("utf-8")
if 'Amazon kindlegen' in line:
@@ -1003,7 +1003,7 @@ class KCCGUI(KCC_ui.Ui_KCC):
self.addMessage('Since you are new user of KCC please see few '
'important tips.',
'info')
- rarExitCode = Popen('unrar', stdout=PIPE, stderr=STDOUT, shell=True)
+ rarExitCode = Popen('unrar', stdout=PIPE, stderr=STDOUT, stdin=PIPE, shell=True)
rarExitCode = rarExitCode.wait()
if rarExitCode == 0 or rarExitCode == 7:
self.UnRAR = True
@@ -1011,7 +1011,7 @@ class KCCGUI(KCC_ui.Ui_KCC):
self.UnRAR = False
self.addMessage('Cannot find UnRAR!'
' Processing of CBR/RAR files will be disabled.', 'warning')
- sevenzaExitCode = Popen('7za', stdout=PIPE, stderr=STDOUT, shell=True)
+ sevenzaExitCode = Popen('7za', stdout=PIPE, stderr=STDOUT, stdin=PIPE, shell=True)
sevenzaExitCode = sevenzaExitCode.wait()
if sevenzaExitCode == 0 or sevenzaExitCode == 7:
self.sevenza = True
diff --git a/kcc/cbxarchive.py b/kcc/cbxarchive.py
index 97c26ba..f802b91 100644
--- a/kcc/cbxarchive.py
+++ b/kcc/cbxarchive.py
@@ -74,7 +74,7 @@ class CBxArchive:
copy(self.origFileName, os.path.join(os.path.dirname(self.origFileName), 'TMP_KCC_TMP'))
self.origFileName = os.path.join(os.path.dirname(self.origFileName), 'TMP_KCC_TMP')
output = Popen('7za x "' + self.origFileName + '" -xr!__MACOSX -xr!.DS_Store -xr!thumbs.db -xr!Thumbs.db -o"' +
- targetdir + '"', stdout=PIPE, stderr=STDOUT, shell=True)
+ targetdir + '"', stdout=PIPE, stderr=STDOUT, stdin=PIPE, shell=True)
extracted = False
for line in output.stdout:
if b"Everything is Ok" in line:
diff --git a/kcc/comic2ebook.py b/kcc/comic2ebook.py
index adc3d0a..69ea6b5 100755
--- a/kcc/comic2ebook.py
+++ b/kcc/comic2ebook.py
@@ -570,13 +570,13 @@ def getWorkFolder(afile):
except:
rmtree(workdir, True)
raise UserWarning("Failed to prepare a workspace.")
- elif afile.lower().endswith('.pdf'):
+ elif os.path.isfile(afile) and afile.lower().endswith('.pdf'):
pdf = pdfjpgextract.PdfJpgExtract(afile)
path, njpg = pdf.extract()
if njpg == 0:
rmtree(path, True)
raise UserWarning("Failed to extract images from PDF file.")
- else:
+ elif os.path.isfile(afile):
workdir = mkdtemp('', 'KCC-')
cbx = cbxarchive.CBxArchive(afile)
if cbx.isCbxFile():
@@ -588,6 +588,8 @@ def getWorkFolder(afile):
else:
rmtree(workdir, True)
raise UserWarning("Failed to detect archive format.")
+ else:
+ raise UserWarning("Failed to open source file/directory.")
newpath = mkdtemp('', 'KCC-')
copytree(path, os.path.join(newpath, 'OEBPS', 'Images'))
rmtree(path, True)
@@ -1064,19 +1066,19 @@ def checkOptions():
def checkTools(source):
source = source.upper()
if source.endswith('.CBR') or source.endswith('.RAR'):
- rarExitCode = Popen('unrar', stdout=PIPE, stderr=STDOUT, shell=True)
+ rarExitCode = Popen('unrar', stdout=PIPE, stderr=STDOUT, stdin=PIPE, shell=True)
rarExitCode = rarExitCode.wait()
if rarExitCode != 0 and rarExitCode != 7:
print('ERROR: UnRAR is missing!')
exit(1)
elif source.endswith('.CB7') or source.endswith('.7Z'):
- sevenzaExitCode = Popen('7za', stdout=PIPE, stderr=STDOUT, shell=True)
+ sevenzaExitCode = Popen('7za', stdout=PIPE, stderr=STDOUT, stdin=PIPE, shell=True)
sevenzaExitCode = sevenzaExitCode.wait()
if sevenzaExitCode != 0 and sevenzaExitCode != 7:
print('ERROR: 7za is missing!')
exit(1)
if options.format == 'MOBI':
- kindleGenExitCode = Popen('kindlegen -locale en', stdout=PIPE, stderr=STDOUT, shell=True)
+ kindleGenExitCode = Popen('kindlegen -locale en', stdout=PIPE, stderr=STDOUT, stdin=PIPE, shell=True)
if kindleGenExitCode.wait() != 0:
print('ERROR: KindleGen is missing!')
exit(1)
@@ -1224,7 +1226,7 @@ def makeMOBIWorker(item):
try:
if os.path.getsize(item) < 629145600:
output = Popen('kindlegen -dont_append_source -locale en "' + item + '"',
- stdout=PIPE, stderr=STDOUT, shell=True)
+ stdout=PIPE, stderr=STDOUT, stdin=PIPE, shell=True)
for line in output.stdout:
line = line.decode('utf-8')
# ERROR: Generic error
diff --git a/kcc/image.py b/kcc/image.py
index 6dd4d98..2126af2 100755
--- a/kcc/image.py
+++ b/kcc/image.py
@@ -254,8 +254,8 @@ class ComicPage:
self.targetPath += '.jpg'
self.image.save(self.targetPath, 'JPEG', optimize=1, quality=80)
return [md5Checksum(self.targetPath), flags, self.orgPath]
- except IOError as e:
- raise RuntimeError('Cannot write image in directory %s: %s' % (targetdir, e))
+ except IOError:
+ raise RuntimeError('Cannot save image.')
def autocontrastImage(self):
gamma = self.opt.gamma
diff --git a/kcc/metadata.py b/kcc/metadata.py
index da57e12..60d19cf 100644
--- a/kcc/metadata.py
+++ b/kcc/metadata.py
@@ -68,7 +68,7 @@ class MetadataParser:
workdir = mkdtemp('', 'KCC-')
tmpXML = os.path.join(workdir, 'ComicInfo.xml')
output = Popen('7za e "' + self.source + '" ComicInfo.xml -o"' + workdir + '"',
- stdout=PIPE, stderr=STDOUT, shell=True)
+ stdout=PIPE, stderr=STDOUT, stdin=PIPE, shell=True)
extracted = False
for line in output.stdout:
if b"Everything is Ok" in line or b"No files to process" in line:
@@ -161,7 +161,8 @@ class MetadataParser:
elif rarfile.is_rarfile(self.source):
raise NotImplementedError
elif is_7zfile(self.source):
- output = Popen('7za a "' + self.source + '" "' + tmpXML + '"', stdout=PIPE, stderr=STDOUT, shell=True)
+ output = Popen('7za a "' + self.source + '" "' + tmpXML + '"',
+ stdout=PIPE, stderr=STDOUT, stdin=PIPE, shell=True)
extracted = False
for line in output.stdout:
if b"Everything is Ok" in line: