mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
23c1910bdb
commit
6b17b8a42b
@ -7,7 +7,7 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import time, operator
|
import operator
|
||||||
from threading import RLock
|
from threading import RLock
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
@ -133,20 +133,9 @@ class MTP_DEVICE(MTPDeviceBase):
|
|||||||
self.dev = self._filesystem_cache = None
|
self.dev = self._filesystem_cache = None
|
||||||
try:
|
try:
|
||||||
self.dev = self.create_device(connected_device)
|
self.dev = self.create_device(connected_device)
|
||||||
except self.libmtp.MTPError:
|
except Exception as e:
|
||||||
# Give the device some time to settle
|
raise OpenFailed('Failed to open %s: Error: %s'%(
|
||||||
time.sleep(2)
|
|
||||||
try:
|
|
||||||
self.dev = self.create_device(connected_device)
|
|
||||||
except self.libmtp.MTPError as e:
|
|
||||||
# Black list this device so that it is ignored for the
|
|
||||||
# remainder of this session.
|
|
||||||
self.blacklisted_devices.add(connected_device)
|
|
||||||
raise OpenFailed('Failed to open %s: Error: %s'%(
|
|
||||||
connected_device, as_unicode(e)))
|
connected_device, as_unicode(e)))
|
||||||
except TypeError:
|
|
||||||
self.blacklisted_devices.add(connected_device)
|
|
||||||
raise OpenFailed('')
|
|
||||||
|
|
||||||
storage = sorted(self.dev.storage_info, key=operator.itemgetter('id'))
|
storage = sorted(self.dev.storage_info, key=operator.itemgetter('id'))
|
||||||
storage = [x for x in storage if x.get('rw', False)]
|
storage = [x for x in storage if x.get('rw', False)]
|
||||||
|
@ -224,8 +224,6 @@ libmtp_Device_init(libmtp_Device *self, PyObject *args, PyObject *kwds)
|
|||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "IBHHssO", &busnum, &devnum, &vendor_id, &product_id, &vendor, &product, &usb_serialnum)) return -1;
|
if (!PyArg_ParseTuple(args, "IBHHssO", &busnum, &devnum, &vendor_id, &product_id, &vendor, &product, &usb_serialnum)) return -1;
|
||||||
|
|
||||||
if (devnum < 0 || devnum > 255 || busnum < 0) { PyErr_SetString(PyExc_TypeError, "Invalid busnum/devnum"); return -1; }
|
|
||||||
|
|
||||||
// We have to build and search the rawdevice list instead of creating a
|
// We have to build and search the rawdevice list instead of creating a
|
||||||
// rawdevice directly as otherwise, dynamic bug flag assignment in libmtp
|
// rawdevice directly as otherwise, dynamic bug flag assignment in libmtp
|
||||||
// does not work
|
// does not work
|
||||||
|
Loading…
x
Reference in New Issue
Block a user