]> xmof Git - DeDRM.git/commitdiff
tools v1.3
authorApprentice Alf <apprenticealf@gmail.com>
Thu, 18 Feb 2010 19:35:12 +0000 (19:35 +0000)
committerApprentice Alf <apprenticealf@gmail.com>
Mon, 2 Mar 2015 07:35:40 +0000 (07:35 +0000)
22 files changed:
Kindle_Mobi_Tools/KindlePID.pyw
Kindle_Mobi_Tools/Kindleizer.pyw
Kindle_Mobi_Tools/MobiDeDRM.pyw
Kindle_Mobi_Tools/lib/mobidedrm.py
Topaz_Tools/TopazExtract_Kindle4PC.pyw
Topaz_Tools/TopazExtract_Kindle_iPhone.pyw
Topaz_Tools/TopazFiles2HTML.pyw
Topaz_Tools/TopazFiles2SVG.pyw
Topaz_Tools/TopazFiles2XML.pyw
Topaz_Tools/lib/cmbtc_dump.py
Topaz_Tools/lib/cmbtc_dump_nonK4PC.py
Topaz_Tools/lib/convert2xml.py
Topaz_Tools/lib/decode_meta.py
Topaz_Tools/lib/flatxml2html.py
Topaz_Tools/lib/genhtml.py
Topaz_Tools/lib/gensvg.py
Topaz_Tools/lib/genxml.py
Topaz_Tools/lib/getpagedim.py
Topaz_Tools/lib/stylexml2css.py
Topaz_Tools/lib/topaz-changes.txt
eReader_Tools/Pml2HTML.pyw
eReader_Tools/eReaderPDB2PML.pyw

index 719d02575408645b74a4ee520476bfee83f10526..771e28804e7acb8108cc4cffc632cb8d01e01b37 100644 (file)
@@ -73,6 +73,7 @@ class MainDialog(Tkinter.Frame):
     # post output from subprocess in scrolled text widget
     def showCmdOutput(self, msg):
         if msg and msg !='':
+            msg = msg.encode('utf-8')
             self.stext.insert(Tkconstants.END,msg)
             self.stext.yview_pickplace(Tkconstants.END)
         return
@@ -88,7 +89,7 @@ class MainDialog(Tkinter.Frame):
                 cmdline = 'python lib\kindlepid.py "' + serial + '"'
             else :
                 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)
         return p2
 
@@ -113,6 +114,7 @@ class MainDialog(Tkinter.Frame):
         log += 'Serial = "' + serial + '"\n'
         log += '\n\n'
         log += 'Please Wait ...\n\n'
+        log = log.encode('utf-8')
         self.stext.insert(Tkconstants.END,log)
         self.p2 = self.pidrdr(serial)
 
index 7efec6e946c89fb8fb35cc717efccfd1ca6325ea..a94b7d314b60b6cc6117a60d75bdaefa429dc506 100644 (file)
@@ -30,7 +30,9 @@ class MainDialog(Tkinter.Frame):
         Tkinter.Label(body, text='Mobi eBook input file').grid(row=0, sticky=Tkconstants.E)
         self.mobipath = Tkinter.Entry(body, width=50)
         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.grid(row=0, column=2)
 
@@ -80,6 +82,7 @@ class MainDialog(Tkinter.Frame):
     # post output from subprocess in scrolled text widget
     def showCmdOutput(self, msg):
         if msg and msg !='':
+            msg = msg.encode('utf-8')
             self.stext.insert(Tkconstants.END,msg)
             self.stext.yview_pickplace(Tkconstants.END)
         return
@@ -96,6 +99,7 @@ class MainDialog(Tkinter.Frame):
             else :
                 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)
         return p2
 
@@ -138,6 +142,7 @@ class MainDialog(Tkinter.Frame):
         log += 'PID = "' + pidnum + '"\n'
         log += '\n\n'
         log += 'Please Wait ...\n\n'
+        log = log.encode('utf-8')
         self.stext.insert(Tkconstants.END,log)
         self.p2 = self.krdr(mobipath, pidnum)
 
index 533223fca153b7794815c147c3fde6b8cd3d9851..7e96befb864bef47f6ec65ffd4c9f4a9713bb354 100644 (file)
@@ -30,7 +30,9 @@ class MainDialog(Tkinter.Frame):
         Tkinter.Label(body, text='Mobi eBook input file').grid(row=0, sticky=Tkconstants.E)
         self.mobipath = Tkinter.Entry(body, width=50)
         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.grid(row=0, column=2)
 
