03-05-2011, 10:32 AM | #1 |
Calibre Plugins Developer
Posts: 4,641
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
Temp files cleanup
I'm moving an email conversation with Kovid here...
I am working on the next version of my Search the Internet plugin, which will allow specifying a url that will be submitted via HTTP POST as some websites require that. Kovid has suggested using mechanize to perform the POST, grab the response, write it to a temp file and launch the browser. The potential issue I have with this is knowing when I could delete the temp files? The other idea I had was to write a temp file with a fake form in it and javascript to submit the form using onload. That way I know I can safely delete the temp file after opening in the launched browser. I've got this working, but of course it would not work for users who disable javascript in their browser. How prevalent that is I have no idea. Can anyone suggest which approach to take? |
03-05-2011, 10:35 AM | #2 |
creator of calibre
Posts: 43,933
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Dont bother deleting the temp file, it will be deleted automatically on calibre shutdown, as long as you create it with the PersistentTemporaryFile function.
I don't think a lot of people disable javascript and if they do, then most likely the other approach will fail for them as well, so I would suggest sticking with your method if you're happy with it. |
Advert | |
|
03-05-2011, 10:56 AM | #3 |
Calibre Plugins Developer
Posts: 4,641
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
Thanks Kovid, that "PersistentTemporaryFile" function will help. I figured with the recent posts there would be some infrastructure I could hook into for that.
I will go with my current approach and save learning mechanize for a rainy day |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
100,000 temp files ??? | cybmole | Calibre | 7 | 01-29-2011 11:09 PM |
Temp files... | BadGandalf | Calibre | 17 | 10-24-2010 11:38 AM |
Temp files | Jeff L | Calibre | 3 | 10-14-2010 05:58 PM |
LIT-to->EPUB conversion leaving behind temp files? | Stinger | Calibre | 1 | 06-20-2010 09:31 PM |
Calibre files left in Temp folder | itimpi | Calibre | 8 | 05-06-2009 06:15 AM |