mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #850183 (fix hardcoded errno values)
This commit is contained in:
parent
e762bb8964
commit
d1d7eb99a0
@ -11,7 +11,7 @@ __docformat__ = 'restructuredtext en'
|
|||||||
Input plugin for HTML or OPF ebooks.
|
Input plugin for HTML or OPF ebooks.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import os, re, sys, uuid, tempfile
|
import os, re, sys, uuid, tempfile, errno
|
||||||
from urlparse import urlparse, urlunparse
|
from urlparse import urlparse, urlunparse
|
||||||
from urllib import unquote
|
from urllib import unquote
|
||||||
from functools import partial
|
from functools import partial
|
||||||
@ -75,7 +75,7 @@ class IgnoreFile(Exception):
|
|||||||
|
|
||||||
def __init__(self, msg, errno):
|
def __init__(self, msg, errno):
|
||||||
Exception.__init__(self, msg)
|
Exception.__init__(self, msg)
|
||||||
self.doesnt_exist = errno == 2
|
self.doesnt_exist = errno == errno.ENOENT
|
||||||
self.errno = errno
|
self.errno = errno
|
||||||
|
|
||||||
class HTMLFile(object):
|
class HTMLFile(object):
|
||||||
|
@ -53,7 +53,7 @@ def pdftohtml(output_dir, pdf_path, no_images):
|
|||||||
p = popen(cmd, stderr=logf._fd, stdout=logf._fd,
|
p = popen(cmd, stderr=logf._fd, stdout=logf._fd,
|
||||||
stdin=subprocess.PIPE)
|
stdin=subprocess.PIPE)
|
||||||
except OSError as err:
|
except OSError as err:
|
||||||
if err.errno == 2:
|
if err.errno == errno.ENOENT:
|
||||||
raise ConversionError(_('Could not find pdftohtml, check it is in your PATH'))
|
raise ConversionError(_('Could not find pdftohtml, check it is in your PATH'))
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
@ -7,7 +7,7 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import textwrap, re, os
|
import textwrap, re, os, errno
|
||||||
|
|
||||||
from PyQt4.Qt import (Qt, QDateEdit, QDate, pyqtSignal, QMessageBox,
|
from PyQt4.Qt import (Qt, QDateEdit, QDate, pyqtSignal, QMessageBox,
|
||||||
QIcon, QToolButton, QWidget, QLabel, QGridLayout, QApplication,
|
QIcon, QToolButton, QWidget, QLabel, QGridLayout, QApplication,
|
||||||
@ -98,7 +98,7 @@ class TitleEdit(EnLineEdit):
|
|||||||
getattr(db, 'set_'+ self.TITLE_ATTR)(id_, title, notify=False,
|
getattr(db, 'set_'+ self.TITLE_ATTR)(id_, title, notify=False,
|
||||||
commit=False)
|
commit=False)
|
||||||
except (IOError, OSError) as err:
|
except (IOError, OSError) as err:
|
||||||
if getattr(err, 'errno', -1) == 13: # Permission denied
|
if getattr(err, 'errno', -1) == errno.EACCES: # Permission denied
|
||||||
import traceback
|
import traceback
|
||||||
fname = err.filename if err.filename else 'file'
|
fname = err.filename if err.filename else 'file'
|
||||||
error_dialog(self, _('Permission denied'),
|
error_dialog(self, _('Permission denied'),
|
||||||
@ -262,7 +262,7 @@ class AuthorsEdit(MultiCompleteComboBox):
|
|||||||
self.books_to_refresh |= db.set_authors(id_, authors, notify=False,
|
self.books_to_refresh |= db.set_authors(id_, authors, notify=False,
|
||||||
allow_case_change=True)
|
allow_case_change=True)
|
||||||
except (IOError, OSError) as err:
|
except (IOError, OSError) as err:
|
||||||
if getattr(err, 'errno', -1) == 13: # Permission denied
|
if getattr(err, 'errno', -1) == errno.EACCES: # Permission denied
|
||||||
import traceback
|
import traceback
|
||||||
fname = err.filename if err.filename else 'file'
|
fname = err.filename if err.filename else 'file'
|
||||||
error_dialog(self, _('Permission denied'),
|
error_dialog(self, _('Permission denied'),
|
||||||
|
@ -7,7 +7,7 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import os
|
import os, errno
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from PyQt4.Qt import (Qt, QVBoxLayout, QHBoxLayout, QWidget, QPushButton,
|
from PyQt4.Qt import (Qt, QVBoxLayout, QHBoxLayout, QWidget, QPushButton,
|
||||||
@ -427,7 +427,7 @@ class MetadataSingleDialogBase(ResizableDialog):
|
|||||||
self.books_to_refresh |= getattr(widget, 'books_to_refresh',
|
self.books_to_refresh |= getattr(widget, 'books_to_refresh',
|
||||||
set([]))
|
set([]))
|
||||||
except IOError as err:
|
except IOError as err:
|
||||||
if err.errno == 13: # Permission denied
|
if err.errno == errno.EACCES: # Permission denied
|
||||||
import traceback
|
import traceback
|
||||||
fname = err.filename if err.filename else 'file'
|
fname = err.filename if err.filename else 'file'
|
||||||
error_dialog(self, _('Permission denied'),
|
error_dialog(self, _('Permission denied'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user