python-distro-info hard to use for some cases

Bug #1253208 reported by Scott Moser
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
distro-info (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

Getting information out of distro_info for some common things such as getting fullname or version for a known codename is very difficult.
There is no easy way to get a full list of all the data to filter through.

I've written a 'get_ubuntu_info' method at https://gist.github.com/smoser/6784120#file-distro_info_dict
that gives me a list of dicts with info for each release for a given date. I called it 'get_ubuntu_info', but it works for debian.

It results in a list of dicts like:
 [{'codename': 'trusty', 'devel': True,
  'full_codename': 'Trusty Tahr', 'fullname': 'Ubuntu 14.04 LTS "Trusty Tahr"',
  'lts': True, 'supported': True, 'version': '14.04'}]

Perhaps we could add a helper like this in the library?

It also seems there is a smll bug in output formatting if a release does not have a version (Sid and Experimental):
  >>> distro_info.DebianDistroInfo().supported(result="fullname")
  >>> ['Debian 6.0 "Squeeze"', 'Debian 7.0 "Wheezy"', 'Debian 8.0 "Jessie"', 'Debian "Sid"', 'Debian "Experimental"']

ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: distro-info 0.8.2
ProcVersionSignature: User Name 3.2.0-56.86-virtual 3.2.51
Uname: Linux 3.2.0-56-virtual x86_64
ApportVersion: 2.0.1-0ubuntu17.6
Architecture: amd64
Date: Wed Nov 20 17:12:42 2013
Ec2AMI: ami-000005ec
Ec2AMIManifest: FIXME
Ec2AvailabilityZone: nova
Ec2InstanceType: m1.tiny
Ec2Kernel: aki-00000548
Ec2Ramdisk: ari-00000548
MarkForUpload: True
ProcEnviron:
 TERM=screen
 PATH=(custom, no user)
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: distro-info
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Scott Moser (smoser) wrote :
description: updated
description: updated
Revision history for this message
Scott Moser (smoser) wrote :

For information, some conversation occurred on this in ubuntu-devel at [1] continuing into [2].
  [1] http://irclogs.ubuntu.com/2013/11/20/%23ubuntu-devel.html#t22:21
  [2] http://irclogs.ubuntu.com/2013/11/21/%23ubuntu-devel.html

[19:20] <smoser> bdrung, thoughts? https://bugs.launchpad.net/ubuntu/+source/distro-info/+bug/1253208
[22:21] <bdrung> smoser: hi, i am happy to accept patches.
[22:22] <bdrung> smoser: returning a dict has the drawback that it could be hard to support if we want to change the internal
[22:22] <bdrung> smoser: we could add functions instead that take a series and return the fullname/version/etc
[01:07] <smoser> bdrung, i think its generally more functional to give me straightforward access to all data.
[01:08] <bdrung> smoser: i would prefer to keep a simple, supportable API.
[01:08] <smoser> how is returning a dict of data not supportable?
[01:10] <smoser> many times i've wanted data in the form that my function gets it.
[01:11] <smoser> its very common to want a release adjective, its version, and whether or not its an lts.
[01:29] <smoser> oh, i see. you're thinking about api other than python.
[01:29] <smoser> :-(.
[01:39] <bdrung> smoser: in case we want to change the file format, the content of the dict could change. the question is: which attributes would we guarantee to be present?
[01:41] <smoser> which of the ones i have there would you imply would not be present?
[01:41] <smoser> i didn't expose anything not already exposed
[01:41] <smoser> other than more conveniently
[01:42] <bdrung> we export codename, fullname, and release
[01:43] <bdrung> and codename
[01:43] <bdrung> how about accepting "all" as result to return a dict with these values?
[01:44] <bdrung> smoser: and you probably want a function that can map a codename to this kind of dict
[01:44] <bdrung> i'll go to bed now. good night.

Changed in distro-info (Ubuntu):
status: New → Confirmed
importance: Undecided → Medium
Revision history for this message
Benjamin Drung (bdrung) wrote :

I implemented a DistroRelease class. Example call:

distros = distro_info.UbuntuDistroInfo().get_all(result="object")

Revision history for this message
Stefano Rivera (stefanor) wrote :

Looking through old bugs, I assume we can call that solution sufficient. Closing.

Changed in distro-info (Ubuntu):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.