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.GetDis kFreeSpace('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_DiskDri ve():
print item
instance of Win32_DiskDrive
{
BytesPerSector = 512;
Capabilities = {3, 4, 7};
Caption = "M-SysT5 Dell Memory Key USB Device";
ConfigManagerEr rorCode = 0;
ConfigManagerUs erConfig = FALSE;
CreationClassNa me = "Win32_DiskDriv e";
Description = "Disk drive";
DeviceID = "\\\\.\\PHYSICA LDRIVE1";
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 = "\\\\.\\PHYSICA LDRIVE1";
Partitions = 1;
PNPDeviceID =
"USBSTOR\\DISK& VEN_M-SYST5&PROD_DELL _MEMORY_KEY&REV _5.00\\09809350 C300C9D7&0";
SectorsPerTrack = 63;
Signature = 2865277640;
Size = "254983680" ;
Status = "OK";
....