當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。