From 3a3ce804d6f4ac349c53b2cf1a89d2f9827dfda3 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 2 Apr 2020 23:44:15 +0200 Subject: [PATCH] Wat da fuke pytz --- moulinette/interfaces/cli.py | 3 ++- moulinette/utils/serialize.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/moulinette/interfaces/cli.py b/moulinette/interfaces/cli.py index dd340398..804028bc 100644 --- a/moulinette/interfaces/cli.py +++ b/moulinette/interfaces/cli.py @@ -7,7 +7,6 @@ import locale import logging from argparse import SUPPRESS from collections import OrderedDict -import pytz from datetime import date, datetime import argcomplete @@ -103,6 +102,8 @@ def pretty_date(_date): Argument: - date -- The date or datetime to display """ + import pytz # Lazy loading, this takes like 3+ sec on a RPi2 ?! + # Deduce system timezone nowutc = datetime.now(tz=pytz.utc) nowtz = datetime.now() diff --git a/moulinette/utils/serialize.py b/moulinette/utils/serialize.py index f3119190..345cb4d4 100644 --- a/moulinette/utils/serialize.py +++ b/moulinette/utils/serialize.py @@ -1,7 +1,6 @@ import logging from json.encoder import JSONEncoder import datetime -import pytz logger = logging.getLogger("moulinette.utils.serialize") @@ -23,6 +22,9 @@ class JSONExtendedEncoder(JSONEncoder): """ def default(self, o): + + import pytz # Lazy loading, this takes like 3+ sec on a RPi2 ?! + """Return a serializable object""" # Convert compatible containers into list if isinstance(o, set) or (hasattr(o, "__iter__") and hasattr(o, "next")):