Python win32api 模块,GetVolumeInformation() 实例源码

我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用win32api.GetVolumeInformation()

项目:lib9    作者:Jumpscale    | 项目源码 | 文件源码
def isNTFSVolume(self, driveletter):
        """Boolean indicating whether a volume is NTFS

        @param driveletter: The letter of the drive to check
        @type driveletter: string
        """

        # Strip away : / \
        while driveletter.endswith(":") or driveletter.endswith("\\") or driveletter.endswith("/"):
            driveletter = driveletter[:-1]
        if not len(driveletter) == 1:
            raise ValueError(
                "Wrong parameter for WindowsSystem.isNTFSVolume: [%s] is not a valid drive letter." % driveletter)
        fTest = '%s:\\' % driveletter
        volumeInformation = win32api.GetVolumeInformation(fTest)
        fileSystem = volumeInformation[4]
        result = fileSystem == 'NTFS'
        return result
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __is_cd_inserted(self, drive=''):
        try:
            x = win32api.GetVolumeInformation(drive)
            #print "CD is inserted in drive %s" % drive
            return 1
        except:
            #print "no CD inserted in drive %s" % drive
            return 0
项目:bksync    作者:oddy    | 项目源码 | 文件源码
def DriveNameToPath(drive):
    if os.name=='nt':
        import win32api
        namePaths = { win32api.GetVolumeInformation(i)[0].lower():i for i in win32api.GetLogicalDriveStrings().split('\0') if i }
        drive = drive.lower()
        if drive not in namePaths:  raise ValueError('Drive name "%s" not found' % drive)
        return namePaths[drive]
    else:
        raise NotImplementedError       # todo: do something with /media/XXX here for ubuntu
项目:LHF    作者:blindfuzzy    | 项目源码 | 文件源码
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