tools v1.3

This commit is contained in:
Apprentice Alf 2010-02-18 19:35:12 +00:00
parent 2819550411
commit dce51ae232
22 changed files with 153 additions and 77 deletions

View File

@ -73,6 +73,7 @@ class MainDialog(Tkinter.Frame):
# post output from subprocess in scrolled text widget # post output from subprocess in scrolled text widget
def showCmdOutput(self, msg): def showCmdOutput(self, msg):
if msg and msg !='': if msg and msg !='':
msg = msg.encode('utf-8')
self.stext.insert(Tkconstants.END,msg) self.stext.insert(Tkconstants.END,msg)
self.stext.yview_pickplace(Tkconstants.END) self.stext.yview_pickplace(Tkconstants.END)
return return
@ -88,7 +89,7 @@ class MainDialog(Tkinter.Frame):
cmdline = 'python lib\kindlepid.py "' + serial + '"' cmdline = 'python lib\kindlepid.py "' + serial + '"'
else : else :
cmdline = 'lib\kindlepid.py "' + serial + '"' cmdline = 'lib\kindlepid.py "' + serial + '"'
cmdline = cmdline.encode(sys.getfilesystemencoding())
p2 = Process(cmdline, shell=True, bufsize=1, stdin=None, stdout=PIPE, stderr=PIPE, close_fds=False) p2 = Process(cmdline, shell=True, bufsize=1, stdin=None, stdout=PIPE, stderr=PIPE, close_fds=False)
return p2 return p2
@ -113,6 +114,7 @@ class MainDialog(Tkinter.Frame):
log += 'Serial = "' + serial + '"\n' log += 'Serial = "' + serial + '"\n'
log += '\n\n' log += '\n\n'
log += 'Please Wait ...\n\n' log += 'Please Wait ...\n\n'
log = log.encode('utf-8')
self.stext.insert(Tkconstants.END,log) self.stext.insert(Tkconstants.END,log)
self.p2 = self.pidrdr(serial) self.p2 = self.pidrdr(serial)

View File

@ -30,7 +30,9 @@ class MainDialog(Tkinter.Frame):
Tkinter.Label(body, text='Mobi eBook input file').grid(row=0, sticky=Tkconstants.E) Tkinter.Label(body, text='Mobi eBook input file').grid(row=0, sticky=Tkconstants.E)
self.mobipath = Tkinter.Entry(body, width=50) self.mobipath = Tkinter.Entry(body, width=50)
self.mobipath.grid(row=0, column=1, sticky=sticky) self.mobipath.grid(row=0, column=1, sticky=sticky)
self.mobipath.insert(0, os.getcwd()) cwd = os.getcwdu()
cwd = cwd.encode('utf-8')
self.mobipath.insert(0, cwd)
button = Tkinter.Button(body, text="...", command=self.get_mobipath) button = Tkinter.Button(body, text="...", command=self.get_mobipath)
button.grid(row=0, column=2) button.grid(row=0, column=2)
@ -80,6 +82,7 @@ class MainDialog(Tkinter.Frame):
# post output from subprocess in scrolled text widget # post output from subprocess in scrolled text widget
def showCmdOutput(self, msg): def showCmdOutput(self, msg):
if msg and msg !='': if msg and msg !='':
msg = msg.encode('utf-8')
self.stext.insert(Tkconstants.END,msg) self.stext.insert(Tkconstants.END,msg)
self.stext.yview_pickplace(Tkconstants.END) self.stext.yview_pickplace(Tkconstants.END)
return return
@ -96,6 +99,7 @@ class MainDialog(Tkinter.Frame):
else : else :
cmdline = 'lib\kindlefix.py "' + infile + '" "' + pidnum + '"' cmdline = 'lib\kindlefix.py "' + infile + '" "' + pidnum + '"'
cmdline = cmdline.encode(sys.getfilesystemencoding())
p2 = Process(cmdline, shell=True, bufsize=1, stdin=None, stdout=PIPE, stderr=PIPE, close_fds=False) p2 = Process(cmdline, shell=True, bufsize=1, stdin=None, stdout=PIPE, stderr=PIPE, close_fds=False)
return p2 return p2
@ -138,6 +142,7 @@ class MainDialog(Tkinter.Frame):
log += 'PID = "' + pidnum + '"\n' log += 'PID = "' + pidnum + '"\n'
log += '\n\n' log += '\n\n'
log += 'Please Wait ...\n\n' log += 'Please Wait ...\n\n'
log = log.encode('utf-8')
self.stext.insert(Tkconstants.END,log) self.stext.insert(Tkconstants.END,log)
self.p2 = self.krdr(mobipath, pidnum) self.p2 = self.krdr(mobipath, pidnum)

View File

