]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
buildinfohelper: ensure task datetimes are timezone-aware
authorElliot Smith <elliot.smith@intel.com>
Wed, 6 Jul 2016 11:00:35 +0000 (12:00 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 8 Jul 2016 08:57:06 +0000 (09:57 +0100)
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.

Signed-off-by: Elliot Smith <elliot.smith@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
lib/bb/ui/buildinfohelper.py

index d5ba6293060bcd9c1f7519040554a25745c7fe7a..447670cb8b4492ee56097c324c711f804a6cfa8a 100644 (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