diff options
Diffstat (limited to 'rpms/sugar/0046-Add-lease-duration-information-in-about-my-computer.patch')
-rw-r--r-- | rpms/sugar/0046-Add-lease-duration-information-in-about-my-computer.patch | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/rpms/sugar/0046-Add-lease-duration-information-in-about-my-computer.patch b/rpms/sugar/0046-Add-lease-duration-information-in-about-my-computer.patch new file mode 100644 index 0000000..36ce7a7 --- /dev/null +++ b/rpms/sugar/0046-Add-lease-duration-information-in-about-my-computer.patch @@ -0,0 +1,94 @@ +From 85297850f1791781aedcf33b170f5ae3d2d6e079 Mon Sep 17 00:00:00 2001 +From: Anish Mangal <anish@sugarlabs.org> +Date: Thu, 20 Jan 2011 23:18:42 -0300 +Subject: [PATCH sugar 46/74] Add lease duration information in about my + computer + +Signed-off-by: Anish Mangal <anish@sugarlabs.org> +--- + extensions/cpsection/aboutcomputer/model.py | 28 +++++++++++++++++++++++++++ + extensions/cpsection/aboutcomputer/view.py | 15 ++++++++++++++ + 2 files changed, 43 insertions(+), 0 deletions(-) + +diff --git a/extensions/cpsection/aboutcomputer/model.py b/extensions/cpsection/aboutcomputer/model.py +index 431c9c0..52a1094 100644 +--- a/extensions/cpsection/aboutcomputer/model.py ++++ b/extensions/cpsection/aboutcomputer/model.py +@@ -21,6 +21,7 @@ + import subprocess + from gettext import gettext as _ + import errno ++from datetime import datetime + + import dbus + +@@ -39,6 +40,9 @@ + _SN = 'serial-number' + _MODEL = 'openprom/model' + ++_XO_1_0_LEASE_PATH = '/security/lease.sig' ++_XO_1_5_LEASE_PATH = '/bootpart/boot/security/lease.sig' ++ + _logger = logging.getLogger('ControlPanel - AboutComputer') + _not_available = _('Not available') + +@@ -53,6 +57,30 @@ def print_aboutcomputer(): + print get_aboutcomputer() + + ++def _get_lease_path(): ++ if os.path.exists(_XO_1_0_LEASE_PATH): ++ return _XO_1_0_LEASE_PATH ++ elif os.path.exists(_XO_1_5_LEASE_PATH): ++ return _XO_1_5_LEASE_PATH ++ else: ++ return '' ++ ++ ++def get_lease_days(): ++ lease_file = _read_file(_get_lease_path()) ++ if lease_file is None: ++ return _not_available ++ ++ encoded_date = str(str.split(lease_file)[3]) ++ expiry_date = datetime.strptime(encoded_date ++ , '%Y%m%dT%H%M%SZ') ++ current_date = datetime.today() ++ days_remaining = (expiry_date - current_date).days ++ #TODO: gettext str_days_remaining ++ str_days_remaining = str(days_remaining) + ' days remaining' ++ return str_days_remaining ++ ++ + def get_serial_number(): + serial_no = None + if os.path.exists(os.path.join(_OFW_TREE, _SN)): +diff --git a/extensions/cpsection/aboutcomputer/view.py b/extensions/cpsection/aboutcomputer/view.py +index 257e165..d719372 100644 +--- a/extensions/cpsection/aboutcomputer/view.py ++++ b/extensions/cpsection/aboutcomputer/view.py +@@ -79,6 +79,21 @@ def _setup_identity(self): + vbox_identity.pack_start(box_identity, expand=False) + box_identity.show() + ++ box_lease = gtk.HBox(spacing=style.DEFAULT_SPACING) ++ label_lease = gtk.Label(_('Lease: ')) ++ label_lease.set_alignment(1, 0) ++ label_lease.modify_fg(gtk.STATE_NORMAL, ++ style.COLOR_SELECTION_GREY.get_gdk_color()) ++ box_lease.pack_start(label_lease, expand=False) ++ self._group.add_widget(label_lease) ++ label_lease.show() ++ label_lease_ver = gtk.Label(self._model.get_lease_days()) ++ label_lease_ver.set_alignment(0, 0) ++ box_lease.pack_start(label_lease_ver, expand=False) ++ label_lease_ver.show() ++ vbox_identity.pack_start(box_lease, expand=False) ++ box_lease.show() ++ + self._vbox.pack_start(vbox_identity, expand=False) + vbox_identity.show() + +-- +1.7.6 + |