Getting USB volume serial number from inserted device on OSX

John Nagle nagle at animats.com
Thu Apr 4 21:58:42 EDT 2013


On 4/2/2013 3:18 PM, Sven wrote:
> Hello,
> 
> I am using Python 2.7 with pyobjc on Lion and NSNotification center to
> monitor any inserted USB volumes. This works fine.
> 
> I've also got some ideas how to get a device's serial number, but these
> involve just parsing all the USB devices ('system_profiler SPUSBDataType'
> command). However I'd like to specifically query the inserted device only
> (the one creating the notification) rather than checking the entire USB
> device list. The latter seems a little inefficient and "wrong".

   That would be useful to have as a portable function for all USB
devices.  Serial port devices are particularly annoying, because their
port number is somewhat random when there's more than one, and changes
on hot-plugging.

				John Nagle



More information about the Python-list mailing list