It appears you need to use the win32 interface for write access to
physical drives. CAUTION: This code writes over the first sector of a
USB drive.

    for physical_disk in c.Win32_DiskDrive (Index=1,InterfaceType='USB'):
        sector_size = int(physical_disk.BytesPerSector)
        total_sectors = int(physical_disk.TotalSectors)

        fill_value = 0

        # create an array of bytes used to write to the drive
        fill = array.array('B')
        for num in xrange(sector_size):
            fill.append(fill_value)

        h = win32file.CreateFile(physical_disk.DeviceID,
                                 win32con.GENERIC_WRITE,
                                 0,
                                 None,
                                 win32file.OPEN_EXISTING,
                                 win32file.FILE_ATTRIBUTE_NORMAL,
                                 None)

        err_code, num_written = win32file.WriteFile(h, fill, None)

        # close the file for clean exit
        win32file.CloseHandle(h)

Thanks for the help.
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to