[Dextrose] [PATCH] Fix for bugs sl#2713 and au#885.
Ajay Garg
ajaygargnsit at gmail.com
Sun Sep 11 15:05:17 EDT 2011
Running the "dextrose-updater" cron.daily job, "touches" a "/var/lib/dextrose-updater" file. This file is then used in the subsequent run, to determine if it
is ok to re-run the job. Effectively, the "last-touched-timestamp" value of "/var/lib/dextrose-updater" is made use of in the "dextrose-updater" job script.
Used similar logic - used the "last-touched-time" as the time when the yum-updater was last run.
Thanks to Anish, for some wonderful review feedback.
Signed-off-by: Ajay Garg <ajay at sugarlabs.org>
---
extensions/cpsection/aboutcomputer/model.py | 39 ++++++++++++++++++++++++++-
extensions/cpsection/aboutcomputer/view.py | 16 +++++++++++
2 files changed, 54 insertions(+), 1 deletions(-)
diff --git a/extensions/cpsection/aboutcomputer/model.py b/extensions/cpsection/aboutcomputer/model.py
index 7c712a9..79860ac 100644
--- a/extensions/cpsection/aboutcomputer/model.py
+++ b/extensions/cpsection/aboutcomputer/model.py
@@ -26,7 +26,7 @@ from datetime import datetime
import dbus
from jarabe import config
-
+from sugar import env
_NM_SERVICE = 'org.freedesktop.NetworkManager'
_NM_PATH = '/org/freedesktop/NetworkManager'
@@ -229,3 +229,40 @@ def get_license():
except IOError:
license_text = _not_available
return license_text
+
+
+def get_last_updated_on_field():
+ fp = '/var/lib/dextrose-updater'
+
+ if not os.path.exists(fp):
+ last_updated_on = 'Not Applicable. No change in base-image yet!'
+ else:
+ environment = os.environ.copy()
+ environment['PATH'] = '%s:/usr/sbin' % (environment['PATH'], )
+
+ # Get the 'last-touched-time' of '/var/lib/dextrose-updater',
+ # in a verbose time-output-format.
+ first_command = 'ls '
+ time_output_format = '--time-style=+\'%A, %d %B %Y, %X, %Z\' '
+ first_command_args = '-l ' + fp + ' ' + time_output_format
+ second_command = 'awk '
+ second_command_args = '\'{print $6 " " $7 " " $8 " " $9 '\
+ '" " $10 " " $11 " " $12}\''
+
+ try:
+ output = subprocess.Popen(['-c',
+ first_command +
+ first_command_args +
+ '| ' +
+ second_command +
+ second_command_args
+ ],
+ stdout=subprocess.PIPE,
+ env=environment,
+ shell=True).stdout.readlines()
+ except OSError:
+ _logger.exception('Error running ls')
+
+ last_updated_on = ([line for line in output][0])
+
+ return last_updated_on
diff --git a/extensions/cpsection/aboutcomputer/view.py b/extensions/cpsection/aboutcomputer/view.py
index 00179d5..0042d6b 100644
--- a/extensions/cpsection/aboutcomputer/view.py
+++ b/extensions/cpsection/aboutcomputer/view.py
@@ -174,6 +174,22 @@ class AboutComputer(SectionView):
box_software.pack_start(box_wireless_fw, expand=False)
box_wireless_fw.show()
+ box_last_updated_on = gtk.HBox(spacing=style.DEFAULT_SPACING)
+ label_last_updated_on = gtk.Label(_('Last Updated On:'))
+ label_last_updated_on.set_alignment(1, 0)
+ label_last_updated_on.modify_fg(gtk.STATE_NORMAL,
+ style.COLOR_SELECTION_GREY.get_gdk_color())
+ box_last_updated_on.pack_start(label_last_updated_on, expand=False)
+ self._group.add_widget(label_last_updated_on)
+ label_last_updated_on.show()
+ label_last_updated_on_value = \
+ gtk.Label(self._model.get_last_updated_on_field())
+ label_last_updated_on_value.set_alignment(0, 0)
+ box_last_updated_on.pack_start(label_last_updated_on_value, expand=False)
+ label_last_updated_on_value.show()
+ box_software.pack_start(box_last_updated_on, expand=False)
+ box_last_updated_on.show()
+
self._vbox.pack_start(box_software, expand=False)
box_software.show()
--
1.7.4.4
More information about the Dextrose
mailing list