@@ -87,6 +89,7 @@ class MainDialog(Tkinter.Frame):
     # post output from subprocess in scrolled text widget
     def showCmdOutput(self, msg):
         if msg and msg !='':
+            msg = msg.encode('utf-8')
             self.stext.insert(Tkconstants.END,msg)
             self.stext.yview_pickplace(Tkconstants.END)
         return
@@ -103,6 +106,7 @@ class MainDialog(Tkinter.Frame):
             else :
                 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)
         return p2
 
@@ -167,6 +171,7 @@ class MainDialog(Tkinter.Frame):
         log += 'PID = "' + pidnum + '"\n'
         log += '\n\n'
         log += 'Please Wait ...\n\n'
+        log = log.encode('utf-8')
         self.stext.insert(Tkconstants.END,log)
         self.p2 = self.mobirdr(mobipath, outpath, pidnum)
 
index 178b046f8f4f121846fa397a547d156a56e42ced..02a2db3b3ec7c2b28c1bea7af7935e654d0907da 100644 (file)
 #         import filter it works when importing unencrypted files.
 #         Also now handles encrypted files that don't need a specific PID.
 #  0.11 - use autoflushed stdout and proper return values
+#  0.12 - Fix for problems with metadata import as Calibre plugin, report errors
 
 class Unbuffered:
-    def __init__(self, stream):
-        self.stream = stream
-    def write(self, data):
-        self.stream.write(data)
-        self.stream.flush()
-    def __getattr__(self, attr):
-        return getattr(self.stream, attr)
+       def __init__(self, stream):
+               self.stream = stream
+       def write(self, data):
+               self.stream.write(data)
+               self.stream.flush()
+       def __getattr__(self, attr):
+               return getattr(self.stream, attr)
 
 import sys
 sys.stdout=Unbuffered(sys.stdout)
@@ -45,37 +46,37 @@ class DrmException(Exception):
 
 #implementation of Pukall Cipher 1
 def PC1(key, src, decryption=True):
-    sum1 = 0;
-    sum2 = 0;
-    keyXorVal = 0;
-    if len(key)!=16:
-        print "Bad key length!"
-        return None
-    wkey = []
-    for i in xrange(8):
-        wkey.append(ord(key[i*2])<<8 | ord(key[i*2+1]))
+       sum1 = 0;
+       sum2 = 0;
+       keyXorVal = 0;
+       if len(key)!=16:
+               print "Bad key length!"
+               return None
+       wkey = []
+       for i in xrange(8):
+               wkey.append(ord(key[i*2])<<8 | ord(key[i*2+1]))
 
-    dst = ""
-    for i in xrange(len(src)):
-        temp1 = 0;
-        byteXorVal = 0;
-        for j in xrange(8):
-            temp1 ^= wkey[j]
-            sum2  = (sum2+j)*20021 + sum1
-            sum1  = (temp1*346)&0xFFFF
-            sum2  = (sum2+sum1)&0xFFFF
-            temp1 = (temp1*20021+1)&0xFFFF
-            byteXorVal ^= temp1 ^ sum2
-        curByte = ord(src[i])
-        if not decryption:
-            keyXorVal = curByte * 257;
-        curByte = ((curByte ^ (byteXorVal >> 8)) ^ byteXorVal) & 0xFF
-        if decryption:
-            keyXorVal = curByte * 257;
-        for j in xrange(8):
-            wkey[j] ^= keyXorVal;
-        dst+=chr(curByte)
-    return dst
+       dst = ""
+       for i in xrange(len(src)):
+               temp1 = 0;
+               byteXorVal = 0;
+               for j in xrange(8):
+                       temp1 ^= wkey[j]
+                       sum2  = (sum2+j)*20021 + sum1
+                       sum1  = (temp1*346)&0xFFFF
+                       sum2  = (sum2+sum1)&0xFFFF
+                       temp1 = (temp1*20021+1)&0xFFFF
+                       byteXorVal ^= temp1 ^ sum2
+               curByte = ord(src[i])
+               if not decryption:
+                       keyXorVal = curByte * 257;
+               curByte = ((curByte ^ (byteXorVal >> 8)) ^ byteXorVal) & 0xFF
+               if decryption:
+                       keyXorVal = curByte * 257;
+               for j in xrange(8):
+                       wkey[j] ^= keyXorVal;
+               dst+=chr(curByte)
+       return dst
 
 def checksumPid(s):
        letters = "ABCDEFGHIJKLMNPQRSTUVWXYZ123456789"
