[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Pulp-list] Dates

Hash: SHA1

Consumer history is completely broken because the CLI fails to parse the
timestamp. I looked through the diff for json_utils.py and found:

- -    Parses the pymongo.json_util encoding of a datetime instance. The
instance is
- -    encoded as a 64-bit unsigned integer for milliseconds since epoch,
according to
- -    JSON strict mode. This method also assumes the strict mode
packaging of a dict
- -    using $date as the key for this integer.
+    Parses the unit timestamp string

- -    Example:
- -    { "$date" : 1283505509571}
- -
- -    @param date_string: JSON encoded datetime instance
+    @param date_string: unix timestamp string
     @type  date_string: dict with the date integer stored at $date

     @return: python object representing the date
     @rtype:  L{datetime.datetime} instance
- -    return datetime.utcfromtimestamp(float(date_string["$date"]) /
\ No newline at end of file
+    return datetime.utcfromtimestamp(float(date_string))

There are a few issues:
- - The method was changed to take the string itself and not a dict. This
is fine, but the param docs were not updated to reflect that (they still
say to pass in a dict) and existing calls into this method were not changed.

- - Why were the docs describing the format of the datetime instance
removed in favor of a less-useful "Parses the unit timestamp string"?
It's one thing for us to have poor docs, its another to actively work
towards removing the few docs we already have.

- - Why was the actual logic change made? Even if I fix the call into this
from consumer history, it cannot parse the date. Is there a different
way we need to store it in the DB? This is what I get with this change
that removes the division by 1000:

  File "/home/jdob/code/pulp/src/pulp/client/json_utils.py", line 32, in
    return datetime.utcfromtimestamp(float(date_string))
ValueError: year is out of range

Can we PLEASE try to be careful when changing method signatures like
this? A simple grep to see if any calls were passing in a dict would
have prevented the entire consumer history feature from breaking.

- -- 
Jay Dobies
RHCE# 805008743336126
Freenode: jdob
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]