diff options
| author | glatzor@ubuntu.com <> | 2006-08-02 21:41:27 +0200 |
|---|---|---|
| committer | glatzor@ubuntu.com <> | 2006-08-02 21:41:27 +0200 |
| commit | 1b2f3650122a3c7d1997287b8d915f9f54402549 (patch) | |
| tree | fbca309b7619f20bb2211a2a7d2294374d1c8fec /UpdateManager | |
| parent | c0e73bb5c6213aa0bc9e0609f9f1d7da254ea2b1 (diff) | |
| download | python-apt-1b2f3650122a3c7d1997287b8d915f9f54402549.tar.gz | |
* use -s option instead of the pipe to cut to get lsb information
* make the origin matcher distribution neutral
* introduce a UpdateOrigin class to make the origins sortable (by
importance)
Diffstat (limited to 'UpdateManager')
| -rw-r--r-- | UpdateManager/Common/DistInfo.py | 2 | ||||
| -rw-r--r-- | UpdateManager/Common/aptsources.py | 2 | ||||
| -rw-r--r-- | UpdateManager/UpdateManager.py | 43 |
3 files changed, 31 insertions, 16 deletions
diff --git a/UpdateManager/Common/DistInfo.py b/UpdateManager/Common/DistInfo.py index 7d2d37ad..79d5356c 100644 --- a/UpdateManager/Common/DistInfo.py +++ b/UpdateManager/Common/DistInfo.py @@ -56,7 +56,7 @@ class DistInfo: self.suites = [] if not dist: - pipe = os.popen("lsb_release -i | cut -d : -f 2-") + pipe = os.popen("lsb_release -i -s") dist = pipe.read().strip() pipe.close() del pipe diff --git a/UpdateManager/Common/aptsources.py b/UpdateManager/Common/aptsources.py index 3d317b15..fd77fe63 100644 --- a/UpdateManager/Common/aptsources.py +++ b/UpdateManager/Common/aptsources.py @@ -452,7 +452,7 @@ class Distribution: # get the LSB information lsb_info = [] for lsb_option in ["-i", "-c", "-d", "-r"]: - pipe = os.popen("lsb_release %s | cut -d : -f 2-" % lsb_option) + pipe = os.popen("lsb_release %s -s" % lsb_option) lsb_info.append(pipe.read().strip()) del pipe (self.id, self.codename, self.description, self.release) = lsb_info diff --git a/UpdateManager/UpdateManager.py b/UpdateManager/UpdateManager.py index be9434ae..0d50a0cc 100644 --- a/UpdateManager/UpdateManager.py +++ b/UpdateManager/UpdateManager.py @@ -200,19 +200,31 @@ class MyCache(apt.Cache): lock.release() class UpdateList: - ORIGIN_MAPPING = { ("edgy-security","Ubuntu"): _("Important security " - "updates of Ubuntu"), - ("edgy-updates","Ubuntu"): _("Recommended updates " - "of Ubuntu"), - ("edgy-backports","Ubuntu"): _("Backports of Ubuntu"), - ("edgy","Ubuntu"): _("Updates of Ubuntu") - } + class UpdateOrigin: + def __init__(self, desc, importance): + self.packages = [] + self.importance = importance + self.description = desc def __init__(self, parent_window): # a map of packages under their origin + pipe = os.popen("lsb_release -c -s") + dist = pipe.read().strip() + del pipe + + templates = [("%s-security" % dist,"Ubuntu", _("Important security updates " + "of Ubuntu"), 0), + ("%s-updates" % dist,"Ubuntu", _("Recommended updates of " + "Ubuntu"), 1), + ("%s-backports" % dist,"Ubuntu", _("Backports of Ubuntu"), 2), + (dist,"Ubuntu", _("Updates of Ubuntu"), 3)] + self.pkgs = {} + self.matcher = {} self.num_updates = 0 self.parent_window = parent_window + for (origin, archive, desc, importance) in templates: + self.matcher[(origin, archive)] = self.UpdateOrigin(desc, importance) def update(self, cache): held_back = [] @@ -229,11 +241,11 @@ class UpdateList: for aorigin in pkg.candidateOrigin: archive = aorigin.archive origin = aorigin.origin - if self.ORIGIN_MAPPING.has_key((archive,origin)) and aorigin.trusted: - originstr = self.ORIGIN_MAPPING[(archive,origin)] - if not self.pkgs.has_key(originstr): - self.pkgs[originstr] = [] - self.pkgs[originstr].append(pkg) + if self.matcher.has_key((archive,origin)) and aorigin.trusted: + origin_node = self.matcher[(archive,origin)] + if not self.pkgs.has_key(origin_node): + self.pkgs[origin_node] = [] + self.pkgs[origin_node].append(pkg) self.num_updates = self.num_updates + 1 elif pkg.isUpgradable: held_back.append(pkg.name) @@ -700,8 +712,11 @@ class UpdateManager(SimpleGladeApp): self.list.update(self.cache) if self.list.num_updates > 0: i=0 - for origin in self.list.pkgs.keys(): - self.store.append([False,'<b><big>%s</big></b>' % origin, origin, None]) + origin_list = self.list.pkgs.keys() + origin_list.sort(lambda x,y: cmp(x.importance,y.importance)) + for origin in origin_list: + self.store.append([False,'<b><big>%s</big></b>' % origin.description, + origin.description, None]) for pkg in self.list.pkgs[origin]: name = xml.sax.saxutils.escape(pkg.name) summary = xml.sax.saxutils.escape(pkg.summary) |
