Skip to content

Commit

Permalink
[update-app] fix for getting disk space
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Hall <hsw@openmoko.com>
  • Loading branch information
hxw committed Aug 22, 2012
1 parent 128ddab commit c2bf763
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions update-app/winapi.py
Expand Up @@ -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
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

0 comments on commit c2bf763

Please sign in to comment.