@ -30,7 +30,9 @@ class MainDialog(Tkinter.Frame):
Tkinter.Label(body, text='Mobi eBook input file').grid(row=0, sticky=Tkconstants.E) Tkinter.Label(body, text='Mobi eBook input file').grid(row=0, sticky=Tkconstants.E)
self.mobipath = Tkinter.Entry(body, width=50) self.mobipath = Tkinter.Entry(body, width=50)
self.mobipath.grid(row=0, column=1, sticky=sticky) self.mobipath.grid(row=0, column=1, sticky=sticky)
self.mobipath.insert(0, os.getcwd()) cwd = os.getcwdu()
cwd = cwd.encode('utf-8')
self.mobipath.insert(0, cwd)
button = Tkinter.Button(body, text="...", command=self.get_mobipath) button = Tkinter.Button(body, text="...", command=self.get_mobipath)
button.grid(row=0, column=2) button.grid(row=0, column=2)
@ -87,6 +89,7 @@ class MainDialog(Tkinter.Frame):
# post output from subprocess in scrolled text widget # post output from subprocess in scrolled text widget
def showCmdOutput(self, msg): def showCmdOutput(self, msg):
if msg and msg !='': if msg and msg !='':
msg = msg.encode('utf-8')
self.stext.insert(Tkconstants.END,msg) self.stext.insert(Tkconstants.END,msg)
self.stext.yview_pickplace(Tkconstants.END) self.stext.yview_pickplace(Tkconstants.END)
return return
@ -103,6 +106,7 @@ class MainDialog(Tkinter.Frame):
else : else :
cmdline = 'lib\mobidedrm.py "' + infile + '" "' + outfile + '" "' + pidnum + '"' cmdline = 'lib\mobidedrm.py "' + infile + '" "' + outfile + '" "' + pidnum + '"'
cmdline = cmdline.encode(sys.getfilesystemencoding())
p2 = Process(cmdline, shell=True, bufsize=1, stdin=None, stdout=PIPE, stderr=PIPE, close_fds=False) p2 = Process(cmdline, shell=True, bufsize=1, stdin=None, stdout=PIPE, stderr=PIPE, close_fds=False)
return p2 return p2
@ -167,6 +171,7 @@ class MainDialog(Tkinter.Frame):
log += 'PID = "' + pidnum + '"\n' log += 'PID = "' + pidnum + '"\n'
log += '\n\n' log += '\n\n'
log += 'Please Wait ...\n\n' log += 'Please Wait ...\n\n'
log = log.encode('utf-8')
self.stext.insert(Tkconstants.END,log) self.stext.insert(Tkconstants.END,log)
self.p2 = self.mobirdr(mobipath, outpath, pidnum) self.p2 = self.mobirdr(mobipath, outpath, pidnum)

View File

@ -25,15 +25,16 @@
# import filter it works when importing unencrypted files. # import filter it works when importing unencrypted files.
# Also now handles encrypted files that don't need a specific PID. # Also now handles encrypted files that don't need a specific PID.
# 0.11 - use autoflushed stdout and proper return values # 0.11 - use autoflushed stdout and proper return values
# 0.12 - Fix for problems with metadata import as Calibre plugin, report errors
class Unbuffered: class Unbuffered:
def __init__(self, stream): def __init__(self, stream):
self.stream = stream self.stream = stream
def write(self, data): def write(self, data):
self.stream.write(data) self.stream.write(data)
self.stream.flush() self.stream.flush()
def __getattr__(self, attr): def __getattr__(self, attr):
return getattr(self.stream, attr) return getattr(self.stream, attr)
import sys import sys
sys.stdout=Unbuffered(sys.stdout) sys.stdout=Unbuffered(sys.stdout)
@ -45,37 +46,37 @@ class DrmException(Exception):
#implementation of Pukall Cipher 1 #implementation of Pukall Cipher 1
def PC1(key, src, decryption=True): def PC1(key, src, decryption=True):
sum1 = 0; sum1 = 0;
sum2 = 0; sum2 = 0;
keyXorVal = 0; keyXorVal = 0;
if len(key)!=16: if len(key)!=16:
print "Bad key length!" print "Bad key length!"
return None return None
wkey = [] wkey = []
for i in xrange(8): for i in xrange(8):
wkey.append(ord(key[i*2])<<8 | ord(key[i*2+1])) wkey.append(ord(key[i*2])<<8 | ord(key[i*2+1]))
dst = "" dst = ""
for i in xrange(len(src)): for i in xrange(len(src)):
temp1 = 0; temp1 = 0;
byteXorVal = 0; byteXorVal = 0;
for j in xrange(8): for j in xrange(8):
temp1 ^= wkey[j] temp1 ^= wkey[j]
sum2 = (sum2+j)*20021 + sum1 sum2 = (sum2+j)*20021 + sum1
sum1 = (temp1*346)&0xFFFF sum1 = (temp1*346)&0xFFFF
sum2 = (sum2+sum1)&0xFFFF sum2 = (sum2+sum1)&0xFFFF
temp1 = (temp1*20021+1)&0xFFFF temp1 = (temp1*20021+1)&0xFFFF
byteXorVal ^= temp1 ^ sum2 byteXorVal ^= temp1 ^ sum2
curByte = ord(src[i]) curByte = ord(src[i])
if not decryption: if not decryption:
keyXorVal = curByte * 257; keyXorVal = curByte * 257;
curByte = ((curByte ^ (byteXorVal >> 8)) ^ byteXorVal) & 0xFF curByte = ((curByte ^ (byteXorVal >> 8)) ^ byteXorVal) & 0xFF
if decryption: if decryption:
keyXorVal = curByte * 257; keyXorVal = curByte * 257;
for j in xrange(8): for j in xrange(8):
wkey[j] ^= keyXorVal; wkey[j] ^= keyXorVal;
dst+=chr(curByte) dst+=chr(curByte)
return dst return dst
def checksumPid(s): def checksumPid(s):
letters = "ABCDEFGHIJKLMNPQRSTUVWXYZ123456789" letters = "ABCDEFGHIJKLMNPQRSTUVWXYZ123456789"
@ -234,40 +235,46 @@ if not __name__ == "__main__":
description = 'Removes DRM from secure Mobi files' description = 'Removes DRM from secure Mobi files'
supported_platforms = ['linux', 'osx', 'windows'] # Platforms this plugin will run on supported_platforms = ['linux', 'osx', 'windows'] # Platforms this plugin will run on
author = 'The Dark Reverser' # The author of this plugin author = 'The Dark Reverser' # The author of this plugin
version = (0, 1, 0) # The version number of this plugin version = (0, 1, 2) # The version number of this plugin
file_types = set(['prc','mobi','azw']) # The file types that this plugin will be applied to file_types = set(['prc','mobi','azw']) # The file types that this plugin will be applied to
on_import = True # Run this plugin during the import on_import = True # Run this plugin during the import
def run(self, path_to_ebook): def run(self, path_to_ebook):
of = self.temporary_file('.mobi') from calibre.gui2 import is_ok_to_use_qt
from PyQt4.Qt import QMessageBox
PID = self.site_customization PID = self.site_customization
data_file = file(path_to_ebook, 'rb').read() data_file = file(path_to_ebook, 'rb').read()
ar = PID.split(',') ar = PID.split(',')
for i in ar: for i in ar:
try: try:
file(of.name, 'wb').write(DrmStripper(data_file, i).getResult()) unlocked_file = DrmStripper(data_file, i).getResult()
except DrmException: except DrmException:
# Hm, we should display an error dialog here. # ignore the error
# Dunno how though. pass
# Ignore the dirty hack behind the curtain.
# strexcept = 'echo exception: %s > /dev/tty' % e
# subprocess.call(strexcept,shell=True)
print i + ": not PID for book"
else: else:
of = self.temporary_file('.mobi')
of.write(unlocked_file)
of.close()
return of.name return of.name
if is_ok_to_use_qt():
d = QMessageBox(QMessageBox.Warning, "MobiDeDRM Plugin", "Couldn't decode: %s\n\nImporting encrypted version." % path_to_ebook)
d.show()
d.raise_()
d.exec_()
return path_to_ebook
def customization_help(self, gui=False): def customization_help(self, gui=False):
return 'Enter PID (separate multiple PIDs with comma)' return 'Enter PID (separate multiple PIDs with comma)'
if __name__ == "__main__": if __name__ == "__main__":
print "MobiDeDrm v0.11. Copyright (c) 2008 The Dark Reverser" print "MobiDeDrm v0.12. Copyright (c) 2008 The Dark Reverser"
if len(sys.argv)<4: if len(sys.argv)<4:
print "Removes protection from Mobipocket books" print "Removes protection from Mobipocket books"
print "Usage:" print "Usage:"
print " mobidedrm infile.mobi outfile.mobi (PID)" print " mobidedrm infile.mobi outfile.mobi (PID)"
sys.exit(1) sys.exit(1)
else: else:
infile = sys.argv[1] infile = sys.argv[1]
outfile = sys.argv[2] outfile = sys.argv[2]
pid = sys.argv[3] pid = sys.argv[3]

