Skip to content

Commit

Permalink
Added MANIFEST.in, ugly fix for OSX not evaluating user local $PATH o…
Browse files Browse the repository at this point in the history
…n app launched from Finder.
  • Loading branch information
ciromattia committed Jan 28, 2013
1 parent cfae5dd commit c0560ed
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 34 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include README.md MANIFEST.in LICENSE.txt
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions kcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@

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()
Expand Down
52 changes: 36 additions & 16 deletions kcc/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
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:
Expand Down Expand Up @@ -63,21 +63,21 @@ def refresh_list(self):

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
Expand All @@ -92,25 +92,29 @@ def initialize(self):
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()
Expand All @@ -132,18 +136,34 @@ def convert(self):
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",
Expand Down
29 changes: 11 additions & 18 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,24 @@
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'
)
)
Expand All @@ -48,18 +42,17 @@
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",
Expand Down

0 comments on commit c0560ed

Please sign in to comment.