This commit is contained in:
Kovid Goyal 2012-08-26 18:46:11 +05:30
parent 23c1910bdb
commit 6b17b8a42b
2 changed files with 3 additions and 16 deletions

View File

@ -7,7 +7,7 @@ __license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import time, operator
import operator
from threading import RLock
from io import BytesIO
from collections import namedtuple
@ -133,20 +133,9 @@ class MTP_DEVICE(MTPDeviceBase):
self.dev = self._filesystem_cache = None
try:
self.dev = self.create_device(connected_device)
except self.libmtp.MTPError:
# Give the device some time to settle
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'%(
except Exception as e:
raise OpenFailed('Failed to open %s: Error: %s'%(
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 = [x for x in storage if x.get('rw', False)]

View File

@ -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 (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
// rawdevice directly as otherwise, dynamic bug flag assignment in libmtp
// does not work