1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-12 17:26:23 +00:00

Added basic error reporting

This commit is contained in:
Ciro Mattia Gonano
2013-01-28 09:47:46 +01:00
parent f40a95765b
commit 02a7bca07c
5 changed files with 56 additions and 29 deletions

View File

@@ -84,24 +84,29 @@ and installed in `/usr/local/bin/`
## CHANGELOG
- 1.00 - Initial version
- 1.10 - Added support for CBZ/CBR files in comic2ebook.py
- 1.11 - Added support for CBZ/CBR files in KindleComicConverter
- 1.20 - Comic optimizations! Split pages not target-oriented (landscape with portrait target or portrait
- 1.00: Initial version
- 1.10: Added support for CBZ/CBR files in comic2ebook.py
- 1.11: Added support for CBZ/CBR files in KindleComicConverter
- 1.20: Comic optimizations! Split pages not target-oriented (landscape with portrait target or portrait
with landscape target), add palette and other image optimizations from Mangle.
WARNING: PIL is required for all image mangling!
- 1.30 - Fixed an issue in OPF generation for device resolution
- 1.30: Fixed an issue in OPF generation for device resolution
Reworked options system (call with -h option to get the inline help)
- 1.40 - Added some options for controlling image optimization
- 1.40: Added some options for controlling image optimization
Further optimization (ImageOps, page numbering cut, autocontrast)
- 1.41 - Fixed a serious bug on resizing when img ratio was bigger than device one
- 1.50 - Added subfolder support for multiple chapters.
- 2.00 - GUI! AppleScript is gone and Tk is used to provide cross-platform GUI support.
- 1.41: Fixed a serious bug on resizing when img ratio was bigger than device one
- 1.50: Added subfolder support for multiple chapters.
- 2.0: GUI! AppleScript is gone and Tk is used to provide cross-platform GUI support.
- 2.1: Added basic error reporting
## TODO
- Add gracefully exit for CBR if no rarfile.py and no unrar executable are found
- Improve error reporting
- Recurse into dirtree for multiple comics
- Try to get filetype from magic number (found some CBR that was actually CBZ)
- Improve GUI displaying what file we're processing and giving an explicit progress status
- Better GUI design
- Add option to gen .mobi or .epub
- Validate ePub
- Make window take focus on app launch
## COPYRIGHT

1
kcc.py
View File

@@ -41,4 +41,5 @@ from kcc import gui
root = Tk()
app = gui.MainWindow(master=root,title="Kindle Comic Converter v" + __version__)
root.tkraise()
root.mainloop()

View File

@@ -74,8 +74,9 @@ class MainWindow:
self.open_folder.pack(side=LEFT)
self.profile = StringVar()
self.profile.set("KHD")
w = apply(OptionMenu, (self.master, self.profile) + tuple(sorted(ProfileData.Profiles.iterkeys())))
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)
self.image_preprocess = IntVar()
@@ -117,7 +118,8 @@ class MainWindow:
self.progressbar.stop()
def convert(self):
argv = ["-p",self.profile.get()]
profilekey = ProfileData.ProfileLabels[self.profile.get()]
argv = ["-p",profilekey]
if self.image_preprocess == 0:
argv.append("--no-image-processing")
if self.cut_page_numbers == 0:
@@ -128,20 +130,30 @@ class MainWindow:
argv.append("--upscale-images")
if self.image_stretch == 1:
argv.append("--stretch-images")
errors = False
for entry in self.filelist:
subargv = list(argv)
subargv.append(entry)
comic2ebook.main(subargv)
path = comic2ebook.getEpubPath()
call(['kindlegen',path + "/content.opf"])
kindlestrip.main((path + "/content.mobi", path + '.mobi'))
# try to clean up temp files... may be destructive!!!
shutil.rmtree(path, onerror=self.remove_readonly)
tkMessageBox.showinfo(
"Success!!",
"Conversion successfully done!"
)
try:
subargv = list(argv)
subargv.append(entry)
comic2ebook.main(subargv)
path = comic2ebook.getEpubPath()
call(['kindlegen',path + "/content.opf"])
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)))
errors = True
if errors:
tkMessageBox.showinfo(
"Done",
"Conversion finished (some errors have been reported)"
)
else:
tkMessageBox.showinfo(
"Done",
"Conversion successfully done!"
)
def remove_readonly(self, fn, path, excinfo):
if fn is os.rmdir:

View File

@@ -84,6 +84,16 @@ class ProfileData:
'KDX': ("Kindle DX", (824, 1200), Palette15),
'KDXG': ("Kindle DXG", (824, 1200), Palette16)
}
ProfileLabels = {
"Kindle" : 'K1',
"Kindle 2" : 'K2',
"Kindle 3/Keyboard" : 'K3',
"Kindle 4/NT/Touch" : 'K4',
"Kindle Paperwhite" : 'KHD',
"Kindle DX" : 'KDX',
"Kindle DXG" : 'KDXG'
}
class ComicPage:
def __init__(self,source,device):

View File

@@ -25,8 +25,7 @@ APP = ['kcc.py']
DATA_FILES = []
OPTIONS = { 'argv_emulation': True,
'iconfile': 'resources/comic2ebook.icns',
'includes': 'kcc/*.py',
'packages': 'PIL'}
'includes': 'kcc/*.py'}
if sys.platform == 'darwin':
extra_options = dict(