[Pulp-list] Dates
Jay Dobies
jason.dobies at redhat.com
Wed Feb 2 15:39:07 UTC 2011
-----BEGIN PGP SIGNED MESSAGE-----
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"]) /
1000.0)
\ 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
parse_date
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
http://pulpproject.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iQEcBAEBAgAGBQJNSXqbAAoJEOMmcTqOSQHCuMMH/jaE+Fd5+unayP036S+gT8fq
uIs7qLNPo4oHUl4rIVkIAHeBiBno1j7D7XSpAzEHhbQUAkCm3Y47WNMgq5F7C/Th
RnmCv7ZCY2b2W7C10rJ+Lhtn0gaNtj7+pCBC9LF0LFMV/WhAAtS51SixJ+xRvm5B
oI+WpbZa6vYhh9kl3iETfVnhGi0mQVk0iAqwo9gI1ycsQ8c9+O7UeSixPg3mb0tT
Q3H53Md6KaGxT/9XC84tEwx8cdk5tOKoID+K3aMGJtNRzDbaMyz8wQXrMBhoPxLF
2658XGAr/nauBFaDF8vfJ6HyDP15TG1rEnn9SMSrlTPUf9QxZXuwD/uj9hOKlwg=
=dmnr
-----END PGP SIGNATURE-----
More information about the Pulp-list
mailing list