RE: How do I get the device description from a device object?



On Thu, 2011-08-25 at 15:43 -0500, Vallevand, Mark K wrote:
> Thanks for the prompt response.  I was looking for whatever nm-applet is doing.  I've been looking at the nm-applet code and it's clear that there isn't single source of information to get a device description.  I've got code that mostly works by scraping information from /sys.  However, I'll look at the libnm-glib/nm-device.c code as suggested.

Screenscraping /sys might be the best way to go for now, but you can
also use libudev or even just 'udevadm info ...' and grabbing the
output.  NM's 'Udi' property on each device should give you a path you
can feed to udevadm info --path= .

Dan


> Again, thanks.
> 
> Regards.
> Mark K Vallevand   Mark Vallevand Unisys com <mailto:Mark Vallevand Unisys com> 
> 
> Eagles may soar, but weasels don't get sucked into jet engines.
> 
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
> 
> 
> -----Original Message-----
> From: Dan Williams [mailto:dcbw redhat com] 
> Sent: Thursday, August 25, 2011 3:35 PM
> To: Vallevand, Mark K
> Cc: networkmanager-list gnome org
> Subject: Re: How do I get the device description from a device object?
> 
> On Thu, 2011-08-25 at 12:41 -0500, Vallevand, Mark K wrote:
> > I’m using python and everything is OK, except that I can’t find a way
> > to get a device description from a device object.
> 
> What kind of description are you looking for?  Like what's shown in the
> nm-applet menu or such?  If so, that description isn't provided by NM
> itself (because any device description isn't really stable and might
> change depending on what components you have in the system), but is
> handled by 'libnm-glib' which you probably wouldn't be using with your
> python program.
> 
> libnm-glib builds the description by looking for the device's entry the
> udev database, and grabbing the ID_VENDOR_ENC/ID_MODEL_ENC fields.  udev
> fills these fields from various sources, including the device itself (if
> any textual description is available) and from static files like
> pci.ids/usb.ids/pnp.ids.  If the device node itself doesn't have
> anything, it queries the parent and grandparent.  (see
> libnm-glib/nm-device.c's _device_update_description() method).
> 
> nm-applet attempts to fix this string up by replacing certain words and
> removing other words (like "Inc" and "Company") which is kinda fragile
> but pretty much works. (see network-manager-applet's src/utils/utils.c
> utils_get_device_description() method).
> 
> I'd entertain the idea of adding this feature as a property of the
> device objects in core NetworkManager, but realize that it (a) wouldn't
> be translated at all to different languages, and (b) wouldn't be a
> stable description across even minor system updates.
> 
> Dan
> 
> >  
> > 
> > A quick pointer is welcome.
> > 
> > Regards.
> > Mark K Vallevand   Mark Vallevand Unisys com
> > 
> > Eagles may soar, but weasels don't get sucked into jet engines.
> > 
> > THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE
> > PROPRIETARY MATERIAL and is thus for use only by the intended
> > recipient. If you received this in error, please contact the sender
> > and delete the e-mail and its attachments from all computers.
> > 
> > 
> > _______________________________________________
> > networkmanager-list mailing list
> > networkmanager-list gnome org
> > http://mail.gnome.org/mailman/listinfo/networkmanager-list
> 
> 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]