View File

@ -31,14 +31,18 @@ class MainDialog(Tkinter.Frame):
Tkinter.Label(body, text='Topaz eBook input file').grid(row=0, sticky=Tkconstants.E) Tkinter.Label(body, text='Topaz eBook input file').grid(row=0, sticky=Tkconstants.E)
self.tpzpath = Tkinter.Entry(body, width=50) self.tpzpath = Tkinter.Entry(body, width=50)
self.tpzpath.grid(row=0, column=1, sticky=sticky) self.tpzpath.grid(row=0, column=1, sticky=sticky)
self.tpzpath.insert(0, os.getcwd()) cwd = os.getcwdu()
cwd = cwd.encode('utf-8')
self.tpzpath.insert(0, cwd)
button = Tkinter.Button(body, text="...", command=self.get_tpzpath) button = Tkinter.Button(body, text="...", command=self.get_tpzpath)
button.grid(row=0, column=2) button.grid(row=0, column=2)
Tkinter.Label(body, text='Output Directory').grid(row=1, sticky=Tkconstants.E) Tkinter.Label(body, text='Output Directory').grid(row=1, sticky=Tkconstants.E)
self.outpath = Tkinter.Entry(body, width=50) self.outpath = Tkinter.Entry(body, width=50)
self.outpath.grid(row=1, column=1, sticky=sticky) self.outpath.grid(row=1, column=1, sticky=sticky)
self.outpath.insert(0, os.getcwd()) cwd = os.getcwdu()
cwd = cwd.encode('utf-8')
self.outpath.insert(0, cwd)
button = Tkinter.Button(body, text="...", command=self.get_outpath) button = Tkinter.Button(body, text="...", command=self.get_outpath)
button.grid(row=1, column=2) button.grid(row=1, column=2)
@ -88,6 +92,7 @@ class MainDialog(Tkinter.Frame):
# post output from subprocess in scrolled text widget # post output from subprocess in scrolled text widget
def showCmdOutput(self, msg): def showCmdOutput(self, msg):
if msg and msg !='': if msg and msg !='':
msg = msg.encode('utf-8')
self.stext.insert(Tkconstants.END,msg) self.stext.insert(Tkconstants.END,msg)
self.stext.yview_pickplace(Tkconstants.END) self.stext.yview_pickplace(Tkconstants.END)
return return
@ -108,6 +113,7 @@ class MainDialog(Tkinter.Frame):
else : else :
cmdline = 'lib\cmbtc_dump.py -v -d ' + pidoption + outoption + '"' + infile + '"' cmdline = 'lib\cmbtc_dump.py -v -d ' + pidoption + outoption + '"' + infile + '"'
cmdline = cmdline.encode(sys.getfilesystemencoding())
p2 = Process(cmdline, shell=True, bufsize=1, stdin=None, stdout=PIPE, stderr=PIPE, close_fds=False) p2 = Process(cmdline, shell=True, bufsize=1, stdin=None, stdout=PIPE, stderr=PIPE, close_fds=False)
return p2 return p2
@ -124,9 +130,11 @@ class MainDialog(Tkinter.Frame):
return return
def get_outpath(self): def get_outpath(self):
cwd = os.getcwdu()
cwd = cwd.encode('utf-8')
outpath = tkFileDialog.askdirectory( outpath = tkFileDialog.askdirectory(
parent=None, title='Directory to Extract Files into', parent=None, title='Directory to Extract Files into',
initialdir=os.getcwd(), initialfile=None) initialdir=cwd, initialfile=None)
if outpath: if outpath:
outpath = os.path.normpath(outpath) outpath = os.path.normpath(outpath)
self.outpath.delete(0, Tkconstants.END) self.outpath.delete(0, Tkconstants.END)
@ -168,6 +176,7 @@ class MainDialog(Tkinter.Frame):
log += 'First 8 chars of PID = "' + pidnum + '"\n' log += 'First 8 chars of PID = "' + pidnum + '"\n'
log += '\n\n' log += '\n\n'
log += 'Please Wait ...\n' log += 'Please Wait ...\n'
log = log.encode('utf-8')
self.stext.insert(Tkconstants.END,log) self.stext.insert(Tkconstants.END,log)
self.p2 = self.topazrdr(tpzpath, outpath, pidnum) self.p2 = self.topazrdr(tpzpath, outpath, pidnum)