@@ -234,40 +235,46 @@ if not __name__ == "__main__":
                description         = 'Removes DRM from secure Mobi files'
                supported_platforms = ['linux', 'osx', 'windows'] # Platforms this plugin will run on
                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
                on_import           = True # Run this plugin during the import
 
        
                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
                        data_file = file(path_to_ebook, 'rb').read()
                        ar = PID.split(',')
                        for i in ar:
                                try:
-                                       file(of.name, 'wb').write(DrmStripper(data_file, i).getResult())
+                                       unlocked_file = DrmStripper(data_file, i).getResult()
                                except DrmException:
-                                       # Hm, we should display an error dialog here.
-                                       # Dunno how though.
-                                       # 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"
+                                       # ignore the error
+                                       pass
                                else:
+                                       of = self.temporary_file('.mobi')
+                                       of.write(unlocked_file)
+                                       of.close()
                                        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):
                        return 'Enter PID (separate multiple PIDs with comma)'
 
 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:
                print "Removes protection from Mobipocket books"
                print "Usage:"
                print "  mobidedrm infile.mobi outfile.mobi (PID)"
                sys.exit(1)
-       else:  
+       else:
                infile = sys.argv[1]
                outfile = sys.argv[2]
                pid = sys.argv[3]
index c18fc3f32184636037a2ce8af9ffdbb2ff00b1cb..48b7f815fd0d75036816fe5a59214f859daa8323 100644 (file)
@@ -31,14 +31,18 @@ class MainDialog(Tkinter.Frame):
         Tkinter.Label(body, text='Topaz eBook input file').grid(row=0, sticky=Tkconstants.E)
         self.tpzpath = Tkinter.Entry(body, width=50)
         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.grid(row=0, column=2)
 
         Tkinter.Label(body, text='Output Directory').grid(row=1, sticky=Tkconstants.E)
         self.outpath = Tkinter.Entry(body, width=50)
         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.grid(row=1, column=2)
 
@@ -88,6 +92,7 @@ class MainDialog(Tkinter.Frame):
     # post output from subprocess in scrolled text widget
     def showCmdOutput(self, msg):
         if msg and msg !='':
+            msg = msg.encode('utf-8')
             self.stext.insert(Tkconstants.END,msg)
             self.stext.yview_pickplace(Tkconstants.END)
         return
@@ -108,6 +113,7 @@ class MainDialog(Tkinter.Frame):
             else :
                 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)
         return p2
 
@@ -124,9 +130,11 @@ class MainDialog(Tkinter.Frame):
         return
 
     def get_outpath(self):
+        cwd = os.getcwdu()
+        cwd = cwd.encode('utf-8')
         outpath = tkFileDialog.askdirectory(
             parent=None, title='Directory to Extract Files into',
-            initialdir=os.getcwd(), initialfile=None)
+            initialdir=cwd, initialfile=None)
         if outpath:
             outpath = os.path.normpath(outpath)
             self.outpath.delete(0, Tkconstants.END)
@@ -168,6 +176,7 @@ class MainDialog(Tkinter.Frame):
         log += 'First 8 chars of PID = "' + pidnum + '"\n'
         log += '\n\n'
         log += 'Please Wait ...\n'
+        log = log.encode('utf-8')
         self.stext.insert(Tkconstants.END,log)
         self.p2 = self.topazrdr(tpzpath, outpath, pidnum)
 
index 30133ec4b209289abc2bb0942ba727a47d3b4aaa..38b9b29fabdedfa5f0b2ea97fac9103da6bfafe3 100644 (file)
@@ -31,14 +31,18 @@ class MainDialog(Tkinter.Frame):
         Tkinter.Label(body, text='Topaz eBook input file').grid(row=0, sticky=Tkconstants.E)
         self.tpzpath = Tkinter.Entry(body, width=50)
         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.grid(row=0, column=2)
 
         Tkinter.Label(body, text='Output Directory').grid(row=1, sticky=Tkconstants.E)
         self.outpath = Tkinter.Entry(body, width=50)
         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.grid(row=1, column=2)
 
