~ubuntu-branches/ubuntu/lucid/landscape-client/lucid

« back to all changes in this revision

Viewing changes to landscape/lib/lsb_release.py

  • Committer: Bazaar Package Importer
  • Author(s): Free Ekanayaka
  • Date: 2009-12-16 10:50:05 UTC
  • mfrom: (1.2.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 27.
  • Revision ID: james.westby@ubuntu.com-20091216105005-bmki8i2of1dmcdkc
Tags: 1.4.0-0ubuntu0.9.10.0
* New upstream release (LP: #497351)

* Bug fixes:
  - Fix landscape daemons fail to start when too many groups are
    available (LP: #456124)
  - Fix landscape programs wake up far too much. (LP: #340843)
  - Fix Package manager fails with 'no such table: task' (LP #465846)
  - Fix test suite leaving temporary files around (LP #476418)
  - Fix the 1hr long wait for user data to be uploaded following a
    resynchronisation (LP #369000)

* Add support for Ubuntu release upgrades:
  - Add helper function to fetch many files at once (LP: #450629)
  - Handle release-upgrade messages in the packagemanager
    plugin (LP: #455217)
  - Add a release-upgrader task handler (LP: #462543)
  - Support upgrade-tool environment variables (LP: #463321)

* Add initial support for Smart package locking:
  - Detect and report changes about Smart package locks (#488108)

* Packaging fixes:
  - Turn unnecessary Pre-Depends on python-gobject into a regular Depends
  - If it's empty, remove /etc/landscape upon purge

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""Get information from /etc/lsb_release."""
 
2
 
 
3
LSB_RELEASE_FILENAME = "/etc/lsb-release"
 
4
LSB_RELEASE_INFO_KEYS = {"DISTRIB_ID": "distributor-id",
 
5
                         "DISTRIB_DESCRIPTION": "description",
 
6
                         "DISTRIB_RELEASE": "release",
 
7
                         "DISTRIB_CODENAME": "code-name"}
 
8
 
 
9
 
 
10
def parse_lsb_release(lsb_release_filename):
 
11
    """Return a C{dict} holding information about the system LSB release.
 
12
 
 
13
    @raises: An IOError exception if C{lsb_release_filename} could not be read.
 
14
    """
 
15
    fd = open(lsb_release_filename, "r")
 
16
    info = {}
 
17
    try:
 
18
        for line in fd:
 
19
            key, value = line.split("=")
 
20
            if key in LSB_RELEASE_INFO_KEYS:
 
21
                key = LSB_RELEASE_INFO_KEYS[key.strip()]
 
22
                value = value.strip().strip('"')
 
23
                info[key] = value
 
24
    finally:
 
25
        fd.close()
 
26
    return info