From daae0c6265cf9491097a2a177766f55041fc6b83 Mon Sep 17 00:00:00 2001
From: Wade Brainerd <wadetb@gmail.com>
Date: Sun, 27 Sep 2009 20:30:28 -0400
Subject: [PATCH] Reject activity bundles which require a newer version of Sugar
---
src/jarabe/model/bundleregistry.py | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/src/jarabe/model/bundleregistry.py b/src/jarabe/model/bundleregistry.py
index b754952..77c9416 100644
a
|
b
|
class BundleRegistry(gobject.GObject): |
209 | 209 | else: |
210 | 210 | return False |
211 | 211 | |
| 212 | def _compare_versions(self, a, b): |
| 213 | """Return True if version a is newer than version b |
| 214 | |
| 215 | Both a and b must be in the form x.y.z""" |
| 216 | |
| 217 | a_list = a.split('.') |
| 218 | b_list = b.split('.') |
| 219 | |
| 220 | for i in range(len(a_list)): |
| 221 | if int(a_list[i]) > int(b_list[i]): |
| 222 | return True |
| 223 | elif int(a_list[i]) < int(b_list[i]): |
| 224 | return False |
| 225 | return False |
| 226 | |
212 | 227 | def _add_bundle(self, bundle_path, install_mime_type=False): |
213 | 228 | logging.debug('STARTUP: Adding bundle %r', bundle_path) |
214 | 229 | try: |
… |
… |
class BundleRegistry(gobject.GObject): |
219 | 234 | logging.exception('Error loading bundle %r', bundle_path) |
220 | 235 | return None |
221 | 236 | |
| 237 | # Compare version strings. |
| 238 | if self._compare_versions(bundle.get_sugar_version(), config.version): |
| 239 | logging.exception('Bundle %r requires Sugar version %s or newer' % |
| 240 | (bundle_path, bundle.get_sugar_version())) |
| 241 | return None |
| 242 | |
222 | 243 | bundle_id = bundle.get_bundle_id() |
223 | 244 | installed = self.get_bundle(bundle_id) |
224 | 245 | |