简体   繁体   中英

Finding Volume Label of a usb mass storage device using python

Could someone please tell me how I could obtain a usb mass storage device's volume label(the name displayed in the explorer, not the device name::/dev/sdX) using python? HAL has deprecated so please don't suggest it as an option.

EDIT: Is there a way to do it using pyudev or pyusb??

If you don't want to use HAL you could do it by calling a subprocess .

import subprocess

mounts = {}

for line in subprocess.check_output(['mount', '-l']).split('\n'):
    parts = line.split(' ')
    if len(parts) > 2:
        mounts[parts[2]] = parts[0]

print mounts

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM