Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #42609 > unrolled thread

Getting USB volume serial number from inserted device on OSX

Started bySven <svenito@gmail.com>
First post2013-04-02 23:18 +0100
Last post2013-04-05 14:23 +0100
Articles 4 — 3 participants

Back to article view | Back to comp.lang.python


Contents

  Getting USB volume serial number from inserted device on OSX Sven <svenito@gmail.com> - 2013-04-02 23:18 +0100
    Re: Getting USB volume serial number from inserted device on OSX John Nagle <nagle@animats.com> - 2013-04-04 18:58 -0700
      Re: Getting USB volume serial number from inserted device on OSX Tim Roberts <timr@probo.com> - 2013-04-04 22:20 -0700
        Re: Getting USB volume serial number from inserted device on OSX Sven <svenito@gmail.com> - 2013-04-05 14:23 +0100

#42609 — Getting USB volume serial number from inserted device on OSX

FromSven <svenito@gmail.com>
Date2013-04-02 23:18 +0100
SubjectGetting USB volume serial number from inserted device on OSX
Message-ID<mailman.25.1364941140.3114.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

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

[toc] | [next] | [standalone]


#42787

FromJohn Nagle <nagle@animats.com>
Date2013-04-04 18:58 -0700
Message-ID<kjlavt$v8j$1@dont-email.me>
In reply to#42609
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

[toc] | [prev] | [next] | [standalone]


#42792

FromTim Roberts <timr@probo.com>
Date2013-04-04 22:20 -0700
Message-ID<2knsl8t9uacsb612cd2kuv43ipr7djrcmg@4ax.com>
In reply to#42787
John Nagle <nagle@animats.com> wrote:
>
>   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.

There is no portable solution.  Every operating system handles this kind of
this very differently.  Remember, the operating system abstractions are all
designed to hide this from you.  When you open a serial port or an audio
device or use a file system, you aren't supposed to KNOW that there is a
USB device behind it.
-- 
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

[toc] | [prev] | [next] | [standalone]


#42816

FromSven <svenito@gmail.com>
Date2013-04-05 14:23 +0100
Message-ID<mailman.139.1365168203.3114.python-list@python.org>
In reply to#42792

[Multipart message — attachments visible in raw view] — view raw

On 5 April 2013 06:20, Tim Roberts <timr@probo.com> wrote:

> John Nagle <nagle@animats.com> wrote:
> >
> >   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.
>
> There is no portable solution.  Every operating system handles this kind of
> this very differently.  Remember, the operating system abstractions are all
> designed to hide this from you.  When you open a serial port or an audio
> device or use a file system, you aren't supposed to KNOW that there is a
> USB device behind it
>

Indeed. Which means I have a working solution under Linux, but I am
struggling to find one under OS  X.

Looks like I might have to resort to just parsing the USB tree until I find
the device that was inserted.

-- 
./Sven

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web