Web Dev Blog

Looking for help with WordPress, Apache, Vim, Web Security and more. Here are a few tips.

Category: Ubuntu

Calibre Crashed with IOError: Errno 5 input/output error

I run Calibre on Kubuntu to manage my ebooks.
Calibre stopped working one day and crashed with this message

Traceback (most recent call last):
File "site.py", line 61, in main
File "site-packages/calibre/__init__.py", line 21, in
File "site-packages/calibre/startup.py", line 77, in
File "site-packages/calibre/utils/localization.py", line 129, in set_translators
File "site-packages/calibre/utils/localization.py", line 63, in get_lang
File "site-packages/calibre/utils/config_base.py", line 446, in
File "site-packages/calibre/utils/config_base.py", line 354, in __getitem__
File "site-packages/calibre/utils/config_base.py", line 364, in get
File "site-packages/calibre/utils/config_base.py", line 348, in refresh
File "site-packages/calibre/utils/config_base.py", line 277, in parse
IOError: [Errno 5] Input/output error
/opt/calibre/lib/python2.7/site-packages/calibre/ptempfile.py:27: RuntimeWarning: Parent module 'calibre' not found while handling absolute import

Hunted high an low to find the problem, re-installed, updated, upgraded to Ubuntu 14.10, still getting same error.

Finally ran an strace on calibre

strace -o ./logfile /opt/calibre/calibre

and found this

open("/home/user/.config/calibre/global.py", O_RDWR|O_CREAT|O_CLOEXEC, 0644) = 7
fstat(7, {st_mode=S_IFREG|0644, st_size=3498, ...}) = 0
fcntl(7, F_GETFL) = 0x8002 (flags O_RDWR|O_LARGEFILE)
fstat(7, {st_mode=S_IFREG|0644, st_size=3498, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc610952000
lseek(7, 0, SEEK_CUR) = 0
lseek(7, 0, SEEK_SET) = 0
flock(7, LOCK_EX|LOCK_NB) = 0
fstat(7, {st_mode=S_IFREG|0644, st_size=3498, ...}) = 0
lseek(7, 0, SEEK_CUR) = 0
read(7, 0x7fc610952000, 4096) = -1 EIO (Input/output error)

Tried to open .config/calibre/global.py and sure enough, it was toast. Deleted global.py and restarted Calibre and everything is working.

Remove spaces from filenames on the Ubuntu Linux command line

I’ve been working on sizing a large number of images for a client to go into a WordPress photo gallery. I use a for loop to find all the files and use convert to size them to a good size for viewing on a website. The problem is the convert program doesn’t like file names with spaces in them. It seems like the easiest thing to do is remove the spaces from the file names with a Ubuntu command line script. This is easily accomplished with the rename comannd.

rename 'y/ /_/' *

This script will replace any spaces spaces in the filenames with underscores (_)