diff options
author | Ciro Mattia Gonano <ciromattia@gmail.com> | 2013-01-28 11:59:43 +0100 |
---|---|---|
committer | Ciro Mattia Gonano <ciromattia@gmail.com> | 2013-01-28 11:59:43 +0100 |
commit | 74a93f1e507ae4bb2e1620cf5169fad62dbf8086 (patch) | |
tree | 9b5e5b84c593d09352e63709f58aff42b8a7648a | |
parent | Update rarfile.py from https://github.com/markokr/rarfile (diff) | |
download | kcc-74a93f1e507ae4bb2e1620cf5169fad62dbf8086.tar.gz kcc-74a93f1e507ae4bb2e1620cf5169fad62dbf8086.tar.bz2 kcc-74a93f1e507ae4bb2e1620cf5169fad62dbf8086.zip |
Added MANIFEST.in, ugly fix for OSX not evaluating user local $PATH on app launched from Finder.
-rw-r--r-- | MANIFEST.in | 1 | ||||
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | kcc.py | 4 | ||||
-rw-r--r-- | kcc/gui.py | 52 | ||||
-rw-r--r-- | setup.py | 29 |
5 files changed, 53 insertions, 34 deletions
diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..ce924ba --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +include README.md MANIFEST.in LICENSE.txt \ No newline at end of file diff --git a/README.md b/README.md index 86c0f2c..e771289 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/kcc.py b/kcc.py index 8594a43..e2e6a87 100644 --- a/kcc.py +++ b/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() diff --git a/kcc/gui.py b/kcc/gui.py index b25501e..8f17edb 100644 --- a/kcc/gui.py +++ b/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", diff --git a/setup.py b/setup.py index 736a3fa..4112376 100644 --- a/setup.py +++ b/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", |