@@ -88,6 +92,7 @@ class MainDialog(Tkinter.Frame):
     # post output from subprocess in scrolled text widget
     def showCmdOutput(self, msg):
         if msg and msg !='':
+            msg = msg.encode('utf-8')
             self.stext.insert(Tkconstants.END,msg)
             self.stext.yview_pickplace(Tkconstants.END)
         return
@@ -106,6 +111,7 @@ class MainDialog(Tkinter.Frame):
             else :
                 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)
         return p2
 
@@ -122,9 +128,11 @@ class MainDialog(Tkinter.Frame):
         return
 
     def get_outpath(self):
+        cwd = os.getcwdu()
+        cwd = cwd.encode('utf-8')
         outpath = tkFileDialog.askdirectory(
             parent=None, title='Directory to Extract Files into',
-            initialdir=os.getcwd(), initialfile=None)
+            initialdir=cwd, initialfile=None)
         if outpath:
             outpath = os.path.normpath(outpath)
             self.outpath.delete(0, Tkconstants.END)
@@ -166,6 +174,7 @@ class MainDialog(Tkinter.Frame):
         log += 'First 8 chars of PID = "' + pidnum + '"\n'
         log += '\n\n'
         log += 'Please Wait ...\n'
+        log = log.encode('utf-8')
         self.stext.insert(Tkconstants.END,log)
         self.p2 = self.topazrdr(tpzpath, outpath, pidnum)
 
index 1e094a573d80bab5c3720997e63bb37c7361564f..962ea75d796c8950095f4dab1d3ad130b0b07f02 100644 (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)
         self.bookdir = Tkinter.Entry(body, width=50)
         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.grid(row=0, column=2)
 
@@ -76,6 +78,7 @@ class MainDialog(Tkinter.Frame):
     # post output from subprocess in scrolled text widget
     def showCmdOutput(self, msg):
         if msg and msg !='':
+            msg = msg.encode('utf-8')
             self.stext.insert(Tkconstants.END,msg)
             self.stext.yview_pickplace(Tkconstants.END)
         return
@@ -92,14 +95,17 @@ class MainDialog(Tkinter.Frame):
             else :
                 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)
         return p2
 
 
     def get_bookdir(self):
+        cwd = os.getcwdu()
+        cwd = cwd.encode('utf-8')
         bookdir = tkFileDialog.askdirectory(
             parent=None, title='Select the Directory you Extracted Topaz Files into',
-            initialdir=os.getcwd(), initialfile=None)
+            initialdir=cwd, initialfile=None)
         if bookdir:
             bookdir = os.path.normpath(bookdir)
             self.bookdir.delete(0, Tkconstants.END)
@@ -127,6 +133,7 @@ class MainDialog(Tkinter.Frame):
         log += 'Book Directory = "' + bookdir + '"\n'
         log += '\n\n'
         log += 'Please Wait ...\n'
+        log = log.encode('utf-8')
         self.stext.insert(Tkconstants.END,log)
         self.p2 = self.topazrdr(bookdir)
 
index a93acc2285a04d9444b11127f48fd4545dd9674a..b3fff79db3f60a1a407bd5b5f408f5be22da18cb 100644 (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)
         self.bookdir = Tkinter.Entry(body, width=50)
         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.grid(row=0, column=2)
 
@@ -76,6 +78,7 @@ class MainDialog(Tkinter.Frame):
     # post output from subprocess in scrolled text widget
     def showCmdOutput(self, msg):
         if msg and msg !='':
+            msg = msg.encode('utf-8')
             self.stext.insert(Tkconstants.END,msg)
             self.stext.yview_pickplace(Tkconstants.END)
         return
@@ -92,14 +95,17 @@ class MainDialog(Tkinter.Frame):
             else :
                 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)
         return p2
 
 
     def get_bookdir(self):
+        cwd = os.getcwdu()
+        cwd = cwd.encode('utf-8')
         bookdir = tkFileDialog.askdirectory(
             parent=None, title='Select the Directory you Extracted Topaz Files into',
-            initialdir=os.getcwd(), initialfile=None)
+            initialdir=cwd, initialfile=None)
         if bookdir:
             bookdir = os.path.normpath(bookdir)
             self.bookdir.delete(0, Tkconstants.END)
