mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-11 09:13:57 -04:00
Fix mount point detection bugs
This commit is contained in:
parent
23e90eb59d
commit
16dca3280c
@ -152,6 +152,7 @@ class PRS505(Device):
|
|||||||
|
|
||||||
|
|
||||||
def open_windows(self):
|
def open_windows(self):
|
||||||
|
drives = []
|
||||||
import wmi
|
import wmi
|
||||||
c = wmi.WMI()
|
c = wmi.WMI()
|
||||||
for drive in c.Win32_DiskDrive():
|
for drive in c.Win32_DiskDrive():
|
||||||
@ -164,13 +165,16 @@ class PRS505(Device):
|
|||||||
continue
|
continue
|
||||||
logical_disk = partition.associators('Win32_LogicalDiskToPartition')[0]
|
logical_disk = partition.associators('Win32_LogicalDiskToPartition')[0]
|
||||||
prefix = logical_disk.DeviceID+os.sep
|
prefix = logical_disk.DeviceID+os.sep
|
||||||
if drive.Index == 1:
|
drives.append((drive.Index, prefix))
|
||||||
self._main_prefix = prefix
|
|
||||||
else:
|
if not drives:
|
||||||
self._card_prefix = prefix
|
|
||||||
if self._main_prefix is None:
|
|
||||||
raise DeviceError('Unable to find %s. Is it connected?'%(self.__class__.__name__,))
|
raise DeviceError('Unable to find %s. Is it connected?'%(self.__class__.__name__,))
|
||||||
|
|
||||||
|
drives.sort(cmp=lambda a, b: cmp(a[0], b[0]))
|
||||||
|
self._main_prefix = drives[0][1]
|
||||||
|
if len(drives) > 1:
|
||||||
|
self._card_prefix = drives[1][1]
|
||||||
|
|
||||||
|
|
||||||
def open_linux(self):
|
def open_linux(self):
|
||||||
import dbus
|
import dbus
|
||||||
@ -203,18 +207,26 @@ class PRS505(Device):
|
|||||||
self._card_prefix = conditional_mount(sc)+os.sep
|
self._card_prefix = conditional_mount(sc)+os.sep
|
||||||
|
|
||||||
def open(self):
|
def open(self):
|
||||||
time.sleep(2)
|
time.sleep(5)
|
||||||
self._main_prefix = self._card_prefix = None
|
self._main_prefix = self._card_prefix = None
|
||||||
try:
|
if islinux:
|
||||||
if islinux:
|
try:
|
||||||
self.open_linux()
|
self.open_linux()
|
||||||
if iswindows:
|
except DeviceError:
|
||||||
|
time.sleep(3)
|
||||||
|
self.open_linux()
|
||||||
|
if iswindows:
|
||||||
|
try:
|
||||||
self.open_windows()
|
self.open_windows()
|
||||||
if isosx:
|
except DeviceError:
|
||||||
|
time.sleep(3)
|
||||||
|
self.open_windows()
|
||||||
|
if isosx:
|
||||||
|
try:
|
||||||
|
self.open_osx()
|
||||||
|
except DeviceError:
|
||||||
|
time.sleep(3)
|
||||||
self.open_osx()
|
self.open_osx()
|
||||||
except DeviceError:
|
|
||||||
time.sleep(4)
|
|
||||||
return self.open()
|
|
||||||
|
|
||||||
def set_progress_reporter(self, pr):
|
def set_progress_reporter(self, pr):
|
||||||
self.report_progress = pr
|
self.report_progress = pr
|
||||||
|
Loading…
x
Reference in New Issue
Block a user