mirror of
https://github.com/ciromattia/kcc
synced 2025-12-15 18:56:28 +00:00
Added MANIFEST.in, ugly fix for OSX not evaluating user local $PATH on app launched from Finder.
This commit is contained in:
1
MANIFEST.in
Normal file
1
MANIFEST.in
Normal file
@@ -0,0 +1 @@
|
|||||||
|
include README.md MANIFEST.in LICENSE.txt
|
||||||
@@ -107,6 +107,7 @@ and installed in `/usr/local/bin/`
|
|||||||
- Add option to gen .mobi or .epub
|
- Add option to gen .mobi or .epub
|
||||||
- Validate ePub
|
- Validate ePub
|
||||||
- Make window take focus on app launch
|
- Make window take focus on app launch
|
||||||
|
- [OSX] Finder-launched app does not take into account user local $PATH
|
||||||
|
|
||||||
## COPYRIGHT
|
## COPYRIGHT
|
||||||
|
|
||||||
|
|||||||
4
kcc.py
4
kcc.py
@@ -38,7 +38,11 @@ __docformat__ = 'restructuredtext en'
|
|||||||
|
|
||||||
from Tkinter import *
|
from Tkinter import *
|
||||||
from kcc import gui
|
from kcc import gui
|
||||||
|
from sys import platform
|
||||||
|
import os
|
||||||
|
|
||||||
|
if platform == 'darwin':
|
||||||
|
os.environ['PATH'] = '/usr/local/bin:' + os.environ['PATH']
|
||||||
root = Tk()
|
root = Tk()
|
||||||
app = gui.MainWindow(master=root,title="Kindle Comic Converter v" + __version__)
|
app = gui.MainWindow(master=root,title="Kindle Comic Converter v" + __version__)
|
||||||
root.tkraise()
|
root.tkraise()
|
||||||
|
|||||||
52
kcc/gui.py
52
kcc/gui.py
@@ -24,7 +24,7 @@ from Tkinter import *
|
|||||||
import tkFileDialog, tkMessageBox, ttk
|
import tkFileDialog, tkMessageBox, ttk
|
||||||
import comic2ebook, kindlestrip
|
import comic2ebook, kindlestrip
|
||||||
from image import ProfileData
|
from image import ProfileData
|
||||||
from subprocess import call
|
from subprocess import call, Popen, PIPE, STDOUT
|
||||||
import os, shutil, stat
|
import os, shutil, stat
|
||||||
|
|
||||||
class MainWindow:
|
class MainWindow:
|
||||||
@@ -63,21 +63,21 @@ class MainWindow:
|
|||||||
|
|
||||||
def initialize(self):
|
def initialize(self):
|
||||||
self.filelocation = Listbox(self.master)
|
self.filelocation = Listbox(self.master)
|
||||||
self.filelocation.pack(fill=BOTH, expand=1)
|
self.filelocation.grid(row=0,columnspan=4,sticky=W+E+N+S)
|
||||||
self.refresh_list()
|
self.refresh_list()
|
||||||
|
|
||||||
self.clear_file = Button(self.master, text="Clear files", command=self.clear_files)
|
self.clear_file = Button(self.master, text="Clear files", command=self.clear_files)
|
||||||
self.clear_file.pack(side=LEFT)
|
self.clear_file.grid(row=4,column=0,rowspan=3)
|
||||||
self.open_file = Button(self.master, text="Add files...", command=self.open_files)
|
self.open_file = Button(self.master, text="Add files...", command=self.open_files)
|
||||||
self.open_file.pack(side=LEFT)
|
self.open_file.grid(row=4,column=1,rowspan=3)
|
||||||
self.open_folder = Button(self.master, text="Add folder...", command=self.open_folder)
|
self.open_folder = Button(self.master, text="Add folder...", command=self.open_folder)
|
||||||
self.open_folder.pack(side=LEFT)
|
self.open_folder.grid(row=4,column=2,rowspan=3)
|
||||||
|
|
||||||
self.profile = StringVar()
|
self.profile = StringVar()
|
||||||
options = sorted(ProfileData.ProfileLabels.iterkeys())
|
options = sorted(ProfileData.ProfileLabels.iterkeys())
|
||||||
self.profile.set(options[-1])
|
self.profile.set(options[-1])
|
||||||
w = apply(OptionMenu, (self.master, self.profile) + tuple(options))
|
w = apply(OptionMenu, (self.master, self.profile) + tuple(options))
|
||||||
w.pack(anchor=W,fill=BOTH)
|
w.grid(row=1,column=3)
|
||||||
|
|
||||||
self.image_preprocess = IntVar()
|
self.image_preprocess = IntVar()
|
||||||
self.image_preprocess = 1
|
self.image_preprocess = 1
|
||||||
@@ -92,25 +92,29 @@ class MainWindow:
|
|||||||
self.c = Checkbutton(self.master, text="Apply image optimizations",
|
self.c = Checkbutton(self.master, text="Apply image optimizations",
|
||||||
variable=self.image_preprocess)
|
variable=self.image_preprocess)
|
||||||
self.c.select()
|
self.c.select()
|
||||||
self.c.pack()
|
self.c.grid(row=2,column=3,sticky=W)
|
||||||
self.c = Checkbutton(self.master, text="Cut page numbers",
|
self.c = Checkbutton(self.master, text="Cut page numbers",
|
||||||
variable=self.cut_page_numbers)
|
variable=self.cut_page_numbers)
|
||||||
self.c.pack()
|
self.c.grid(row=3,column=3,sticky=W)
|
||||||
self.c = Checkbutton(self.master, text="Split manga-style (right-to-left reading)",
|
self.c = Checkbutton(self.master, text="Split manga-style (right-to-left reading)",
|
||||||
variable=self.mangastyle)
|
variable=self.mangastyle)
|
||||||
self.c.pack()
|
self.c.grid(row=4,column=3,sticky=W)
|
||||||
self.c = Checkbutton(self.master, text="Allow image upscaling",
|
self.c = Checkbutton(self.master, text="Allow image upscaling",
|
||||||
variable=self.image_upscale)
|
variable=self.image_upscale)
|
||||||
self.c.pack()
|
self.c.grid(row=5,column=3,sticky=W)
|
||||||
self.c = Checkbutton(self.master, text="Stretch images",
|
self.c = Checkbutton(self.master, text="Stretch images",
|
||||||
variable=self.image_stretch)
|
variable=self.image_stretch)
|
||||||
self.c.pack()
|
self.c.grid(row=6,column=3,sticky=W)
|
||||||
|
|
||||||
self.progressbar = ttk.Progressbar(orient=HORIZONTAL, length=200, mode='determinate')
|
self.progressbar = ttk.Progressbar(orient=HORIZONTAL, length=200, mode='determinate')
|
||||||
#now for a button
|
|
||||||
self.submit = Button(self.master, text="Execute!", command=self.start_conversion, fg="red")
|
self.submit = Button(self.master, text="Execute!", command=self.start_conversion, fg="red")
|
||||||
self.submit.pack()
|
self.submit.grid(row=7,column=3)
|
||||||
self.progressbar.pack(side=BOTTOM)
|
self.progressbar.grid(row=8,column=0,columnspan=4,sticky=W+E+N+S)
|
||||||
|
|
||||||
|
# self.debug = Listbox(self.master)
|
||||||
|
# self.debug.grid(row=9,columnspan=4,sticky=W+E+N+S)
|
||||||
|
# self.debug.insert(END, os.environ['PATH'])
|
||||||
|
|
||||||
def start_conversion(self):
|
def start_conversion(self):
|
||||||
self.progressbar.start()
|
self.progressbar.start()
|
||||||
@@ -132,18 +136,34 @@ class MainWindow:
|
|||||||
argv.append("--stretch-images")
|
argv.append("--stretch-images")
|
||||||
errors = False
|
errors = False
|
||||||
for entry in self.filelist:
|
for entry in self.filelist:
|
||||||
|
self.master.update()
|
||||||
try:
|
try:
|
||||||
subargv = list(argv)
|
subargv = list(argv)
|
||||||
subargv.append(entry)
|
subargv.append(entry)
|
||||||
comic2ebook.main(subargv)
|
comic2ebook.main(subargv)
|
||||||
path = comic2ebook.getEpubPath()
|
path = comic2ebook.getEpubPath()
|
||||||
call(['kindlegen',path + "/content.opf"])
|
except Exception, err:
|
||||||
|
tkMessageBox.showerror('Error comic2ebook', "Error on file %s:\n%s" % (subargv[-1], str(err)))
|
||||||
|
errors = True
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
retcode = call("kindlegen " + path + "/content.opf", shell=True)
|
||||||
|
if retcode < 0:
|
||||||
|
print >>sys.stderr, "Child was terminated by signal", -retcode
|
||||||
|
else:
|
||||||
|
print >>sys.stderr, "Child returned", retcode
|
||||||
|
except OSError as e:
|
||||||
|
tkMessageBox.showerror('Error kindlegen', "Error on file %s:\n%s" % (path + "/content.opf", e))
|
||||||
|
errors = True
|
||||||
|
continue
|
||||||
|
try:
|
||||||
kindlestrip.main((path + "/content.mobi", path + '.mobi'))
|
kindlestrip.main((path + "/content.mobi", path + '.mobi'))
|
||||||
# try to clean up temp files... may be destructive!!!
|
# try to clean up temp files... may be destructive!!!
|
||||||
shutil.rmtree(path, onerror=self.remove_readonly)
|
shutil.rmtree(path, onerror=self.remove_readonly)
|
||||||
except Exception, err:
|
except Exception, err:
|
||||||
tkMessageBox.showerror('Error', "Error on file %s:\n%s" % (subargv[-1], str(err)))
|
tkMessageBox.showerror('Error', "Error on file %s:\n%s" % (path + "/content.mobi", str(err)))
|
||||||
errors = True
|
errors = True
|
||||||
|
continue
|
||||||
if errors:
|
if errors:
|
||||||
tkMessageBox.showinfo(
|
tkMessageBox.showinfo(
|
||||||
"Done",
|
"Done",
|
||||||
|
|||||||
29
setup.py
29
setup.py
@@ -16,30 +16,24 @@ ez_setup.use_setuptools()
|
|||||||
import sys
|
import sys
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
|
||||||
NAME="KindleComicConverter"
|
NAME='KindleComicConverter'
|
||||||
VERSION="2.0"
|
VERSION="2.1"
|
||||||
IDENTIFIER="com.github.ciromattia.kcc"
|
mainscript = 'kcc.py'
|
||||||
EXENAME="KindleComicConverter"
|
|
||||||
|
|
||||||
APP = ['kcc.py']
|
|
||||||
DATA_FILES = []
|
|
||||||
OPTIONS = { 'argv_emulation': True,
|
|
||||||
'iconfile': 'resources/comic2ebook.icns',
|
|
||||||
'includes': 'kcc/*.py'}
|
|
||||||
|
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
extra_options = dict(
|
extra_options = dict(
|
||||||
setup_requires=['py2app'],
|
setup_requires=['py2app'],
|
||||||
|
app=[mainscript],
|
||||||
options=dict(
|
options=dict(
|
||||||
py2app=dict(OPTIONS,
|
py2app=dict(
|
||||||
#resources=['LICENSE.txt','resources/Scripts','resources/description.rtfd'],
|
argv_emulation=True,
|
||||||
resources=['LICENSE.txt','resources/description.rtfd'],
|
iconfile='resources/comic2ebook.icns',
|
||||||
plist=dict(
|
plist=dict(
|
||||||
CFBundleName = NAME,
|
CFBundleName = NAME,
|
||||||
CFBundleShortVersionString = VERSION,
|
CFBundleShortVersionString = VERSION,
|
||||||
CFBundleGetInfoString = NAME + " " + VERSION + ", written 2012-2013 by Ciro Mattia Gonano",
|
CFBundleGetInfoString = NAME + " " + VERSION + ", written 2012-2013 by Ciro Mattia Gonano",
|
||||||
CFBundleExecutable = EXENAME,
|
CFBundleExecutable = NAME,
|
||||||
CFBundleIdentifier = IDENTIFIER,
|
CFBundleIdentifier = 'com.github.ciromattia.kcc',
|
||||||
CFBundleSignature = 'dplt'
|
CFBundleSignature = 'dplt'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -48,18 +42,17 @@ if sys.platform == 'darwin':
|
|||||||
elif sys.platform == 'win32':
|
elif sys.platform == 'win32':
|
||||||
extra_options = dict(
|
extra_options = dict(
|
||||||
setup_requires=['py2exe'],
|
setup_requires=['py2exe'],
|
||||||
|
app=[mainscript]
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
extra_options = dict(
|
extra_options = dict(
|
||||||
# Normally unix-like platforms will use "setup.py install"
|
# Normally unix-like platforms will use "setup.py install"
|
||||||
# and install the main script as such
|
# and install the main script as such
|
||||||
scripts=APP,
|
scripts=[mainscript],
|
||||||
)
|
)
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name=NAME,
|
name=NAME,
|
||||||
app=APP,
|
|
||||||
data_files=DATA_FILES,
|
|
||||||
version=VERSION,
|
version=VERSION,
|
||||||
author="Ciro Mattia Gonano",
|
author="Ciro Mattia Gonano",
|
||||||
author_email="ciromattia@gmail.com",
|
author_email="ciromattia@gmail.com",
|
||||||
|
|||||||
Reference in New Issue
Block a user