forked from openlp/openlp
Fix optical drive detection on windows
This commit is contained in:
parent
d402bf86cb
commit
6f7f3be3ff
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
from ctypes import windll
|
from win32com.client import Dispatch
|
||||||
import string
|
import string
|
||||||
import sys
|
import sys
|
||||||
if sys.platform.startswith('linux'):
|
if sys.platform.startswith('linux'):
|
||||||
@ -581,18 +581,13 @@ class MediaClipSelectorForm(QtGui.QDialog, Ui_MediaClipSelector):
|
|||||||
# insert empty string as first item
|
# insert empty string as first item
|
||||||
self.media_path_combobox.addItem('')
|
self.media_path_combobox.addItem('')
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
# use win api to fine optical drives
|
# use win api to find optical drives
|
||||||
bitmask = windll.kernel32.GetLogicalDrives()
|
fso = Dispatch('scripting.filesystemobject')
|
||||||
for letter in string.uppercase:
|
for drive in fso.Drives :
|
||||||
if bitmask & 1:
|
log.debug('Drive %s has type %d' % (drive.DriveLetter, drive.DriveType))
|
||||||
try:
|
# if type is 4, it is a cd-rom drive
|
||||||
type = windll.kernel32.GetDriveTypeW('%s:\\' % letter)
|
if drive.DriveType == 4:
|
||||||
# if type is 5, it is a cd-rom drive
|
self.media_path_combobox.addItem('%s:\\' % drive.DriveLetter)
|
||||||
if type == 5:
|
|
||||||
self.media_path_combobox.addItem('%s:\\' % letter)
|
|
||||||
except Exception as e:
|
|
||||||
log.debug('Exception while looking for optical drives: ', e)
|
|
||||||
bitmask >>= 1
|
|
||||||
elif sys.platform.startswith('linux'):
|
elif sys.platform.startswith('linux'):
|
||||||
# Get disc devices from dbus and find the ones that are optical
|
# Get disc devices from dbus and find the ones that are optical
|
||||||
bus = dbus.SystemBus()
|
bus = dbus.SystemBus()
|
||||||
|
Loading…
Reference in New Issue
Block a user