mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Ensure that mount points on linux are never blank. Also make find_device_nodes reusable
This commit is contained in:
parent
b4e6ceadd8
commit
304a0ae408
@ -217,7 +217,7 @@ class DevicePlugin(Plugin):
|
|||||||
'''
|
'''
|
||||||
Unix version of :meth:`can_handle_windows`
|
Unix version of :meth:`can_handle_windows`
|
||||||
|
|
||||||
:param device_info: Is a tupe of (vid, pid, bcd, manufacturer, product,
|
:param device_info: Is a tuple of (vid, pid, bcd, manufacturer, product,
|
||||||
serial number)
|
serial number)
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
@ -483,7 +483,7 @@ class Device(DeviceConfig, DevicePlugin):
|
|||||||
self._card_a_prefix = get_card_prefix('carda')
|
self._card_a_prefix = get_card_prefix('carda')
|
||||||
self._card_b_prefix = get_card_prefix('cardb')
|
self._card_b_prefix = get_card_prefix('cardb')
|
||||||
|
|
||||||
def find_device_nodes(self):
|
def find_device_nodes(self, detected_device=None):
|
||||||
|
|
||||||
def walk(base):
|
def walk(base):
|
||||||
base = os.path.abspath(os.path.realpath(base))
|
base = os.path.abspath(os.path.realpath(base))
|
||||||
@ -507,8 +507,11 @@ class Device(DeviceConfig, DevicePlugin):
|
|||||||
d, j = os.path.dirname, os.path.join
|
d, j = os.path.dirname, os.path.join
|
||||||
usb_dir = None
|
usb_dir = None
|
||||||
|
|
||||||
|
if detected_device is None:
|
||||||
|
detected_device = self.detected_device
|
||||||
|
|
||||||
def test(val, attr):
|
def test(val, attr):
|
||||||
q = getattr(self.detected_device, attr)
|
q = getattr(detected_device, attr)
|
||||||
return q == val
|
return q == val
|
||||||
|
|
||||||
for x, isfile in walk('/sys/devices'):
|
for x, isfile in walk('/sys/devices'):
|
||||||
@ -596,6 +599,8 @@ class Device(DeviceConfig, DevicePlugin):
|
|||||||
label = self.STORAGE_CARD2_VOLUME_LABEL
|
label = self.STORAGE_CARD2_VOLUME_LABEL
|
||||||
if not label:
|
if not label:
|
||||||
label = self.STORAGE_CARD_VOLUME_LABEL + ' 2'
|
label = self.STORAGE_CARD_VOLUME_LABEL + ' 2'
|
||||||
|
if not label:
|
||||||
|
label = 'E-book Reader (%s)'%type
|
||||||
extra = 0
|
extra = 0
|
||||||
while True:
|
while True:
|
||||||
q = ' (%d)'%extra if extra else ''
|
q = ' (%d)'%extra if extra else ''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user