Ticket #1590 (closed defect: fixed)

Opened 4 years ago

Last modified 3 years ago

Make timestamp retrieval in Journal more robust

Reported by: sayamindu Owned by: alsroot
Priority: Unspecified by Maintainer Milestone: 0.90
Component: sugar Version: Git as of bugdate
Severity: Major Keywords:
Cc: Distribution/OS:
Bug Status: New

Description

The timestamp retrieval code in the journal expects the data to be int, however, sometimes it is not. The attached patch tries to fix that.

Attachments

time_stamp.patch Download (0.9 KB) - added by sayamindu 4 years ago.
Proposed patch

Change History

Changed 4 years ago by sayamindu

Proposed patch

Changed 4 years ago by sayamindu

  • keywords r? added

Changed 4 years ago by sascha_silbe

try:
timestamp = float(metadatatimestamp?)
except ValueError:
timestamp = None
if timestamp is None:
return _('No date')
else:
return util.timestamp_to_elapsed_string(timestamp)

How about returning directly in the except clause? There's no other way that timestamp can get assigned None and it makes the code easier to read and understand.

Changed 4 years ago by sayamindu

  • owner changed from tomeu to alsroot
  • status changed from new to assigned

Eegh - that is embarrassing :-). Reassigning ticket to alsroot since he's the Journal maintainer.

Changed 3 years ago by alsroot

  • keywords r+ added; r? removed

sorry, I really missed this one and if it's not too late for string freeze

but w/ silbe's remark - wold be good to see logging.error in except block

Changed 3 years ago by alsroot

  • keywords r- added; r+ removed

looks like we have similar code in other places, so lets investigate why we have not float some time and fix this issue in all palces

Changed 3 years ago by sascha_silbe

  • distribution Unspecified deleted
  • status_field changed from Unconfirmed to New
  • severity changed from Unspecified to Major
  • version changed from Unspecified to Git as of bugdate
  • milestone changed from Unspecified by Release Team to 0.90

Here's another place that will break if timestamp is a float. Triggered this while importing data store entries from Sugar 0.82.1 (OLPC Build 801):

Traceback (most recent call last):
  File "/home/sascha.silbe/sugar-jhbuild/install/lib/python2.6/site-packages/jarabe/journal/listmodel.py", line 142, in on_get_value
    timestamp = int(metadata.get('timestamp', 0))
ValueError: invalid literal for int() with base 10: '1283202926.51'

#2208 is related (breakage on parsing the ctime property).

Changed 3 years ago by sascha_silbe

  • keywords r- removed
  • status changed from assigned to closed
  • resolution set to fixed

Fixed by  923a7fc.

Note: See TracTickets for help on using tickets.