当前位置: 首页>>代码示例>>Python>>正文


Python win32api.GetLogicalDriveStrings方法代码示例

本文整理汇总了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?") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:testwnet.py

示例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?") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:test_win32wnet.py

示例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 
开发者ID:RainingComputers,项目名称:whipFTP,代码行数:27,代码来源:drive_detect.py

示例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 
开发者ID:sithis993,项目名称:Crypter,代码行数:19,代码来源:Base.py

示例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')] 
开发者ID:mbusb,项目名称:multibootusb,代码行数:5,代码来源:win32.py

示例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] 
开发者ID:google,项目名称:rekall,代码行数:6,代码来源:windows.py

示例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 
开发者ID:51x,项目名称:WHP,代码行数:31,代码来源:windows-privesc-check.py

示例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] 
开发者ID:refack,项目名称:GYP3,代码行数:13,代码来源:gyptest-generator-output-different-drive.py

示例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 [] 
开发者ID:alesnav,项目名称:p2ptv-pi,代码行数:9,代码来源:BaseApp.py

示例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
    ] 
开发者ID:winpython,项目名称:winpython,代码行数:9,代码来源:make.py

示例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] 
开发者ID:turbulenz,项目名称:gyp,代码行数:8,代码来源:gyptest-generator-output-different-drive.py

示例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 
开发者ID:SekoiaLab,项目名称:Fastir_Collector,代码行数:11,代码来源:utils.py

示例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 
开发者ID:SekoiaLab,项目名称:Fastir_Collector,代码行数:11,代码来源:utils.py

示例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] 
开发者ID:kawalpemilu,项目名称:kawalpemilu2014,代码行数:8,代码来源:gyptest-generator-output-different-drive.py

示例15: GetLogicalDriveStrings

# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetLogicalDriveStrings [as 别名]
def GetLogicalDriveStrings():
    return Api.GetLogicalDriveStrings().split("\0")[:-1] 
开发者ID:grawity,项目名称:code,代码行数:4,代码来源:df.py


注:本文中的win32api.GetLogicalDriveStrings方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。