Opened 11 years ago

Closed 10 years ago

Last modified 7 years ago

#1590 closed defect (fixed)

Make timestamp retrieval in Journal more robust

Reported by: sayamindu Owned by: alsroot
Priority: Unspecified by Maintainer Milestone:
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 (1)

time_stamp.patch (905 bytes) - added by sayamindu 11 years ago.
Proposed patch

Download all attachments as: .zip

Change History (9)

Changed 11 years ago by sayamindu

Proposed patch

comment:1 Changed 11 years ago by sayamindu

  • Keywords r? added

comment:2 Changed 11 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.

comment:3 Changed 11 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.

comment:4 Changed 10 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

comment:5 Changed 10 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

comment:6 Changed 10 years ago by sascha_silbe

  • Bug Status changed from Unconfirmed to New
  • Distribution/OS Unspecified deleted
  • Milestone changed from Unspecified by Release Team to 0.90
  • Severity changed from Unspecified to Major
  • Version changed from Unspecified to Git as of bugdate

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).

comment:7 Changed 10 years ago by sascha_silbe

  • Keywords r- removed
  • Resolution set to fixed
  • Status changed from assigned to closed

Fixed by 923a7fc.

comment:8 Changed 7 years ago by dnarvaez

  • Milestone 0.90 deleted

Milestone 0.90 deleted

Note: See TracTickets for help on using tickets.