View File

@ -31,14 +31,18 @@ class MainDialog(Tkinter.Frame):
Tkinter.Label(body, text='Topaz eBook input file').grid(row=0, sticky=Tkconstants.E) Tkinter.Label(body, text='Topaz eBook input file').grid(row=0, sticky=Tkconstants.E)
self.tpzpath = Tkinter.Entry(body, width=50) self.tpzpath = Tkinter.Entry(body, width=50)
self.tpzpath.grid(row=0, column=1, sticky=sticky) self.tpzpath.grid(row=0, column=1, sticky=sticky)
self.tpzpath.insert(0, os.getcwd()) cwd = os.getcwdu()
cwd = cwd.encode('utf-8')
self.tpzpath.insert(0, cwd)
button = Tkinter.Button(body, text="...", command=self.get_tpzpath) button = Tkinter.Button(body, text="...", command=self.get_tpzpath)
button.grid(row=0, column=2) button.grid(row=0, column=2)
Tkinter.Label(body, text='Output Directory').grid(row=1, sticky=Tkconstants.E) Tkinter.Label(body, text='Output Directory').grid(row=1, sticky=Tkconstants.E)
self.outpath = Tkinter.Entry(body, width=50) self.outpath = Tkinter.Entry(body, width=50)
self.outpath.grid(row=1, column=1, sticky=sticky) self.outpath.grid(row=1, column=1, sticky=sticky)
self.outpath.insert(0, os.getcwd()) cwd = os.getcwdu()
cwd = cwd.encode('utf-8')
self.outpath.insert(0, cwd)
button = Tkinter.Button(body, text="...", command=self.get_outpath) button = Tkinter.Button(body, text="...", command=self.get_outpath)
button.grid(row=1, column=2) button.grid(row=1, column=2)
@ -88,6 +92,7 @@ class MainDialog(Tkinter.Frame):
# post output from subprocess in scrolled text widget # post output from subprocess in scrolled text widget
def showCmdOutput(self, msg): def showCmdOutput(self, msg):
if msg and msg !='': if msg and msg !='':
msg = msg.encode('utf-8')
self.stext.insert(Tkconstants.END,msg) self.stext.insert(Tkconstants.END,msg)
self.stext.yview_pickplace(Tkconstants.END) self.stext.yview_pickplace(Tkconstants.END)
return return
@ -106,6 +111,7 @@ class MainDialog(Tkinter.Frame):
else : else :
cmdline = 'lib\cmbtc_dump_nonK4PC.py -v -d ' + pidoption + outoption + '"' + infile + '"' cmdline = 'lib\cmbtc_dump_nonK4PC.py -v -d ' + pidoption + outoption + '"' + infile + '"'
cmdline = cmdline.encode(sys.getfilesystemencoding())
p2 = Process(cmdline, shell=True, bufsize=1, stdin=None, stdout=PIPE, stderr=PIPE, close_fds=False) p2 = Process(cmdline, shell=True, bufsize=1, stdin=None, stdout=PIPE, stderr=PIPE, close_fds=False)
return p2 return p2
@ -122,9 +128,11 @@ class MainDialog(Tkinter.Frame):
return return
def get_outpath(self): def get_outpath(self):
cwd = os.getcwdu()
cwd = cwd.encode('utf-8')
outpath = tkFileDialog.askdirectory( outpath = tkFileDialog.askdirectory(
parent=None, title='Directory to Extract Files into', parent=None, title='Directory to Extract Files into',
initialdir=os.getcwd(), initialfile=None) initialdir=cwd, initialfile=None)
if outpath: if outpath:
outpath = os.path.normpath(outpath) outpath = os.path.normpath(outpath)
self.outpath.delete(0, Tkconstants.END) self.outpath.delete(0, Tkconstants.END)
@ -166,6 +174,7 @@ class MainDialog(Tkinter.Frame):
log += 'First 8 chars of PID = "' + pidnum + '"\n' log += 'First 8 chars of PID = "' + pidnum + '"\n'
log += '\n\n' log += '\n\n'
log += 'Please Wait ...\n' log += 'Please Wait ...\n'
log = log.encode('utf-8')
self.stext.insert(Tkconstants.END,log) self.stext.insert(Tkconstants.END,log)
self.p2 = self.topazrdr(tpzpath, outpath, pidnum) self.p2 = self.topazrdr(tpzpath, outpath, pidnum)

