Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 06-06-2010, 08:55 PM   #1
q345
Member
q345 began at the beginning.
 
Posts: 23
Karma: 10
Join Date: May 2010
Device: none
Question Can't update cover if file cover.jpg is already in the directory ?

If I already have a cover.jpg file in the directory and I go to metadata editor, download a cover and hit 'OK' I got

File "/home/kovid/build/calibre/src/calibre/utils/magick_draw.py", line 221, in save_cover_data_to
IOError: [Errno 2] No such file or directory: u'..../cover.jpg'


I need to go to the directory, manually remove cover.jpg file, only then, when I hit OK, new cover file is saved.

I have the latest Calibre 7.1 installed under Ubuntu
The line 221 in magic_draw just tries the open cover.jpg file for writing in 'wb' mode

221 with open(path, 'wb') as f:

My question is if 'wb' (write in binary mode) necessary when opening file in Linux (not in Window) and if this might cause the problem ?
q345 is offline   Reply With Quote
Old 06-06-2010, 08:58 PM   #2
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: 43,744
Karma: 22446736
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
I just tried it and it worked fine for me in linux (wb mode works on both linux and windows and indeed is used throughout calibre).

Is this happening with all books or just one book?
kovidgoyal is offline   Reply With Quote
Old 06-06-2010, 09:09 PM   #3
q345
Member
q345 began at the beginning.
 
Posts: 23
Karma: 10
Join Date: May 2010
Device: none
Happens with all the books ( Calibre directory is on NAS)

Hi Kovid !

(It was quick !)

It happens with all the books. My Calibre directory is on NAS Can this be the reason ( I think SQLite/metadata is not involved , it just try to write file?
q345 is offline   Reply With Quote
Old 06-06-2010, 09:13 PM   #4
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: 43,744
Karma: 22446736
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
I dont see why being on NAS would cause a problem.

Tome me the message about

Can you post the actual path that occurs in the error message instead of ..../cover.jpg
kovidgoyal is offline   Reply With Quote
Old 06-06-2010, 09:32 PM   #5
q345
Member
q345 began at the beginning.
 
Posts: 23
Karma: 10
Join Date: May 2010
Device: none
Here are the complete details

Traceback (most recent call last):
File "/home/kovid/build/calibre/src/calibre/gui2/dialogs/metadata_single.py", line 704, in accept
File "/home/kovid/build/calibre/src/calibre/library/database2.py", line 474, in set_cover
File "/home/kovid/build/calibre/src/calibre/utils/magick_draw.py", line 221, in save_cover_data_to
IOError: [Errno 2] No such file or directory: u"/mm/CalibreLibrary/Pindar/The Complete Odes (Oxford World's Classics) (82)/cover.jpg"

/mm is mountpoint for NAS directory

cover.jpg has all the permissions for read/write

I need 'cd' to directory and do 'rm cover.jpg' then it works.
Also if I hit 'Reset cover to default' save it and then download covert and save - it work as well. Looks like the mere presence of cover.jpg is the problem

P.S. I tried to do source install of 7.1 to try and modify 'wb' to 'w'. First it required poppler package - when I installed it , it run further but fail in one of gcc compilation

Last edited by q345; 06-06-2010 at 09:39 PM.
q345 is offline   Reply With Quote
Old 06-06-2010, 09:44 PM   #6
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: 43,744
Karma: 22446736
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You dont need to do a source install, you can run calibre from source easioly by following the instructions in the user manual for setting up a development environment
kovidgoyal is offline   Reply With Quote
Old 06-06-2010, 09:53 PM   #7
q345
Member
q345 began at the beginning.
 
Posts: 23
Karma: 10
Join Date: May 2010
Device: none
Run in debug mode with 'wb' changed to 'w' didn't help

Run in debug mode with 'wb' changed to 'w' didn't help
q345 is offline   Reply With Quote
Old 06-06-2010, 10:17 PM   #8
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: 43,744
Karma: 22446736
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
strange. You can work around it by simply putting in

if os.path.exists(path): os.remove(path)

in that function.
kovidgoyal is offline   Reply With Quote
Old 06-06-2010, 10:46 PM   #9
q345
Member
q345 began at the beginning.
 
Posts: 23
Karma: 10
Join Date: May 2010
Device: none
This line works (problem is it tries to open file for writing)

Hi Kovid !

This line works. Thanks

I wound out that the problem (for some reason) is that it tries to open file for writing) I inserted before line 221 )