@@ -127,6 +133,7 @@ class MainDialog(Tkinter.Frame):
         log += 'Book Directory = "' + bookdir + '"\n'
         log += '\n\n'
         log += 'Please Wait ...\n'
+        log = log.encode('utf-8')
         self.stext.insert(Tkconstants.END,log)
         self.p2 = self.topazrdr(bookdir)
 
index 1d2bd7c0d5e07a40d27e1d9114ee80d03ff8a030..e5f578cb56ccd9ee04beaccd98d160cab5b1d069 100644 (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)
         self.bookdir = Tkinter.Entry(body, width=50)
         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.grid(row=0, column=2)
 
@@ -76,6 +78,7 @@ class MainDialog(Tkinter.Frame):
     # post output from subprocess in scrolled text widget
     def showCmdOutput(self, msg):
         if msg and msg !='':
+            msg = msg.encode('utf-8')
             self.stext.insert(Tkconstants.END,msg)
             self.stext.yview_pickplace(Tkconstants.END)
         return
@@ -92,14 +95,17 @@ class MainDialog(Tkinter.Frame):
             else :
                 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)
         return p2
 
 
     def get_bookdir(self):
+        cwd = os.getcwdu()
+        cwd = cwd.encode('utf-8')
         bookdir = tkFileDialog.askdirectory(
             parent=None, title='Select the Directory you Extracted Topaz Files into',
-            initialdir=os.getcwd(), initialfile=None)
+            initialdir=cwd, initialfile=None)
         if bookdir:
             bookdir = os.path.normpath(bookdir)
             self.bookdir.delete(0, Tkconstants.END)
@@ -127,6 +133,7 @@ class MainDialog(Tkinter.Frame):
         log += 'Book Directory = "' + bookdir + '"\n'
         log += '\n\n'
         log += 'Please Wait ...\n'
+        log = log.encode('utf-8')
         self.stext.insert(Tkconstants.END,log)
         self.p2 = self.topazrdr(bookdir)
 
index c7b08f84499c09b706a730e44acdd259137e28e9..83301ddd8c57c3cd777d0e02b860e817361d58b6 100644 (file)
@@ -1,5 +1,5 @@
 #! /usr/bin/python