View File

@ -31,7 +31,9 @@ class MainDialog(Tkinter.Frame):
Tkinter.Label(body, text='Directory you Extracted Topaz Files into').grid(row=0, sticky=Tkconstants.E) Tkinter.Label(body, text='Directory you Extracted Topaz Files into').grid(row=0, sticky=Tkconstants.E)
self.bookdir = Tkinter.Entry(body, width=50) self.bookdir = Tkinter.Entry(body, width=50)
self.bookdir.grid(row=0, column=1, sticky=sticky) self.bookdir.grid(row=0, column=1, sticky=sticky)
self.bookdir.insert(0, os.getcwd()) cwd = os.getcwdu()
cwd = cwd.encode('utf-8')
self.bookdir.insert(0, cwd)
button = Tkinter.Button(body, text="...", command=self.get_bookdir) button = Tkinter.Button(body, text="...", command=self.get_bookdir)
button.grid(row=0, column=2) button.grid(row=0, column=2)
@ -76,6 +78,7 @@ class MainDialog(Tkinter.Frame):
# post output from subprocess in scrolled text widget # post output from subprocess in scrolled text widget
def showCmdOutput(self, msg): def showCmdOutput(self, msg):
if msg and msg !='': if msg and msg !='':
msg = msg.encode('utf-8')
self.stext.insert(Tkconstants.END,msg) self.stext.insert(Tkconstants.END,msg)
self.stext.yview_pickplace(Tkconstants.END) self.stext.yview_pickplace(Tkconstants.END)
return return
@ -92,14 +95,17 @@ class MainDialog(Tkinter.Frame):
else : else :
cmdline = 'lib\genhtml.py "' + bookdir + '"' cmdline = 'lib\genhtml.py "' + bookdir + '"'
cmdline = cmdline.encode(sys.getfilesystemencoding())
p2 = Process(cmdline, shell=True, bufsize=1, stdin=None, stdout=PIPE, stderr=PIPE, close_fds=False) p2 = Process(cmdline, shell=True, bufsize=1, stdin=None, stdout=PIPE, stderr=PIPE, close_fds=False)
return p2 return p2
def get_bookdir(self): def get_bookdir(self):
cwd = os.getcwdu()
cwd = cwd.encode('utf-8')
bookdir = tkFileDialog.askdirectory( bookdir = tkFileDialog.askdirectory(
parent=None, title='Select the Directory you Extracted Topaz Files into', parent=None, title='Select the Directory you Extracted Topaz Files into',
initialdir=os.getcwd(), initialfile=None) initialdir=cwd, initialfile=None)
if bookdir: if bookdir:
bookdir = os.path.normpath(bookdir) bookdir = os.path.normpath(bookdir)
self.bookdir.delete(0, Tkconstants.END) self.bookdir.delete(0, Tkconstants.END)
@ -127,6 +133,7 @@ class MainDialog(Tkinter.Frame):
log += 'Book Directory = "' + bookdir + '"\n' log += 'Book Directory = "' + bookdir + '"\n'
log += '\n\n' log += '\n\n'
log += 'Please Wait ...\n' log += 'Please Wait ...\n'
log = log.encode('utf-8')
self.stext.insert(Tkconstants.END,log) self.stext.insert(Tkconstants.END,log)
self.p2 = self.topazrdr(bookdir) self.p2 = self.topazrdr(bookdir)

View File

