1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-13 01:36:27 +00:00

Miscellaneous tweaks

This commit is contained in:
Paweł Jastrzębski
2015-10-29 17:12:56 +01:00
parent 7305ccffc5
commit 7d81de6834
7 changed files with 60 additions and 59 deletions

View File

@@ -85,8 +85,8 @@ Options:
-t TITLE, --title=TITLE -t TITLE, --title=TITLE
Comic title [Default=filename or directory name] Comic title [Default=filename or directory name]
-f FORMAT, --format=FORMAT -f FORMAT, --format=FORMAT
Output format (Available options: Auto, MOBI, EPUB, Output format (Available options: Auto, MOBI, EPUB, CBZ)
CBZ) [Default=Auto] [Default=Auto]
-b, --batchsplit Split output into multiple files -b, --batchsplit Split output into multiple files
PROCESSING: PROCESSING:

View File

@@ -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\Additional-LICENSE.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "other\windows\UnRAR.exe"; 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\7za.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "other\windows\vc_redist.x64.exe"; DestDir: "{tmp}"; Flags: ignoreversion deleteafterinstall
[Icons] [Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" 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 Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
[Run] [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 Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall
[Messages] [Messages]

View File

@@ -184,7 +184,7 @@ class VersionThread(QtCore.QThread):
move(path[0], path[0] + '.exe') move(path[0], path[0] + '.exe')
MW.hideProgressBar.emit() MW.hideProgressBar.emit()
MW.modeConvert.emit(1) 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() MW.forceShutdown.emit()
except Exception: except Exception:
MW.addMessage.emit('Failed to download update!', 'warning', False) 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) os.chmod('/usr/local/bin/kindlegen', 0o755)
except Exception: except Exception:
pass 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: if kindleGenExitCode.wait() == 0:
self.kindleGen = True 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: for line in versionCheck.stdout:
line = line.decode("utf-8") line = line.decode("utf-8")
if 'Amazon kindlegen' in line: if 'Amazon kindlegen' in line:
@@ -1003,7 +1003,7 @@ class KCCGUI(KCC_ui.Ui_KCC):
self.addMessage('Since you are new user of <b>KCC</b> please see few ' self.addMessage('Since you are new user of <b>KCC</b> please see few '
'<a href="https://github.com/ciromattia/kcc/wiki/Important-tips">important tips</a>.', '<a href="https://github.com/ciromattia/kcc/wiki/Important-tips">important tips</a>.',
'info') 'info')
rarExitCode = Popen('unrar', stdout=PIPE, stderr=STDOUT, shell=True) rarExitCode = Popen('unrar', stdout=PIPE, stderr=STDOUT, stdin=PIPE, shell=True)
rarExitCode = rarExitCode.wait() rarExitCode = rarExitCode.wait()
if rarExitCode == 0 or rarExitCode == 7: if rarExitCode == 0 or rarExitCode == 7:
self.UnRAR = True self.UnRAR = True
@@ -1011,7 +1011,7 @@ class KCCGUI(KCC_ui.Ui_KCC):
self.UnRAR = False self.UnRAR = False
self.addMessage('Cannot find <a href="http://www.rarlab.com/rar_add.htm">UnRAR</a>!' self.addMessage('Cannot find <a href="http://www.rarlab.com/rar_add.htm">UnRAR</a>!'
' Processing of CBR/RAR files will be disabled.', 'warning') ' 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() sevenzaExitCode = sevenzaExitCode.wait()
if sevenzaExitCode == 0 or sevenzaExitCode == 7: if sevenzaExitCode == 0 or sevenzaExitCode == 7:
self.sevenza = True self.sevenza = True

View File

@@ -74,7 +74,7 @@ class CBxArchive:
copy(self.origFileName, os.path.join(os.path.dirname(self.origFileName), 'TMP_KCC_TMP')) 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') 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"' + 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 extracted = False
for line in output.stdout: for line in output.stdout:
if b"Everything is Ok" in line: if b"Everything is Ok" in line:

View File

@@ -570,13 +570,13 @@ def getWorkFolder(afile):
except: except:
rmtree(workdir, True) rmtree(workdir, True)
raise UserWarning("Failed to prepare a workspace.") 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) pdf = pdfjpgextract.PdfJpgExtract(afile)
path, njpg = pdf.extract() path, njpg = pdf.extract()
if njpg == 0: if njpg == 0:
rmtree(path, True) rmtree(path, True)
raise UserWarning("Failed to extract images from PDF file.") raise UserWarning("Failed to extract images from PDF file.")
else: elif os.path.isfile(afile):
workdir = mkdtemp('', 'KCC-') workdir = mkdtemp('', 'KCC-')
cbx = cbxarchive.CBxArchive(afile) cbx = cbxarchive.CBxArchive(afile)
if cbx.isCbxFile(): if cbx.isCbxFile():
@@ -588,6 +588,8 @@ def getWorkFolder(afile):
else: else:
rmtree(workdir, True) rmtree(workdir, True)
raise UserWarning("Failed to detect archive format.") raise UserWarning("Failed to detect archive format.")
else:
raise UserWarning("Failed to open source file/directory.")
newpath = mkdtemp('', 'KCC-') newpath = mkdtemp('', 'KCC-')
copytree(path, os.path.join(newpath, 'OEBPS', 'Images')) copytree(path, os.path.join(newpath, 'OEBPS', 'Images'))
rmtree(path, True) rmtree(path, True)
@@ -1064,19 +1066,19 @@ def checkOptions():
def checkTools(source): def checkTools(source):
source = source.upper() source = source.upper()
if source.endswith('.CBR') or source.endswith('.RAR'): 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() rarExitCode = rarExitCode.wait()
if rarExitCode != 0 and rarExitCode != 7: if rarExitCode != 0 and rarExitCode != 7:
print('ERROR: UnRAR is missing!') print('ERROR: UnRAR is missing!')
exit(1) exit(1)
elif source.endswith('.CB7') or source.endswith('.7Z'): 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() sevenzaExitCode = sevenzaExitCode.wait()
if sevenzaExitCode != 0 and sevenzaExitCode != 7: if sevenzaExitCode != 0 and sevenzaExitCode != 7:
print('ERROR: 7za is missing!') print('ERROR: 7za is missing!')
exit(1) exit(1)
if options.format == 'MOBI': 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: if kindleGenExitCode.wait() != 0:
print('ERROR: KindleGen is missing!') print('ERROR: KindleGen is missing!')
exit(1) exit(1)
@@ -1224,7 +1226,7 @@ def makeMOBIWorker(item):
try: try:
if os.path.getsize(item) < 629145600: if os.path.getsize(item) < 629145600:
output = Popen('kindlegen -dont_append_source -locale en "' + item + '"', 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: for line in output.stdout:
line = line.decode('utf-8') line = line.decode('utf-8')
# ERROR: Generic error # ERROR: Generic error

View File

@@ -254,8 +254,8 @@ class ComicPage:
self.targetPath += '.jpg' self.targetPath += '.jpg'
self.image.save(self.targetPath, 'JPEG', optimize=1, quality=80) self.image.save(self.targetPath, 'JPEG', optimize=1, quality=80)
return [md5Checksum(self.targetPath), flags, self.orgPath] return [md5Checksum(self.targetPath), flags, self.orgPath]
except IOError as e: except IOError:
raise RuntimeError('Cannot write image in directory %s: %s' % (targetdir, e)) raise RuntimeError('Cannot save image.')
def autocontrastImage(self): def autocontrastImage(self):
gamma = self.opt.gamma gamma = self.opt.gamma

View File

@@ -68,7 +68,7 @@ class MetadataParser:
workdir = mkdtemp('', 'KCC-') workdir = mkdtemp('', 'KCC-')
tmpXML = os.path.join(workdir, 'ComicInfo.xml') tmpXML = os.path.join(workdir, 'ComicInfo.xml')
output = Popen('7za e "' + self.source + '" ComicInfo.xml -o"' + workdir + '"', 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 extracted = False
for line in output.stdout: for line in output.stdout:
if b"Everything is Ok" in line or b"No files to process" in line: 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): elif rarfile.is_rarfile(self.source):
raise NotImplementedError raise NotImplementedError
elif is_7zfile(self.source): 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 extracted = False
for line in output.stdout: for line in output.stdout:
if b"Everything is Ok" in line: if b"Everything is Ok" in line: