mirror of
https://github.com/ciromattia/kcc
synced 2025-12-13 01:36:27 +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
|
||||
- Validate ePub
|
||||
- Make window take focus on app launch
|
||||
- [OSX] Finder-launched app does not take into account user local $PATH
|
||||
|
||||
## COPYRIGHT
|
||||
|
||||
|
||||
4
kcc.py
4
kcc.py
@@ -38,7 +38,11 @@ __docformat__ = 'restructuredtext en'
|
||||
|
||||
from Tkinter import *
|
||||
from kcc import gui
|
||||
from sys import platform
|
||||
import os
|
||||
|
||||
if platform == 'darwin':
|
||||
os.environ['PATH'] = '/usr/local/bin:' + os.environ['PATH']
|
||||
root = Tk()
|
||||
app = gui.MainWindow(master=root,title="Kindle Comic Converter v" + __version__)
|
||||
root.tkraise()
|
||||
|
||||
52
kcc/gui.py
52
kcc/gui.py
@@ -24,7 +24,7 @@ from Tkinter import *
|
||||
import tkFileDialog, tkMessageBox, ttk
|
||||
import comic2ebook, kindlestrip
|
||||
from image import ProfileData
|
||||
from subprocess import call
|
||||
from subprocess import call, Popen, PIPE, STDOUT
|
||||
import os, shutil, stat
|
||||
|
||||
class MainWindow:
|
||||
@@ -63,21 +63,21 @@ class MainWindow:
|
||||
|
||||
def initialize(self):
|
||||
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.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.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.pack(side=LEFT)
|
||||
self.open_folder.grid(row=4,column=2,rowspan=3)
|
||||
|
||||
self.profile = StringVar()
|
||||
options = sorted(ProfileData.ProfileLabels.iterkeys())
|
||||
self.profile.set(options[-1])
|
||||
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 = 1
|
||||
@@ -92,25 +92,29 @@ class MainWindow:
|
||||
self.c = Checkbutton(self.master, text="Apply image optimizations",
|
||||
variable=self.image_preprocess)
|
||||
self.c.select()
|
||||
self.c.pack()
|
||||
self.c.grid(row=2,column=3,sticky=W)
|
||||
self.c = Checkbutton(self.master, text="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)",
|
||||
variable=self.mangastyle)
|
||||
self.c.pack()
|
||||
self.c.grid(row=4,column=3,sticky=W)
|
||||
self.c = Checkbutton(self.master, text="Allow image upscaling",
|
||||
variable=self.image_upscale)
|
||||
self.c.pack()
|
||||
self.c.grid(row=5,column=3,sticky=W)
|
||||
self.c = Checkbutton(self.master, text="Stretch images",
|
||||
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')
|
||||
#now for a button
|
||||
|
||||
self.submit = Button(self.master, text="Execute!", command=self.start_conversion, fg="red")
|
||||
self.submit.pack()
|
||||
self.progressbar.pack(side=BOTTOM)
|
||||
self.submit.grid(row=7,column=3)
|
||||
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):
|
||||
self.progressbar.start()
|
||||
@@ -132,18 +136,34 @@ class MainWindow:
|
||||
argv.append("--stretch-images")
|
||||
errors = False
|
||||
for entry in self.filelist:
|
||||
self.master.update()
|
||||
try:
|
||||
subargv = list(argv)
|
||||
subargv.append(entry)
|
||||
comic2ebook.main(subargv)
|
||||
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'))
|
||||
# try to clean up temp files... may be destructive!!!
|
||||
shutil.rmtree(path, onerror=self.remove_readonly)
|
||||
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
|
||||
continue
|
||||
if errors:
|
||||
tkMessageBox.showinfo(
|
||||
"Done",
|
||||
|
||||
29
setup.py
29
setup.py
@@ -16,30 +16,24 @@ ez_setup.use_setuptools()
|
||||
import sys
|
||||
from setuptools import setup
|
||||
|
||||
NAME="KindleComicConverter"
|
||||
VERSION="2.0"
|
||||
IDENTIFIER="com.github.ciromattia.kcc"
|
||||
EXENAME="KindleComicConverter"
|
||||
|
||||
APP = ['kcc.py']
|
||||
DATA_FILES = []
|
||||
OPTIONS = { 'argv_emulation': True,
|
||||
'iconfile': 'resources/comic2ebook.icns',
|
||||
'includes': 'kcc/*.py'}
|
||||
NAME='KindleComicConverter'
|
||||
VERSION="2.1"
|
||||
mainscript = 'kcc.py'
|
||||
|
||||
if sys.platform == 'darwin':
|
||||
extra_options = dict(
|
||||
setup_requires=['py2app'],
|
||||
app=[mainscript],
|
||||
options=dict(
|
||||
py2app=dict(OPTIONS,
|
||||
#resources=['LICENSE.txt','resources/Scripts','resources/description.rtfd'],
|
||||
resources=['LICENSE.txt','resources/description.rtfd'],
|
||||
py2app=dict(
|
||||
argv_emulation=True,
|
||||
iconfile='resources/comic2ebook.icns',
|
||||
plist=dict(
|
||||
CFBundleName = NAME,
|
||||
CFBundleShortVersionString = VERSION,
|
||||
CFBundleGetInfoString = NAME + " " + VERSION + ", written 2012-2013 by Ciro Mattia Gonano",
|
||||
CFBundleExecutable = EXENAME,
|
||||
CFBundleIdentifier = IDENTIFIER,
|
||||
CFBundleExecutable = NAME,
|
||||
CFBundleIdentifier = 'com.github.ciromattia.kcc',
|
||||
CFBundleSignature = 'dplt'
|
||||
)
|
||||
)
|
||||
@@ -48,18 +42,17 @@ if sys.platform == 'darwin':
|
||||
elif sys.platform == 'win32':
|
||||
extra_options = dict(
|
||||
setup_requires=['py2exe'],
|
||||
app=[mainscript]
|
||||
)
|
||||
else:
|
||||
extra_options = dict(
|
||||
# Normally unix-like platforms will use "setup.py install"
|
||||
# and install the main script as such
|
||||
scripts=APP,
|
||||
scripts=[mainscript],
|
||||
)
|
||||
|
||||
setup(
|
||||
name=NAME,
|
||||
app=APP,
|
||||
data_files=DATA_FILES,
|
||||
version=VERSION,
|
||||
author="Ciro Mattia Gonano",
|
||||
author_email="ciromattia@gmail.com",
|
||||
|
||||
Reference in New Issue
Block a user