Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Readers > Sony Reader

Notices

Reply
 
Thread Tools Search this Thread
Old 08-28-2008, 11:47 AM   #166
acidzebra
Liseuse Lover
acidzebra ought to be getting tired of karma fortunes by now.acidzebra ought to be getting tired of karma fortunes by now.acidzebra ought to be getting tired of karma fortunes by now.acidzebra ought to be getting tired of karma fortunes by now.acidzebra ought to be getting tired of karma fortunes by now.acidzebra ought to be getting tired of karma fortunes by now.acidzebra ought to be getting tired of karma fortunes by now.acidzebra ought to be getting tired of karma fortunes by now.acidzebra ought to be getting tired of karma fortunes by now.acidzebra ought to be getting tired of karma fortunes by now.acidzebra ought to be getting tired of karma fortunes by now.
 
acidzebra's Avatar
 
Posts: 869
Karma: 1035404
Join Date: Jul 2008
Location: Netherlands
Device: PRS-505
Beowulf, that is an awesome extension!

Regarding HTML cleanup, I've always used the Aardvark extension to clean up HTML before I print, it might be worth looking at if your considering integrating some kind of cleanup mechanism - why invent the wheel twice?

Last edited by acidzebra; 08-28-2008 at 11:57 AM.
acidzebra is offline   Reply With Quote
Old 08-28-2008, 12:07 PM   #167
beowulf573
Addict
beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.
 
beowulf573's Avatar
 
Posts: 208
Karma: 1523
Join Date: Jul 2007
Location: Houston,TX
Device: PRS-T1
Quote:
Originally Posted by kovidgoyal View Post
How are you launching web2lrf on windows? Using a windows API call?
Yep, I'm using the unicode version of CreateProcess. Passing Unicode titles work, it's the file names that are an issue. I ran dumpbin against web2lrf.exe and it's only importing the ASCII version of CreateFile (CreateFileA) so it's incapable of creating files with Unicode file names.

Apparently this is a long standing issue with python that I don't think is fully resolved yet. From what I've read googling about it's sticky problem depending upon what version of python you're using and how you instantiate the file object. However, I'm far from a python expert and am most likely wrong.

If you want I can create a set of testcases and sample code and create a ticket on your site.
beowulf573 is offline   Reply With Quote
Advert
Old 08-28-2008, 12:07 PM   #168
beowulf573
Addict
beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.
 
beowulf573's Avatar
 
Posts: 208
Karma: 1523
Join Date: Jul 2007
Location: Houston,TX
Device: PRS-T1
Quote:
Originally Posted by acidzebra View Post
Beowulf, that is an awesome extension!

Regarding HTML cleanup, I've always used the Aardvark extension to clean up HTML before I print, it might be worth looking at if your considering integrating some kind of cleanup mechanism - why invent the wheel twice?
Cool, I'll take a look at it.
beowulf573 is offline   Reply With Quote
Old 08-28-2008, 12:25 PM   #169
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 44,159
Karma: 22670164
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Quote:
Originally Posted by beowulf573 View Post
Yep, I'm using the unicode version of CreateProcess. Passing Unicode titles work, it's the file names that are an issue. I ran dumpbin against web2lrf.exe and it's only importing the ASCII version of CreateFile (CreateFileA) so it's incapable of creating files with Unicode file names.

Apparently this is a long standing issue with python that I don't think is fully resolved yet. From what I've read googling about it's sticky problem depending upon what version of python you're using and how you instantiate the file object. However, I'm far from a python expert and am most likely wrong.

If you want I can create a set of testcases and sample code and create a ticket on your site.
Do that, I'll look into it. calibre already has an extension module to make interfacing with windows a little less bug prone. Worst case, I could just add a wrapper around CreateFileW and replace open with that.
kovidgoyal is offline   Reply With Quote
Old 08-28-2008, 01:22 PM   #170
beowulf573
Addict
beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.
 
beowulf573's Avatar
 
Posts: 208
Karma: 1523
Join Date: Jul 2007
Location: Houston,TX
Device: PRS-T1
Quote:
Originally Posted by kovidgoyal View Post
Do that, I'll look into it. calibre already has an extension module to make interfacing with windows a little less bug prone. Worst case, I could just add a wrapper around CreateFileW and replace open with that.
Will do. I'll put something together tonight.
beowulf573 is offline   Reply With Quote
Advert
Old 08-28-2008, 04:15 PM   #171
igorsk
Wizard
igorsk ought to be getting tired of karma fortunes by now.igorsk ought to be getting tired of karma fortunes by now.igorsk ought to be getting tired of karma fortunes by now.igorsk ought to be getting tired of karma fortunes by now.igorsk ought to be getting tired of karma fortunes by now.igorsk ought to be getting tired of karma fortunes by now.igorsk ought to be getting tired of karma fortunes by now.igorsk ought to be getting tired of karma fortunes by now.igorsk ought to be getting tired of karma fortunes by now.igorsk ought to be getting tired of karma fortunes by now.igorsk ought to be getting tired of karma fortunes by now.
 
