mirror of
https://github.com/ciromattia/kcc
synced 2025-12-12 17:26:23 +00:00
Code cleanup
This commit is contained in:
@@ -28,4 +28,4 @@ from kindlecomicconverter.startup import startC2P
|
||||
|
||||
if __name__ == "__main__":
|
||||
freeze_support()
|
||||
startC2P()
|
||||
startC2P()
|
||||
|
||||
2
kcc.py
2
kcc.py
@@ -39,7 +39,7 @@ elif sys.platform.startswith('win'):
|
||||
class _Popen(forking.Popen):
|
||||
def __init__(self, *args, **kw):
|
||||
if hasattr(sys, 'frozen'):
|
||||
# noinspection PyProtectedMember
|
||||
# noinspection PyUnresolvedReferences,PyProtectedMember
|
||||
os.putenv('_MEIPASS2', sys._MEIPASS)
|
||||
try:
|
||||
super(_Popen, self).__init__(*args, **kw)
|
||||
|
||||
@@ -533,8 +533,8 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
|
||||
def clearJobs(self):
|
||||
GUI.jobList.clear()
|
||||
|
||||
# noinspection PyCallByClass,PyTypeChecker
|
||||
def openWiki(self):
|
||||
# noinspection PyCallByClass
|
||||
QtGui.QDesktopServices.openUrl(QtCore.QUrl('https://github.com/ciromattia/kcc/wiki'))
|
||||
|
||||
def modeChange(self, mode):
|
||||
|
||||
@@ -16,12 +16,11 @@
|
||||
# PERFORMANCE OF THIS SOFTWARE.
|
||||
#
|
||||
|
||||
import sys
|
||||
import os
|
||||
from zipfile import is_zipfile, ZipFile
|
||||
from subprocess import STDOUT, PIPE
|
||||
from psutil import Popen
|
||||
from shutil import move, copy
|
||||
from shutil import move
|
||||
from . import rarfile
|
||||
from .shared import check7ZFile as is_7zfile
|
||||
|
||||
|
||||
@@ -259,7 +259,8 @@ def main(argv=None, qtGUI=None):
|
||||
raise UserWarning("Conversion interrupted.")
|
||||
if len(mergeWorkerOutput) > 0:
|
||||
rmtree(options.targetDir, True)
|
||||
raise RuntimeError("One of workers crashed. Cause: " + mergeWorkerOutput[0][0], mergeWorkerOutput[0][1])
|
||||
raise RuntimeError("One of workers crashed. Cause: " + mergeWorkerOutput[0][0],
|
||||
mergeWorkerOutput[0][1])
|
||||
print("Splitting images...")
|
||||
for root, _, files in os.walk(options.targetDir, False):
|
||||
for name in files:
|
||||
@@ -282,7 +283,8 @@ def main(argv=None, qtGUI=None):
|
||||
raise UserWarning("Conversion interrupted.")
|
||||
if len(splitWorkerOutput) > 0:
|
||||
rmtree(options.targetDir, True)
|
||||
raise RuntimeError("One of workers crashed. Cause: " + splitWorkerOutput[0][0], splitWorkerOutput[0][1])
|
||||
raise RuntimeError("One of workers crashed. Cause: " + splitWorkerOutput[0][0],
|
||||
splitWorkerOutput[0][1])
|
||||
if options.inPlace:
|
||||
rmtree(options.sourceDir)
|
||||
move(options.targetDir, options.sourceDir)
|
||||
|
||||
@@ -17,11 +17,9 @@
|
||||
#
|
||||
|
||||
import os
|
||||
from sys import version_info
|
||||
from hashlib import md5
|
||||
from html.parser import HTMLParser
|
||||
from distutils.version import StrictVersion
|
||||
from time import sleep
|
||||
from shutil import rmtree, copy
|
||||
from tempfile import mkdtemp
|
||||
from zipfile import ZipFile, ZIP_DEFLATED
|
||||
|
||||
@@ -23,6 +23,7 @@ import sys
|
||||
from . import __version__
|
||||
from .shared import dependencyCheck
|
||||
|
||||
|
||||
def start():
|
||||
dependencyCheck(3)
|
||||
from . import KCC_gui
|
||||
@@ -40,14 +41,16 @@ def start():
|
||||
KCCUI.handleMessage(sys.argv[1])
|
||||
sys.exit(KCCAplication.exec_())
|
||||
|
||||
|
||||
def startC2E():
|
||||
dependencyCheck(2)
|
||||
from .comic2ebook import main
|
||||
print('comic2ebook v' + __version__ + ' - Written by Ciro Mattia Gonano and Pawel Jastrzebski.')
|
||||
sys.exit(main(sys.argv[1:]))
|
||||
|
||||
|
||||
def startC2P():
|
||||
dependencyCheck(1)
|
||||
from .comic2panel import main
|
||||
print('comic2panel v' + __version__ + ' - Written by Ciro Mattia Gonano and Pawel Jastrzebski.')
|
||||
sys.exit(main(sys.argv[1:]))
|
||||
sys.exit(main(sys.argv[1:]))
|
||||
|
||||
22
setup.py
22
setup.py
@@ -2,10 +2,10 @@
|
||||
"""
|
||||
pip/pyinstaller build script for KCC.
|
||||
|
||||
Usage (Windows):
|
||||
py -3 setup.py build_binary
|
||||
Install as Python package:
|
||||
python3 setup.py install
|
||||
|
||||
Usage (Linux/OS X):
|
||||
Create EXE/APP/DEB:
|
||||
python3 setup.py build_binary
|
||||
"""
|
||||
|
||||
@@ -14,32 +14,22 @@ import sys
|
||||
import shutil
|
||||
import setuptools
|
||||
import distutils.cmd
|
||||
from distutils.command.build import build
|
||||
from kindlecomicconverter import __version__
|
||||
|
||||
NAME = 'KindleComicConverter'
|
||||
MAIN = 'kcc.py'
|
||||
VERSION = __version__
|
||||
|
||||
|
||||
class BuildBinaryCommand(distutils.cmd.Command):
|
||||
description = 'build binary release'
|
||||
user_options = [
|
||||
('pyz', None, 'build PYZ package'),
|
||||
]
|
||||
|
||||
def initialize_options(self):
|
||||
# noinspection PyAttributeOutsideInit
|
||||
self.pyz = False
|
||||
|
||||
def finalize_options(self):
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
if sys.platform == 'darwin':
|
||||
if os.path.isfile('Kindle Comic Converter.spec'):
|
||||
os.system('pyinstaller "Kindle Comic Converter.spec"')
|
||||
else:
|
||||
os.system('pyinstaller -y -F -i icons/comic2ebook.icns -n "Kindle Comic Converter" -w -s --noupx kcc.py')
|
||||
os.system('pyinstaller -y -F -i icons/comic2ebook.icns -n "Kindle Comic Converter" -w -s kcc.py')
|
||||
shutil.copy('other/osx/7za', 'dist/Kindle Comic Converter.app/Contents/Resources')
|
||||
shutil.copy('other/osx/unrar', 'dist/Kindle Comic Converter.app/Contents/Resources')
|
||||
shutil.copy('other/osx/Info.plist', 'dist/Kindle Comic Converter.app/Contents')
|
||||
@@ -92,6 +82,6 @@ setuptools.setup(
|
||||
'python-slugify>=1.2.1',
|
||||
'raven>=6.0.0',
|
||||
],
|
||||
classifiers = [],
|
||||
classifiers=[],
|
||||
zip_safe=False,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user