mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
IGN:Proper error messages when mimagemagick fails to load. Also workaround occasional IOError when sendingfiles to devices on linux
This commit is contained in:
parent
00c32f1a2a
commit
207a9728c0
@ -24,6 +24,12 @@ class File(object):
|
||||
self.name = os.path.basename(path)
|
||||
|
||||
|
||||
def check_transfer(infile, dest):
|
||||
infile.seek(0)
|
||||
dest.seek(0)
|
||||
return infile.read() == dest.read()
|
||||
|
||||
|
||||
class CLI(object):
|
||||
|
||||
def get_file(self, path, outfile, end_session=True):
|
||||
@ -45,7 +51,15 @@ class CLI(object):
|
||||
if not os.path.exists(d):
|
||||
os.makedirs(d)
|
||||
with open(path, 'wb') as dest:
|
||||
try:
|
||||
shutil.copyfileobj(infile, dest)
|
||||
except IOError:
|
||||
print 'WARNING: First attempt to send file to device failed'
|
||||
infile.seek(0)
|
||||
dest.seek(0)
|
||||
dest.truncate()
|
||||
shutil.copyfileobj(infile, dest)
|
||||
#if not check_transfer(infile, dest): raise Exception('Transfer failed')
|
||||
if close:
|
||||
infile.close()
|
||||
|
||||
|
@ -87,7 +87,8 @@ _magick = _magick_error = None
|
||||
try:
|
||||
_magick = ctypes.CDLL(_lib)
|
||||
except Exception, err:
|
||||
_magick_erorr = str(err)
|
||||
global _magick_error
|
||||
_magick_error = str(err)
|
||||
|
||||
_initialized = False
|
||||
def initialize():
|
||||
@ -4362,7 +4363,6 @@ except AttributeError,e:
|
||||
else:
|
||||
PixelSetColor = _magick.PixelSetColor
|
||||
|
||||
|
||||
if __name__=='__main__':
|
||||
import doctest
|
||||
doctest.testmod()
|
||||
|
Loading…
x
Reference in New Issue
Block a user