bitbake: buildinfohelper: ensure task datetimes are timezone-aware

When using toaster-eventreplay to run a bitbake event file
through toasterui/buildinfohelper, errors occur when the
tasks are updated with buildstats info:

  RuntimeWarning: DateTimeField Task.started received a naive
  datetime (2016-07-06 09:15:22.070000) while time zone support
  is active.

This is because a method in buildinfohelper returns a naive
datetime, but Django is expecting timezone-aware datetimes.

Ensure that datetimes used to set the started/ended times on
tasks are converted to timezone-aware datetimes.

(Bitbake rev: df9f4337bec87024ea6a43138c6080a755eb7fab)

Signed-off-by: Elliot Smith <elliot.smith@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Elliot Smith 2016-07-06 12:00:35 +01:00 committed by Richard Purdie
parent 78b3fe6d5b
commit 903c3c2ef8
1 changed files with 1 additions and 1 deletions

View File

@ -125,7 +125,7 @@ class ORMWrapper(object):
"""
Convert timestamp in seconds to Python datetime
"""
return datetime(1970, 1, 1) + timedelta(seconds=secs)
return timezone.make_aware(datetime(1970, 1, 1) + timedelta(seconds=secs))
# pylint: disable=no-self-use
# we disable detection of no self use in functions because the methods actually work on the object