Space left on device

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sir_alex

    #1

    Space left on device

    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!

  • rbt

    #2
    Re: Space left on device

    sir_alex wrote:[color=blue]
    > 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!
    >[/color]

    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";
    ....

    Comment

    Working...