@ -31,7 +31,9 @@ class MainDialog(Tkinter.Frame):
Tkinter.Label(body, text='Directory you Extracted Topaz Files into').grid(row=0, sticky=Tkconstants.E) Tkinter.Label(body, text='Directory you Extracted Topaz Files into').grid(row=0, sticky=Tkconstants.E)
self.bookdir = Tkinter.Entry(body, width=50) self.bookdir = Tkinter.Entry(body, width=50)
self.bookdir.grid(row=0, column=1, sticky=sticky) self.bookdir.grid(row=0, column=1, sticky=sticky)
self.bookdir.insert(0, os.getcwd()) cwd = os.getcwdu()
cwd = cwd.encode('utf-8')
self.bookdir.insert(0, cwd)
button = Tkinter.Button(body, text="...", command=self.get_bookdir) button = Tkinter.Button(body, text="...", command=self.get_bookdir)
button.grid(row=0, column=2) button.grid(row=0, column=2)
@ -76,6 +78,7 @@ class MainDialog(Tkinter.Frame):
# post output from subprocess in scrolled text widget # post output from subprocess in scrolled text widget
def showCmdOutput(self, msg): def showCmdOutput(self, msg):
if msg and msg !='': if msg and msg !='':
msg = msg.encode('utf-8')
self.stext.insert(Tkconstants.END,msg) self.stext.insert(Tkconstants.END,msg)
self.stext.yview_pickplace(Tkconstants.END) self.stext.yview_pickplace(Tkconstants.END)
return return
@ -92,14 +95,17 @@ class MainDialog(Tkinter.Frame):
else : else :
cmdline = 'lib\gensvg.py "' + bookdir + '"' cmdline = 'lib\gensvg.py "' + bookdir + '"'
cmdline = cmdline.encode(sys.getfilesystemencoding())
p2 = Process(cmdline, shell=True, bufsize=1, stdin=None, stdout=PIPE, stderr=PIPE, close_fds=False) p2 = Process(cmdline, shell=True, bufsize=1, stdin=None, stdout=PIPE, stderr=PIPE, close_fds=False)
return p2 return p2
def get_bookdir(self): def get_bookdir(self):
cwd = os.getcwdu()
cwd = cwd.encode('utf-8')
bookdir = tkFileDialog.askdirectory( bookdir = tkFileDialog.askdirectory(
parent=None, title='Select the Directory you Extracted Topaz Files into', parent=None, title='Select the Directory you Extracted Topaz Files into',
initialdir=os.getcwd(), initialfile=None) initialdir=cwd, initialfile=None)
if bookdir: if bookdir:
bookdir = os.path.normpath(bookdir) bookdir = os.path.normpath(bookdir)
self.bookdir.delete(0, Tkconstants.END) self.bookdir.delete(0, Tkconstants.END)
@ -127,6 +133,7 @@ class MainDialog(Tkinter.Frame):
log += 'Book Directory = "' + bookdir + '"\n' log += 'Book Directory = "' + bookdir + '"\n'
log += '\n\n' log += '\n\n'
log += 'Please Wait ...\n' log += 'Please Wait ...\n'
log = log.encode('utf-8')
self.stext.insert(Tkconstants.END,log) self.stext.insert(Tkconstants.END,log)
self.p2 = self.topazrdr(bookdir) self.p2 = self.topazrdr(bookdir)

View File

@ -31,7 +31,9 @@ class MainDialog(Tkinter.Frame):
Tkinter.Label(body, text='Directory you Extracted Topaz Files into').grid(row=0, sticky=Tkconstants.E) Tkinter.Label(body, text='Directory you Extracted Topaz Files into').grid(row=0, sticky=Tkconstants.E)
self.bookdir = Tkinter.Entry(body, width=50) self.bookdir = Tkinter.Entry(body, width=50)
self.bookdir.grid(row=0, column=1, sticky=sticky) self.bookdir.grid(row=0, column=1, sticky=sticky)
self.bookdir.insert(0, os.getcwd()) cwd = os.getcwdu()
cwd = cwd.encode('utf-8')
self.bookdir.insert(0, cwd)
button = Tkinter.Button(body, text="...", command=self.get_bookdir) button = Tkinter.Button(body, text="...", command=self.get_bookdir)
button.grid(row=0, column=2) button.grid(row=0, column=2)
@ -76,6 +78,7 @@ class MainDialog(Tkinter.Frame):
# post output from subprocess in scrolled text widget # post output from subprocess in scrolled text widget
def showCmdOutput(self, msg): def showCmdOutput(self, msg):
if msg and msg !='': if msg and msg !='':
msg = msg.encode('utf-8')
self.stext.insert(Tkconstants.END,msg) self.stext.insert(Tkconstants.END,msg)
self.stext.yview_pickplace(Tkconstants.END) self.stext.yview_pickplace(Tkconstants.END)
return return
@ -92,14 +95,17 @@ class MainDialog(Tkinter.Frame):
else : else :
cmdline = 'lib\genxml.py "' + bookdir + '"' cmdline = 'lib\genxml.py "' + bookdir + '"'
cmdline = cmdline.encode(sys.getfilesystemencoding())
p2 = Process(cmdline, shell=True, bufsize=1, stdin=None, stdout=PIPE, stderr=PIPE, close_fds=False) p2 = Process(cmdline, shell=True, bufsize=1, stdin=None, stdout=PIPE, stderr=PIPE, close_fds=False)
return p2 return p2
def get_bookdir(self): def get_bookdir(self):
cwd = os.getcwdu()
cwd = cwd.encode('utf-8')
bookdir = tkFileDialog.askdirectory( bookdir = tkFileDialog.askdirectory(
parent=None, title='Select the Directory you Extracted Topaz Files into', parent=None, title='Select the Directory you Extracted Topaz Files into',
initialdir=os.getcwd(), initialfile=None) initialdir=cwd, initialfile=None)
if bookdir: if bookdir:
bookdir = os.path.normpath(bookdir) bookdir = os.path.normpath(bookdir)
self.bookdir.delete(0, Tkconstants.END) self.bookdir.delete(0, Tkconstants.END)
@ -127,6 +133,7 @@ class MainDialog(Tkinter.Frame):
log += 'Book Directory = "' + bookdir + '"\n' log += 'Book Directory = "' + bookdir + '"\n'
log += '\n\n' log += '\n\n'
log += 'Please Wait ...\n' log += 'Please Wait ...\n'
log = log.encode('utf-8')
self.stext.insert(Tkconstants.END,log) self.stext.insert(Tkconstants.END,log)
self.p2 = self.topazrdr(bookdir) self.p2 = self.topazrdr(bookdir)

View File

@ -1,5 +1,5 @@
#! /usr/bin/python #! /usr/bin/python
# For use in Topaz Scripts version 2.2 # For use in Topaz Scripts version 2.3
""" """

View File

