trying be a little more platform independant
This commit is contained in:
@@ -17,11 +17,10 @@ from PyQt5 import QtCore, QtGui, QtNetwork, QtWebEngineWidgets, QtWidgets
|
||||
from PyQt5.uic import loadUi
|
||||
|
||||
try:
|
||||
import win32api
|
||||
import win32file
|
||||
except ImportError:
|
||||
if platform.system()=='Windows':
|
||||
raise #require win32api and win32file on windows
|
||||
raise #require win32file on windows
|
||||
|
||||
from validators.location_validator import Location_Validator
|
||||
from .menu_iterator import MenuIterator
|
||||
@@ -74,14 +73,12 @@ class InstallerWizard(QtWidgets.QWizard):
|
||||
if no suitable external device is found
|
||||
"""
|
||||
if platform.system() == 'Windows':
|
||||
drives = [drive for drive in win32api.GetLogicalDriveStrings().split('\0') if drive]
|
||||
dialog_location = drives.pop()
|
||||
while (win32file.GetDriveType(dialog_location) == win32file.DRIVE_CDROM
|
||||
or win32file.GetDriveType(dialog_location) == win32file.DRIVE_REMOTE):
|
||||
dialog_location = drives.pop()
|
||||
if dialog_location == "C:\\":
|
||||
dialog_location = Path.home()
|
||||
break
|
||||
#get all drives read-writable drives except C:\
|
||||
drives = [drive for drive in psutil.disk_partitions(all = True) if drive.device not in ("","C:\\") and "rw" in drive.opts]
|
||||
if drives: #drives other than C:\ exist, are likely installation locations
|
||||
dialog_location = Path(drives[0].mountpoint)
|
||||
else: #C:\ was only drive, so start in user home
|
||||
dialog_location = Path.home()
|
||||
else:
|
||||
dialog_location = Path.home()
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class Location_Validator(QtGui.QValidator):
|
||||
Arguments:
|
||||
location {str} -- A string representing a folder path
|
||||
"""
|
||||
match = [drive for drive in psutil.disk_partitions() if (Path(drive.mountpoint) in Path(location).parents and drive.fstype.lower() == "ntfs")]
|
||||
match = [drive for drive in psutil.disk_partitions(all = True) if (Path(drive.mountpoint) in Path(location).parents and drive.fstype.lower() == "ntfs")]
|
||||
if match:
|
||||
self._ntfs_location_selected = True
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user