mirror of
https://github.com/ciromattia/kcc
synced 2025-12-13 01:36:27 +00:00
fix p7zip-rar error and files with ' or " by using arg lists instead of strings (#633)
* Revert "Revert "fix files with ' or " by using arg lists instead of strings (#581)" (#628)"
This reverts commit b528dab711.
* handle FileNotFoundError
* modify unar handling
* remove unneeded utf-8 encoding
* dont uft-8 encode 7z
* remove utf-8 encoding from 7z calls
* don't extract stderr
* add extraction error
* edit error message
* remove debug
* remove kindlegen location from GUI
* remove comment
This commit is contained in:
@@ -38,7 +38,7 @@ from natsort import os_sorted
|
||||
from slugify import slugify as slugify_ext
|
||||
from PIL import Image
|
||||
from subprocess import STDOUT, PIPE
|
||||
from psutil import Popen, virtual_memory, disk_usage
|
||||
from psutil import virtual_memory, disk_usage
|
||||
from html import escape as hescape
|
||||
try:
|
||||
from PyQt5 import QtCore
|
||||
@@ -1103,15 +1103,15 @@ def checkTools(source):
|
||||
source = source.upper()
|
||||
if source.endswith('.CB7') or source.endswith('.7Z') or source.endswith('.RAR') or source.endswith('.CBR') or \
|
||||
source.endswith('.ZIP') or source.endswith('.CBZ'):
|
||||
process = Popen('7z', stdout=PIPE, stderr=STDOUT, stdin=PIPE, shell=True)
|
||||
process.communicate()
|
||||
if process.returncode != 0 and process.returncode != 7:
|
||||
try:
|
||||
subprocess.run(['7z'], stdout=PIPE, stderr=STDOUT)
|
||||
except FileNotFoundError:
|
||||
print('ERROR: 7z is missing!')
|
||||
sys.exit(1)
|
||||
if options.format == 'MOBI':
|
||||
kindleGenExitCode = Popen('kindlegen -locale en', stdout=PIPE, stderr=STDOUT, stdin=PIPE, shell=True)
|
||||
kindleGenExitCode.communicate()
|
||||
if kindleGenExitCode.returncode != 0:
|
||||
try:
|
||||
subprocess.run(['kindlegen', '-locale', 'en'], stdout=PIPE, stderr=STDOUT)
|
||||
except FileNotFoundError:
|
||||
print('ERROR: KindleGen is missing!')
|
||||
sys.exit(1)
|
||||
|
||||
@@ -1267,10 +1267,9 @@ def makeMOBIWorker(item):
|
||||
kindlegenError = ''
|
||||
try:
|
||||
if os.path.getsize(item) < 629145600:
|
||||
output = Popen('kindlegen -dont_append_source -locale en "' + item + '"',
|
||||
stdout=PIPE, stderr=STDOUT, stdin=PIPE, shell=True)
|
||||
for line in output.stdout:
|
||||
line = line.decode('utf-8')
|
||||
output = subprocess.run(['kindlegen', '-dont_append_source', '-locale', 'en', item],
|
||||
stdout=PIPE, stderr=STDOUT, encoding='UTF-8')
|
||||
for line in output.stdout.splitlines():
|
||||
# ERROR: Generic error
|
||||
if "Error(" in line:
|
||||
kindlegenErrorCode = 1
|
||||
@@ -1281,7 +1280,6 @@ def makeMOBIWorker(item):
|
||||
if kindlegenErrorCode > 0:
|
||||
break
|
||||
if ":I1036: Mobi file built successfully" in line:
|
||||
output.communicate()
|
||||
break
|
||||
else:
|
||||
# ERROR: EPUB too big
|
||||
|
||||
Reference in New Issue
Block a user