@ -1,5 +1,5 @@
#!/usr/bin/python #!/usr/bin/python
# For use with Topaz Scripts Version 2.2 # For use with Topaz Scripts Version 2.3
class Unbuffered: class Unbuffered:
def __init__(self, stream): def __init__(self, stream):

View File

@ -1,6 +1,6 @@
#! /usr/bin/python #! /usr/bin/python
# vim:ts=4:sw=4:softtabstop=4:smarttab:expandtab # vim:ts=4:sw=4:softtabstop=4:smarttab:expandtab
# For use with Topaz Scripts Version 2.2 # For use with Topaz Scripts Version 2.3
class Unbuffered: class Unbuffered:
def __init__(self, stream): def __init__(self, stream):

View File

@ -1,6 +1,6 @@
#! /usr/bin/python #! /usr/bin/python
# vim:ts=4:sw=4:softtabstop=4:smarttab:expandtab # vim:ts=4:sw=4:softtabstop=4:smarttab:expandtab
# For use with Topaz Scripts Version 2.2 # For use with Topaz Scripts Version 2.3
import csv import csv
import sys import sys

View File

@ -1,6 +1,6 @@
#! /usr/bin/python #! /usr/bin/python
# vim:ts=4:sw=4:softtabstop=4:smarttab:expandtab # vim:ts=4:sw=4:softtabstop=4:smarttab:expandtab
# For use with Topaz Scripts Version 2.2 # For use with Topaz Scripts Version 2.3
import sys import sys
import csv import csv

View File

@ -1,6 +1,6 @@
#! /usr/bin/python #! /usr/bin/python
# vim:ts=4:sw=4:softtabstop=4:smarttab:expandtab # vim:ts=4:sw=4:softtabstop=4:smarttab:expandtab
# For use with Topaz Scripts Version 2.2 # For use with Topaz Scripts Version 2.3
class Unbuffered: class Unbuffered:
def __init__(self, stream): def __init__(self, stream):

View File

@ -1,6 +1,6 @@
#! /usr/bin/python #! /usr/bin/python
# vim:ts=4:sw=4:softtabstop=4:smarttab:expandtab # vim:ts=4:sw=4:softtabstop=4:smarttab:expandtab
# For use with Topaz Scripts Version 2.2 # For use with Topaz Scripts Version 2.3
class Unbuffered: class Unbuffered:
def __init__(self, stream): def __init__(self, stream):

View File

@ -1,6 +1,6 @@
#! /usr/bin/python #! /usr/bin/python
# vim:ts=4:sw=4:softtabstop=4:smarttab:expandtab # vim:ts=4:sw=4:softtabstop=4:smarttab:expandtab
# For use with Topaz Scripts Version 2.2 # For use with Topaz Scripts Version 2.3
class Unbuffered: class Unbuffered:
def __init__(self, stream): def __init__(self, stream):

View File

@ -1,6 +1,6 @@
#! /usr/bin/python #! /usr/bin/python
# vim:ts=4:sw=4:softtabstop=4:smarttab:expandtab # vim:ts=4:sw=4:softtabstop=4:smarttab:expandtab
# For use with Topaz Scripts Version 2.2 # For use with Topaz Scripts Version 2.3
import csv import csv
import sys import sys

View File

@ -1,6 +1,6 @@
#! /usr/bin/python #! /usr/bin/python
# vim:ts=4:sw=4:softtabstop=4:smarttab:expandtab # vim:ts=4:sw=4:softtabstop=4:smarttab:expandtab
# For use with Topaz Scripts Version 2.2 # For use with Topaz Scripts Version 2.3
import csv import csv
import sys import sys

View File

@ -1,3 +1,7 @@
Canges in 2.3
- fix for use with non-latin1 based systems (thank you Tedd)
- fixes for out of order tokens in xml
Changes in 2.2 Changes in 2.2
- fix for minor bug in encode_Number from clark nova - fix for minor bug in encode_Number from clark nova
- more fixes to handle paths with spaces in them - more fixes to handle paths with spaces in them

View File

@ -30,7 +30,9 @@ class MainDialog(Tkinter.Frame):
Tkinter.Label(body, text='eBook Pml input file').grid(row=0, sticky=Tkconstants.E) Tkinter.Label(body, text='eBook Pml input file').grid(row=0, sticky=Tkconstants.E)
self.pmlpath = Tkinter.Entry(body, width=50) self.pmlpath = Tkinter.Entry(body, width=50)
self.pmlpath.grid(row=0, column=1, sticky=sticky) self.pmlpath.grid(row=0, column=1, sticky=sticky)
self.pmlpath.insert(0, os.getcwd()) cwd = os.getcwdu()
cwd = cwd.encode('utf-8')
self.pmlpath.insert(0, cwd)
button = Tkinter.Button(body, text="...", command=self.get_pmlpath) button = Tkinter.Button(body, text="...", command=self.get_pmlpath)
button.grid(row=0, column=2) button.grid(row=0, column=2)
@ -82,6 +84,7 @@ class MainDialog(Tkinter.Frame):
# post output from subprocess in scrolled text widget # post output from subprocess in scrolled text widget
def showCmdOutput(self, msg): def showCmdOutput(self, msg):
if msg and msg !='': if msg and msg !='':
msg = msg.encode('utf-8')
self.stext.insert(Tkconstants.END,msg) self.stext.insert(Tkconstants.END,msg)
self.stext.yview_pickplace(Tkconstants.END) self.stext.yview_pickplace(Tkconstants.END)
return return
@ -98,6 +101,7 @@ class MainDialog(Tkinter.Frame):
else : else :
cmdline = 'lib\\xpml2xhtml.py "' + infile + '" "' + outfile + '"' cmdline = 'lib\\xpml2xhtml.py "' + infile + '" "' + outfile + '"'
cmdline = cmdline.encode(sys.getfilesystemencoding())
p2 = Process(cmdline, shell=True, bufsize=1, stdin=None, stdout=PIPE, stderr=PIPE, close_fds=False) p2 = Process(cmdline, shell=True, bufsize=1, stdin=None, stdout=PIPE, stderr=PIPE, close_fds=False)
return p2 return p2
@ -156,6 +160,7 @@ class MainDialog(Tkinter.Frame):
log += 'HTML Output File = "' + outpath + '"\n' log += 'HTML Output File = "' + outpath + '"\n'
log += '\n\n' log += '\n\n'
log += 'Please Wait ...\n\n' log += 'Please Wait ...\n\n'
log = log.encode('utf-8')
self.stext.insert(Tkconstants.END,log) self.stext.insert(Tkconstants.END,log)
self.p2 = self.pmlhtml(pmlpath, outpath) self.p2 = self.pmlhtml(pmlpath, outpath)

