diff options
author | Alexandru DAMIAN <alexandru.damian@intel.com> | 2014-04-01 15:28:15 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-04-09 16:58:08 +0100 |
commit | bfe67472e3ee778b78ef004b2153fa88b3807b92 (patch) | |
tree | 2a3d6ced96416c0dc512fe33337b06767f07a461 | |
parent | ca921c773c52392a5a338b2f493ad38c8132f708 (diff) | |
download | bitbake-bfe67472e3ee778b78ef004b2153fa88b3807b92.tar.gz |
toaster: do not load all available timezones
This patch makes sure that we only load pytz-recognized
timezones. Pytz is used to transform the timezone information
for the database queries, and needs to be able to deal with
the TIME_ZONE value that we set up.
[YOCTO #6093]
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | lib/toaster/toastermain/settings.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/toaster/toastermain/settings.py b/lib/toaster/toastermain/settings.py index e26ee3c9e..6e9d85d4c 100644 --- a/lib/toaster/toastermain/settings.py +++ b/lib/toaster/toastermain/settings.py @@ -64,7 +64,15 @@ else: for dirpath, dirnames, filenames in os.walk(ZONEINFOPATH): for fn in filenames: filepath = os.path.join(dirpath, fn) - zonefilelist[hashlib.md5(open(filepath).read()).hexdigest()] = filepath.lstrip(ZONEINFOPATH).strip() + try: + import pytz + from pytz.exceptions import UnknownTimeZoneError + zonename = filepath.lstrip(ZONEINFOPATH).strip() + if pytz.timezone(zonename) is not None: + zonefilelist[hashlib.md5(open(filepath).read()).hexdigest()] = zonename + except UnknownTimeZoneError, ValueError: + # we expect timezone failures here, just move over + pass TIME_ZONE = zonefilelist[hashlib.md5(open('/etc/localtime').read()).hexdigest()] |