Getting USB volume serial number from inserted device on OSX

Sven svenito at gmail.com
Tue Apr 2 18:18:58 EDT 2013


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

Can this be accomplished in a sensible way? The NSNotification object
passed to my handler function doesn't have that kind of information and
I've not been able to find any information on doing the above with the
information provided by the NSNotification object.

I've tried DBus (I use this for the linux handler) but I've not had much
luck getting it to work reliably on OS X and installing it wasn't as
straightforward as I hoped.

I have no requirement to use pyobjc so other suggestions welcome as long as
it's straightforward to install and without too many other dependencies.
I'd like to keep installation straightforward for the end users.
Thanks

-- 
./Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130402/5a0668e1/attachment.html>


More information about the Python-list mailing list