View File

@ -31,14 +31,18 @@ class MainDialog(Tkinter.Frame):
Tkinter.Label(body, text='eBook PDB input file').grid(row=0, sticky=Tkconstants.E) Tkinter.Label(body, text='eBook PDB input file').grid(row=0, sticky=Tkconstants.E)
self.pdbpath = Tkinter.Entry(body, width=50) self.pdbpath = Tkinter.Entry(body, width=50)
self.pdbpath.grid(row=0, column=1, sticky=sticky) self.pdbpath.grid(row=0, column=1, sticky=sticky)
self.pdbpath.insert(0, os.getcwd()) cwd = os.getcwdu()
cwd = cwd.encode('utf-8')
self.pdbpath.insert(0, cwd)
button = Tkinter.Button(body, text="...", command=self.get_pdbpath) button = Tkinter.Button(body, text="...", command=self.get_pdbpath)
button.grid(row=0, column=2) button.grid(row=0, column=2)
Tkinter.Label(body, text='Output Directory').grid(row=1, sticky=Tkconstants.E) Tkinter.Label(body, text='Output Directory').grid(row=1, sticky=Tkconstants.E)
self.outpath = Tkinter.Entry(body, width=50) self.outpath = Tkinter.Entry(body, width=50)
self.outpath.grid(row=1, column=1, sticky=sticky) self.outpath.grid(row=1, column=1, sticky=sticky)
self.outpath.insert(0, os.getcwd()) cwd = os.getcwdu()
cwd = cwd.encode('utf-8')
self.outpath.insert(0, cwd)
button = Tkinter.Button(body, text="...", command=self.get_outpath) button = Tkinter.Button(body, text="...", command=self.get_outpath)
button.grid(row=1, column=2) button.grid(row=1, column=2)
@ -93,6 +97,7 @@ class MainDialog(Tkinter.Frame):
# post output from subprocess in scrolled text widget # post output from subprocess in scrolled text widget
def showCmdOutput(self, msg): def showCmdOutput(self, msg):
if msg and msg !='': if msg and msg !='':
msg = msg.encode('utf-8')
self.stext.insert(Tkconstants.END,msg) self.stext.insert(Tkconstants.END,msg)
self.stext.yview_pickplace(Tkconstants.END) self.stext.yview_pickplace(Tkconstants.END)
return return
@ -109,6 +114,7 @@ class MainDialog(Tkinter.Frame):
else : else :
cmdline = 'lib\erdr2pml.py "' + infile + '" "' + outdir + '" "' + name + '" ' + ccnum cmdline = 'lib\erdr2pml.py "' + infile + '" "' + outdir + '" "' + name + '" ' + ccnum
cmdline = cmdline.encode(sys.getfilesystemencoding())
p2 = Process(cmdline, shell=True, bufsize=1, stdin=None, stdout=PIPE, stderr=PIPE, close_fds=False) p2 = Process(cmdline, shell=True, bufsize=1, stdin=None, stdout=PIPE, stderr=PIPE, close_fds=False)
return p2 return p2
@ -125,9 +131,11 @@ class MainDialog(Tkinter.Frame):
return return
def get_outpath(self): def get_outpath(self):
cwd = os.getcwdu()
cwd = cwd.encode('utf-8')
outpath = tkFileDialog.askdirectory( outpath = tkFileDialog.askdirectory(
parent=None, title='Directory to Store Output into', parent=None, title='Directory to Store Output into',
initialdir=os.getcwd(), initialfile=None) initialdir=cwd, initialfile=None)
if outpath: if outpath:
outpath = os.path.normpath(outpath) outpath = os.path.normpath(outpath)
self.outpath.delete(0, Tkconstants.END) self.outpath.delete(0, Tkconstants.END)
@ -175,6 +183,7 @@ class MainDialog(Tkinter.Frame):
log += 'Last 8 of CC = "' + ccnum + '"\n' log += 'Last 8 of CC = "' + ccnum + '"\n'
log += '\n\n' log += '\n\n'
log += 'Please Wait ...\n' log += 'Please Wait ...\n'
log = log.encode('utf-8')
self.stext.insert(Tkconstants.END,log) self.stext.insert(Tkconstants.END,log)
self.p2 = self.erdr(pdbpath, outpath, name, ccnum) self.p2 = self.erdr(pdbpath, outpath, name, ccnum)