Posts: 3,442
Karma: 300001
Join Date: Sep 2006
Location: Belgium
Device: PRS-500/505/700, Kindle, Cybook Gen3, Words Gear
Here's a little wrapper I had used to handle unicode commandline arguments.
Code:
import sys, os, ctypes, pprint
class Argvu:
    def __init__(self,CommandLine=None):
        if CommandLine==None:
            CommandLine=ctypes.windll.kernel32.GetCommandLineW()
        argv_count=ctypes.c_int()
        cmd_string=ctypes.c_wchar_p(CommandLine)
        array_memory_address=ctypes.windll.shell32.CommandLineToArgvW(cmd_string,ctypes.byref(argv_count))
        match_array_type=ctypes.c_wchar_p*argv_count.value
        self.argv=[arg for arg in match_array_type.from_address(array_memory_address)]

        #running from a script:
        #sys.argv[0] == script.py
        #our argv[0] == python.exe
        #running from an exe:
        #sys.argv[0] == prog.exe
        #our argv[0] == prog.exe
        #if we have the first case, we need to remove the interpreter from argv

        if not sys.argv[0].endswith(".exe") and self.argv[0].endswith(".exe"):
            self.argv=self.argv[1:]

        ctypes.windll.kernel32.LocalFree(array_memory_address)
    def __str__(self):
        return pprint.pformat(self.result)

argv = Argvu().argv

if __name__=='__main__':
    c2a=Argvu()
    print c2a
    print c2a.argv
igorsk is offline   Reply With Quote
Old 08-28-2008, 04:19 PM   #172
igorsk
Wizard
igorsk ought to be getting tired of karma fortunes by now.igorsk ought to be getting tired of karma fortunes by now.igorsk ought to be getting tired of karma fortunes by now.igorsk ought to be getting tired of karma fortunes by now.igorsk ought to be getting tired of karma fortunes by now.igorsk ought to be getting tired of karma fortunes by now.igorsk ought to be getting tired of karma fortunes by now.igorsk ought to be getting tired of karma fortunes by now.igorsk ought to be getting tired of karma fortunes by now.igorsk ought to be getting tired of karma fortunes by now.igorsk ought to be getting tired of karma fortunes by now.
 
Posts: 3,442
Karma: 300001
Join Date: Sep 2006
Location: Belgium
Device: PRS-500/505/700, Kindle, Cybook Gen3, Words Gear
Quote:
Originally Posted by beowulf573 View Post
Yep, I'm using the unicode version of CreateProcess. Passing Unicode titles work, it's the file names that are an issue. I ran dumpbin against web2lrf.exe and it's only importing the ASCII version of CreateFile (CreateFileA) so it's incapable of creating files with Unicode file names.
Try dumping python25.dll instead
igorsk is offline   Reply With Quote
Old 08-28-2008, 11:52 PM   #173
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 44,159
Karma: 22670164
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Yeah calibre uses something very similar, except its implemented in C. But if I understand beowulf's problem, it's that calibre is not creating the correct output file name.

Quote:
Originally Posted by igorsk View Post
Here's a little wrapper I had used to handle unicode commandline arguments.
Code:
import sys, os, ctypes, pprint
class Argvu:
    def __init__(self,CommandLine=None):
        if CommandLine==None:
            CommandLine=ctypes.windll.kernel32.GetCommandLineW()
        argv_count=ctypes.c_int()
        cmd_string=ctypes.c_wchar_p(CommandLine)
        array_memory_address=ctypes.windll.shell32.CommandLineToArgvW(cmd_string,ctypes.byref(argv_count))
        match_array_type=ctypes.c_wchar_p*argv_count.value
        self.argv=[arg for arg in match_array_type.from_address(array_memory_address)]

        #running from a script:
        #sys.argv[0] == script.py
        #our argv[0] == python.exe
        #running from an exe:
        #sys.argv[0] == prog.exe
        #our argv[0] == prog.exe
        #if we have the first case, we need to remove the interpreter from argv

        if not sys.argv[0].endswith(".exe") and self.argv[0].endswith(".exe"):
            self.argv=self.argv[1:]

        ctypes.windll.kernel32.LocalFree(array_memory_address)
    def __str__(self):
        return pprint.pformat(self.result)

argv = Argvu().argv

if __name__=='__main__':
    c2a=Argvu()
    print c2a
    print c2a.argv
kovidgoyal is offline   Reply With Quote
Old 08-28-2008, 11:55 PM   #174
beowulf573
Addict
beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.
 
beowulf573's Avatar
 
Posts: 208
Karma: 1523
Join Date: Jul 2007
Location: Houston,TX
Device: PRS-T1
You're right, I see python25.dll importing all of those functions.

So, you're code did the trick. I wrote a simple python script that created a file and wrote a utf-8 string to it. If I passed a unicode string in as the filename, it failed in the same we I was seeing. However, if i used your code to obtain the argv array, it works like a champ.