ff = open(path, 'r')
print ff
ff.close()

it print filename OK

but

ff = open(path, 'w')
print ff
ff.close()

Cries Errno 2 - No such file.

Again, I didn't check if it's the same for local directory or only for mountpoint. I don't have this problem for other metadata

I can't understand why it can't open this particular file for writing. Is locking might be involved. it was mounted with mount -t cifs
q345 is offline   Reply With Quote
Old 06-07-2010, 12:14 AM   #10
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: 43,744
Karma: 22446736
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Hmm I'm afraid I don't have a clue as to what the problem might be.
kovidgoyal is offline   Reply With Quote
Old 06-07-2010, 01:21 AM   #11
q345
Member
q345 began at the beginning.
 
Posts: 23
Karma: 10
Join Date: May 2010
Device: none
There are 2 workarounds so it's not a big problem

One is to delete the file in magic_draw.py
and second is to reset the cover from metadata menu.

I'll try to see if it happens on local harddrive too
q345 is offline   Reply With Quote
Old 06-07-2010, 01:41 PM   #12
KayakerNC
Enthusiast
KayakerNC began at the beginning.
 
Posts: 28
Karma: 12
Join Date: Oct 2009
Location: Eastern NC, near the coast
Device: Kindle Klassic (K1), Kindle 3 wifi & 3G, and Sony Pocket
What if I don't want a Cover page. No cover...nada.
How to convince Calibre?
KayakerNC is offline   Reply With Quote
Old 06-07-2010, 01:45 PM   #13
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: 43,744
Karma: 22446736
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
click the trash icon under the cover image in edit metadata
kovidgoyal is offline   Reply With Quote
Old 06-07-2010, 01:59 PM   #14
KayakerNC
Enthusiast
KayakerNC began at the beginning.
 
Posts: 28
Karma: 12
Join Date: Oct 2009
Location: Eastern NC, near the coast
Device: Kindle Klassic (K1), Kindle 3 wifi & 3G, and Sony Pocket
KayakerNC What if I don't want a Cover page. No cover...nada.
How to convince Calibre?

Quote:
Originally Posted by kovidgoyal View Post
click the trash icon under the cover image in edit metadata
Then Calibre decides to duplicate the 1st page as a cover. I don't want to see any cover page, but I can live with it.
KayakerNC is offline   Reply With Quote
Old 06-08-2010, 06:23 AM   #15
q345
Member
q345 began at the beginning.
 
Posts: 23
Karma: 10
Join Date: May 2010
Device: none
It turned out not to be a Calibre problem

Kovid !

It turned out not to be a Calibre problem,

When I invoke python interpreter it can't open ANY existing file for writing if this file is located on NAS ( mounted with mount -t cifs). It can delete file, create new file and open existing file for reading, but not 'w' or 'wb' mode in open if file exists. It return error code 2, saying "No such file"
q345 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Calibre changes size of cover.jpg when copy to new Libary --> see PDF attached icq70610 Calibre 5 10-02-2010 01:29 PM
JPG cover files not removed from Novel js4c Calibre 5 08-03-2010 09:27 PM
Extracting a cover image from lit file p3aul Calibre 6 07-25-2010 04:33 PM
Two cover .mobi file Xabache Kindle Formats 2 07-10-2010 06:25 AM
Setting first HTML file Image as Cover? phnord Calibre 2 01-09-2010 03:13 AM


All times are GMT -4. The time now is 05:49 AM.


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