In python if I know the volume label of a USB mass storage device is there a way to get its.

Drive letter Windows
Mount Point Linux
Mount Point OSX

Originally I was thinking either the sys library or the os library. i ahve found another library called PYUSB. Still researching it. but wondered if anyone knew of a good solution.

Recommended Answers

All 2 Replies

psutil is good.
Here a run on my windows and Mint(VirtualBox)

>>> import psutil
>>> psutil.disk_partitions()
[sdiskpart(device='C:\\', mountpoint='C:\\', fstype='NTFS', opts='rw,fixed'),
 sdiskpart(device='D:\\', mountpoint='D:\\', fstype='', opts='cdrom'),
 sdiskpart(device='E:\\', mountpoint='E:\\', fstype='NTFS', opts='rw,fixed'),
 sdiskpart(device='F:\\', mountpoint='F:\\', fstype='UDF', opts='ro,cdrom'),
 sdiskpart(device='G:\\', mountpoint='G:\\', fstype='NTFS', opts='rw,fixed')]
>>> psutil.disk_usage('C:\\')
sdiskusage(total=255953203200L, used=177126027264L, free=78827175936L, percent=69.2)

Mint:

>>> import psutil
>>> psutil.disk_partitions()
[partition(device='/dev/sda1', mountpoint='/', fstype='ext4', opts='rw,errors=remount-ro')]
>>> psutil.disk_io_counters()
iostat(read_count=32177, write_count=6804, read_bytes=833645568, write_bytes=317702144, read_time=123880, write_time=124128)

Also notice that the information returned resides in named tuples.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.