I'll write a ticket up for Kovid with details.
beowulf573 is offline   Reply With Quote
Old 08-29-2008, 12:01 AM   #175
beowulf573
Addict
beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.
 
beowulf573's Avatar
 
Posts: 208
Karma: 1523
Join Date: Jul 2007
Location: Houston,TX
Device: PRS-T1
Sorry Kovid, I was writing my reply as you posted yours.

I think the problem is either the command line arguments are not being converted to python unicode strings from the get go, or, somewhere along the line the string variable containing the output filename is being converted to ascii or some other encoding.

The open method must be a true python unicode string not a utf-8 encoded string.
beowulf573 is offline   Reply With Quote
Old 08-29-2008, 01:10 AM   #176
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 44,159
Karma: 22670164
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
I'll look at the ticket when I get time. But calibre processes unicode arguments correctly on windows (it also uses GetCommandLineW) so the bug is probably elsewhere.
kovidgoyal is offline   Reply With Quote
Old 08-29-2008, 04:17 AM   #177
jotheman
Sleeper.
jotheman began at the beginning.
 
jotheman's Avatar
 
Posts: 109
Karma: 10
Join Date: Dec 2007
Device: Boox Max2, Kinde Voyage, reMarkable, Dasung Paperlike Pro
Quote:
Originally Posted by beowulf573 View Post
I just tested with an ascii title and it worked, are you trying a page with a unicode title? There's a problem passing a unicode output filename to web2lrf or html2lrf so I replace any non-ascii title. I don't like it but it appears to be a python issue on certain os versions and python versions. I'm going to continue to look at it but right now I don't have a good solution.

There's an edit field on the advanced tab that will let you override the filename.

I'm glad you found the editor menu item, I'll add a new menu item to the Tools menu. I need to sit down and make the gui more consistent. For 0.5.0 I'll do a complete overhaul.
Beowulf,

I think the editor feature is a great idea and it already does a great job.

I wasn't talking about the file names, though, I meant document title in the metadata. It is always empty now.

I also found that I cant un-set bold, italic etc. attributes added with the editor.

Cheers,


jo.

Last edited by jotheman; 08-29-2008 at 04:20 AM.
jotheman is offline   Reply With Quote
Old 08-29-2008, 11:16 AM   #178
beowulf573
Addict
beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.
 
beowulf573's Avatar
 
Posts: 208
Karma: 1523
Join Date: Jul 2007
Location: Houston,TX
Device: PRS-T1
Quote:
Originally Posted by kovidgoyal View Post
I'll look at the ticket when I get time. But calibre processes unicode arguments correctly on windows (it also uses GetCommandLineW) so the bug is probably elsewhere.
You're right, since unicode titles are processed correctly it's probably not the argument code.

I've found an easier way to reproduce it, cut and paste the following into a console window:
Code:
"c:\program files\calibre\web2lrf.exe" -u http://localhost -o abc_ΠΣΩ.lrf default
I've updated the ticket but in case you read this first. As time permits I'll trace through the calibre code and see if anything jumps out.
beowulf573 is offline   Reply With Quote
Old 08-29-2008, 01:49 PM   #179
beowulf573
Addict
beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.
 
beowulf573's Avatar
 
Posts: 208
Karma: 1523
Join Date: Jul 2007
Location: Houston,TX
Device: PRS-T1
Update: 0.4.3

A quick lunchtime release.

Notes for 0.4.3
  1. Ordered and Unordered lists in the html editor
  2. A Tools popup menu for folks who don't use the status bar icon
  3. Quick fix for windows conversion, fixes a bug no one should have seen.
beowulf573 is offline   Reply With Quote
Old 08-30-2008, 07:14 PM   #180
beowulf573
Addict
beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.beowulf573 once ate a cherry pie in a record 7 seconds.
 
beowulf573's Avatar
 
Posts: 208
Karma: 1523
Join Date: Jul 2007
Location: Houston,TX
Device: PRS-T1
Quote:
Originally Posted by jotheman View Post
Beowulf,

I wasn't talking about the file names, though, I meant document title in the metadata. It is always empty now.

I also found that I cant un-set bold, italic etc. attributes added with the editor.
I can't reproduce either of these, can you make sure to update to the latest version and try again? Also, make sure you didn't set a fixed title in the options dialog.

If it's still broken send me platform, firefox version details, and a sample url you see this on.

thanks.
beowulf573 is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
New Plugin Type Idea: Library Plugin cgranade Plugins 3 09-15-2010 12:11 PM
BookIt and 64 bit jlbfoot LRF 0 03-09-2009 03:24 PM
Idea for a "Bookit" Plugin -- Maybe Kovid? dsuden Sony Reader 55 01-03-2009 11:22 AM
Great new Idea! Bookit button =X= Feedback 0 10-27-2008 01:49 PM
Making MobiRead Threads BookIt Friendly =X= Feedback 3 08-11-2008 11:24 PM


All times are GMT -4. The time now is 10:12 AM.


MobileRead.com is a privately owned, operated and funded community.