~mvo/software-center/fedora

« back to all changes in this revision

Viewing changes to softwarecenter/distro/__init__.py

  • Committer: Giovanni Campagna
  • Date: 2011-12-02 14:16:26 UTC
  • Revision ID: gcampagna@src.gnome.org-20111202141626-czxga8imp6ijid5h
distro: don't use lsb_release

lsb_release is not available in all distributions (in particular,
it's missing in Fedora). Instead, we can use builtin module
platform to obtain the distribution name.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import os
22
22
 
23
23
from gettext import gettext as _
24
 
import lsb_release
 
24
import platform
25
25
 
26
26
from softwarecenter.utils import UnimplementedError, utf8
27
27
 
46
46
    # Point developers to a web page
47
47
    DEVELOPER_URL = ""
48
48
 
49
 
    def __init__(self, lsb_info):
 
49
    def __init__(self):
50
50
        """Return a new generic Distro instance."""
51
 
        self.lsb_info = lsb_info
52
51
 
53
52
    def get_app_name(self):
54
53
        """ 
79
78
            return os.environ["SOFTWARE_CENTER_DISTRO_CODENAME"]
80
79
        # normal behavior
81
80
        if not hasattr(self, "_distro_code_name"):
82
 
            self._distro_code_name = \
83
 
                    lsb_release.get_distro_information()["CODENAME"]
 
81
            self._distro_code_name = platform.dist()[2]
84
82
        return self._distro_code_name
85
83
 
86
84
    def get_maintenance_status(self, cache, appname, pkgname, component, channelname):
155
153
 
156
154
 
157
155
def _get_distro():
158
 
    lsb_info = lsb_release.get_distro_information()
159
 
    distro_id = lsb_info["ID"]
 
156
    distro_info = platform.linux_distribution()
 
157
    distro_id = distro_info[0]
160
158
    log.debug("get_distro: '%s'", distro_id)
161
159
    # start with a import, this gives us only a softwarecenter module
162
160
    module =  __import__(distro_id, globals(), locals(), [], -1)
163
161
    # get the right class and instanciate it
164
162
    distro_class = getattr(module, distro_id)
165
 
    instance = distro_class(lsb_info)
 
163
    instance = distro_class()
166
164
    return instance
167
165
 
168
166
def get_distro():