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
|
from PyQt5.uic import loadUi
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import win32api
|
|
||||||
import win32file
|
import win32file
|
||||||
except ImportError:
|
except ImportError:
|
||||||
if platform.system()=='Windows':
|
if platform.system()=='Windows':
|
||||||
raise #require win32api and win32file on windows
|
raise #require win32file on windows
|
||||||
|
|
||||||
from validators.location_validator import Location_Validator
|
from validators.location_validator import Location_Validator
|
||||||
from .menu_iterator import MenuIterator
|
from .menu_iterator import MenuIterator
|
||||||
@@ -74,17 +73,15 @@ class InstallerWizard(QtWidgets.QWizard):
|
|||||||
if no suitable external device is found
|
if no suitable external device is found
|
||||||
"""
|
"""
|
||||||
if platform.system() == 'Windows':
|
if platform.system() == 'Windows':
|
||||||
drives = [drive for drive in win32api.GetLogicalDriveStrings().split('\0') if drive]
|
#get all drives read-writable drives except C:\
|
||||||
dialog_location = drives.pop()
|
drives = [drive for drive in psutil.disk_partitions(all = True) if drive.device not in ("","C:\\") and "rw" in drive.opts]
|
||||||
while (win32file.GetDriveType(dialog_location) == win32file.DRIVE_CDROM
|
if drives: #drives other than C:\ exist, are likely installation locations
|
||||||
or win32file.GetDriveType(dialog_location) == win32file.DRIVE_REMOTE):
|
dialog_location = Path(drives[0].mountpoint)
|
||||||
dialog_location = drives.pop()
|
else: #C:\ was only drive, so start in user home
|
||||||
if dialog_location == "C:\\":
|
dialog_location = Path.home()
|
||||||
dialog_location = Path.home()
|
|
||||||
break
|
|
||||||
else:
|
else:
|
||||||
dialog_location = Path.home()
|
dialog_location = Path.home()
|
||||||
|
|
||||||
selected_location = QtWidgets.QFileDialog.getExistingDirectory(parent=self,caption="Select Location",
|
selected_location = QtWidgets.QFileDialog.getExistingDirectory(parent=self,caption="Select Location",
|
||||||
directory=str(dialog_location),
|
directory=str(dialog_location),
|
||||||
options=(QtWidgets.QFileDialog.ShowDirsOnly))
|
options=(QtWidgets.QFileDialog.ShowDirsOnly))
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class Location_Validator(QtGui.QValidator):
|
|||||||
Arguments:
|
Arguments:
|
||||||
location {str} -- A string representing a folder path
|
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:
|
if match:
|
||||||
self._ntfs_location_selected = True
|
self._ntfs_location_selected = True
|
||||||
return True
|
return True
|
||||||
|
|||||||
Reference in New Issue
Block a user