[Sugar-devel] [PATCH sugar] Journal details view: don't choke on invalid timestamp (SL#1590, SL#2208)
Simon Schampijer
simon at schampijer.de
Mon Nov 29 08:14:21 EST 2010
On 10/17/2010 12:04 PM, Sascha Silbe wrote:
> Metadata can get corrupted by crashes or malformed by buggy activities.
> We should do our best to display the parts that are usable.
>
> Signed-off-by: Sascha Silbe<sascha-pgp at silbe.org>
Acked-by: Simon Schampijer <simon at schampijer.de>
Looks fine - as we have agreed already on the general approach and as
the existing patches in the tickets looked similar, good with me.
> ---
> src/jarabe/journal/expandedentry.py | 12 ++++++++----
> src/jarabe/journal/misc.py | 16 ++++++++++++----
> 2 files changed, 20 insertions(+), 8 deletions(-)
>
> diff --git a/src/jarabe/journal/expandedentry.py b/src/jarabe/journal/expandedentry.py
> index 0c60600..0abf8ab 100644
> --- a/src/jarabe/journal/expandedentry.py
> +++ b/src/jarabe/journal/expandedentry.py
> @@ -281,10 +281,14 @@ class ExpandedEntry(hippo.CanvasBox):
>
> def _format_date(self):
> if 'timestamp' in self._metadata:
> - timestamp = float(self._metadata['timestamp'])
> - return time.strftime('%x', time.localtime(timestamp))
> - else:
> - return _('No date')
> + try:
> + timestamp = float(self._metadata['timestamp'])
> + except (ValueError, TypeError):
> + logging.warning('Invalid timestamp for %r: %r',
> + self._metadata['uid'], self._metadata['timestamp'])
Is think this should formatted slightly different to please the pep8
example :)
Regards,
Simon
More information about the Sugar-devel
mailing list