From c2bf7639d289328ec976be751084251c4609c7d8 Mon Sep 17 00:00:00 2001 From: Christopher Hall Date: Wed, 22 Aug 2012 16:08:02 +0800 Subject: [PATCH] [update-app] fix for getting disk space Signed-off-by: Christopher Hall --- update-app/winapi.py | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/update-app/winapi.py b/update-app/winapi.py index e4fefb29f..8e3f6ce9b 100755 --- a/update-app/winapi.py +++ b/update-app/winapi.py @@ -2,25 +2,25 @@ This API only for MSW(Windows) version. """ -import wmi - -c = wmi.WMI() - -def getRemovableDisk(): - tmp = [] - disk = [] - for drive in c.Win32_LogicalDisk(DriveType=2): - tmp.append(str(drive.Caption)) - - for physical_disk in c.Win32_DiskDrive(): - if physical_disk.size: - for partition in physical_disk.associators ("Win32_DiskDriveToDiskPartition"): - for logical_disk in partition.associators ("Win32_LogicalDiskToPartition"): - if logical_disk.Caption in tmp: - disk.append(str(logical_disk.Caption)) - - return disk - -def getDiskSize(DeviceID): - disk = c.Win32_LogicalDisk(DeviceID="G:")[0] - return disk.size, disk.Freespace \ No newline at end of file +import wmi + +c = wmi.WMI() + +def getRemovableDisk(): + tmp = [] + disk = [] + for drive in c.Win32_LogicalDisk(DriveType=2): + tmp.append(str(drive.Caption)) + + for physical_disk in c.Win32_DiskDrive(): + if physical_disk.size: + for partition in physical_disk.associators ("Win32_DiskDriveToDiskPartition"): + for logical_disk in partition.associators ("Win32_LogicalDiskToPartition"): + if logical_disk.Caption in tmp: + disk.append(str(logical_disk.Caption)) + + return disk + +def getDiskSize(DeviceID="G:"): + disk = c.Win32_LogicalDisk(DeviceID=DeviceID)[0] + return disk.size, disk.Freespace