sir_alex wrote:
Is there any function to see how much space is left on a device (such
as a usb key)? I'm trying to fill in an mp3 reader in a little script,
and this information could be very useful! Thanks!
On windows with the win32 extensions, you might try this:
# Get hard drive info from Windows.
drive = win32api.GetDiskFreeSpace('c:')
print drive[0], "sectors per cluster."
print drive[1], "bytes per sector."
print drive[2], "free clusters."
print drive[3], "total clusters."
You could use wmi to discover where the device has been mounted:
for item in c.Win32_DiskDrive():
print item
instance of Win32_DiskDrive
{
BytesPerSector = 512;
Capabilities = {3, 4, 7};
Caption = "M-SysT5 Dell Memory Key USB Device";
ConfigManagerErrorCode = 0;
ConfigManagerUserConfig = FALSE;
CreationClassName = "Win32_DiskDrive";
Description = "Disk drive";
DeviceID = "\\\\.\\PHYSICALDRIVE1";
Index = 1;
InterfaceType = "USB";
Manufacturer = "(Standard disk drives)";
MediaLoaded = TRUE;
MediaType = "Removable media other than\tfloppy";
Model = "M-SysT5 Dell Memory Key USB Device";
Name = "\\\\.\\PHYSICALDRIVE1";
Partitions = 1;
PNPDeviceID =
"USBSTOR\\DISK&VEN_M-SYST5&PROD_DELL_MEMORY_KEY&REV_5.00\\09809350C300C 9D7&0";
SectorsPerTrack = 63;
Signature = 2865277640;
Size = "254983680";
Status = "OK";
....