-# For use in Topaz Scripts version 2.2
+# For use in Topaz Scripts version 2.3
 
 """
 
index 253079f1c1786ba7f00c17944a62679d45bb5990..1508741cb1c47a63246278ea120a0e4a6d4cd25c 100644 (file)
@@ -1,5 +1,5 @@
 #!/usr/bin/python
-# For use with Topaz Scripts Version 2.2
+# For use with Topaz Scripts Version 2.3
 
 class Unbuffered:
     def __init__(self, stream):
index caf503922b6e06fff032ed6371a7136a2278b651..958e3b9b9d57eae37214c1240044e97a48915b0a 100644 (file)
@@ -1,6 +1,6 @@
 #! /usr/bin/python
 # 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:
     def __init__(self, stream):
index 01d8cc942cb7628b604d9f718c891323f2f15086..038f1338d91c42d62a23bbc581ccfd3c9133b39f 100644 (file)
@@ -1,6 +1,6 @@
 #! /usr/bin/python
 # 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 sys
index 6047749bd7265555d2507518e8ea901435107fe3..0fb106dc396c87e3283b719444c8de2549c74abb 100644 (file)
@@ -1,6 +1,6 @@
 #! /usr/bin/python
 # 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 csv
index 8df7b52cfd3a51d3282795968d8466e8d592b8fb..82b2c728d8251805bc237a9fea2482b3be5e098d 100644 (file)
@@ -1,6 +1,6 @@
 #! /usr/bin/python
 # 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:
     def __init__(self, stream):
index e8dfe0665423269739a341240d630b9fe0427633..82f6bc7d333e52e3c446ed89ac5d70d7402d240a 100644 (file)
@@ -1,6 +1,6 @@
 #! /usr/bin/python
 # 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:
     def __init__(self, stream):
index 868fef1c5f4ad479427f14e165d96234484c60c3..a30c6308749e16a9acf5b411cd9fac859dfbb9af 100644 (file)
@@ -1,6 +1,6 @@
 #! /usr/bin/python
 # 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:
     def __init__(self, stream):
index e59e83fa503fc261a41dbe9d4f946836b6eb63cd..af2a6f6ec91dae0e1b54825a505c7a5dfbf05d35 100644 (file)
@@ -1,6 +1,6 @@
 #! /usr/bin/python
 # 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 sys
index a540e9a96a976c85d1a034a404d87c519b69350a..0f84d696f3197c5887a0895e5a783000960f4a33 100644 (file)
@@ -1,6 +1,6 @@
 #! /usr/bin/python
 # 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 sys
index a80ef5f2566bc0d182d64e24d59113b39fa8f979..055b4b5735986e3f4aae0ff6c9ce30c1b691191c 100644 (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
        - fix for minor bug in encode_Number from clark nova
        - more fixes to handle paths with spaces in them
index 7800463d7e94cd93318416ea8585629f3d83666d..b02922ed9ccd6a2071d1f67f08b65c61eb2f3465 100644 (file)
@@ -30,7 +30,9 @@ class MainDialog(Tkinter.Frame):
         Tkinter.Label(body, text='eBook Pml input file').grid(row=0, sticky=Tkconstants.E)
         self.pmlpath = Tkinter.Entry(body, width=50)
         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.grid(row=0, column=2)
 
@@ -82,6 +84,7 @@ class MainDialog(Tkinter.Frame):
     # post output from subprocess in scrolled text widget
     def showCmdOutput(self, msg):
         if msg and msg !='':
+            msg = msg.encode('utf-8')
             self.stext.insert(Tkconstants.END,msg)
             self.stext.yview_pickplace(Tkconstants.END)
         return
@@ -98,6 +101,7 @@ class MainDialog(Tkinter.Frame):
             else :
                 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)
         return p2
 
@@ -156,6 +160,7 @@ class MainDialog(Tkinter.Frame):
         log += 'HTML Output File = "' + outpath + '"\n'
         log += '\n\n'
         log += 'Please Wait ...\n\n'
+        log = log.encode('utf-8')
         self.stext.insert(Tkconstants.END,log)
         self.p2 = self.pmlhtml(pmlpath, outpath)
 
index cb1569c637ee598759c3e77de61e3235e73b7470..16da8cd705f8b2d744547502d2ccb5087bc41031 100644 (file)
@@ -31,14 +31,18 @@ class MainDialog(Tkinter.Frame):
         Tkinter.Label(body, text='eBook PDB input file').grid(row=0, sticky=Tkconstants.E)
         self.pdbpath = Tkinter.Entry(body, width=50)
         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.grid(row=0, column=2)
 
         Tkinter.Label(body, text='Output Directory').grid(row=1, sticky=Tkconstants.E)
         self.outpath = Tkinter.Entry(body, width=50)
         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.grid(row=1, column=2)
 
@@ -93,6 +97,7 @@ class MainDialog(Tkinter.Frame):
     # post output from subprocess in scrolled text widget
     def showCmdOutput(self, msg):
         if msg and msg !='':
+            msg = msg.encode('utf-8')
             self.stext.insert(Tkconstants.END,msg)
             self.stext.yview_pickplace(Tkconstants.END)
         return
@@ -109,6 +114,7 @@ class MainDialog(Tkinter.Frame):
             else :
                 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)
         return p2
 
@@ -125,9 +131,11 @@ class MainDialog(Tkinter.Frame):
         return
 
     def get_outpath(self):
+        cwd = os.getcwdu()
+        cwd = cwd.encode('utf-8')
         outpath = tkFileDialog.askdirectory(
             parent=None, title='Directory to Store Output into',
-            initialdir=os.getcwd(), initialfile=None)
+            initialdir=cwd, initialfile=None)
         if outpath:
             outpath = os.path.normpath(outpath)
             self.outpath.delete(0, Tkconstants.END)
@@ -175,6 +183,7 @@ class MainDialog(Tkinter.Frame):
         log += 'Last 8 of CC = "' + ccnum + '"\n'
         log += '\n\n'
         log += 'Please Wait ...\n'
+        log = log.encode('utf-8')
         self.stext.insert(Tkconstants.END,log)
         self.p2 = self.erdr(pdbpath, outpath, name, ccnum)