mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Windows device detection: If the driver order detection assigns the same drive order to disks on the device, use the drive letter when sorting.
This commit is contained in:
parent
02d68b83a1
commit
bcfbe81888
@ -30,6 +30,12 @@ class Drive(str):
|
|||||||
typ.order = order
|
typ.order = order
|
||||||
return typ
|
return typ
|
||||||
|
|
||||||
|
def drivecmp(a, b):
|
||||||
|
ans = cmp(getattr(a, 'order', 0), getattr(b, 'order', 0))
|
||||||
|
if ans == 0:
|
||||||
|
ans = cmp(a, b)
|
||||||
|
return ans
|
||||||
|
|
||||||
|
|
||||||
class WinPNPScanner(object):
|
class WinPNPScanner(object):
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ intended to be subclassed with the relevant parts implemented for a particular
|
|||||||
device. This class handles device detection.
|
device. This class handles device detection.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import os, subprocess, time, re, sys, glob, operator
|
import os, subprocess, time, re, sys, glob
|
||||||
from itertools import repeat
|
from itertools import repeat
|
||||||
|
|
||||||
from calibre.devices.interface import DevicePlugin
|
from calibre.devices.interface import DevicePlugin
|
||||||
@ -225,7 +225,7 @@ class Device(DeviceConfig, DevicePlugin):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def open_windows(self):
|
def open_windows(self):
|
||||||
from calibre.devices.scanner import win_pnp_drives
|
from calibre.devices.scanner import win_pnp_drives, drivecmp
|
||||||
|
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
drives = {}
|
drives = {}
|
||||||
@ -263,7 +263,7 @@ class Device(DeviceConfig, DevicePlugin):
|
|||||||
if self.WINDOWS_MAIN_MEM in (self.WINDOWS_CARD_A_MEM,
|
if self.WINDOWS_MAIN_MEM in (self.WINDOWS_CARD_A_MEM,
|
||||||
self.WINDOWS_CARD_B_MEM) or \
|
self.WINDOWS_CARD_B_MEM) or \
|
||||||
self.WINDOWS_CARD_A_MEM == self.WINDOWS_CARD_B_MEM:
|
self.WINDOWS_CARD_A_MEM == self.WINDOWS_CARD_B_MEM:
|
||||||
letters = sorted(drives.values(), key=operator.attrgetter('order'))
|
letters = sorted(drives.values(), cmp=drivecmp)
|
||||||
drives = {}
|
drives = {}
|
||||||
for which, letter in zip(['main', 'carda', 'cardb'], letters):
|
for which, letter in zip(['main', 'carda', 'cardb'], letters):
|
||||||
drives[which] = letter
|
drives[which] = letter
|
||||||
|
Loading…
x
Reference in New Issue
Block a user