From 1d631fba8a76a3f29ff94bdb63c6e8ac140f9e70 Mon Sep 17 00:00:00 2001 From: Alexandru DAMIAN Date: Tue, 1 Apr 2014 15:28:15 +0000 Subject: bitbake: 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] (Bitbake rev: bfe67472e3ee778b78ef004b2153fa88b3807b92) Signed-off-by: Alexandru DAMIAN Signed-off-by: Richard Purdie --- bitbake/lib/toaster/toastermain/settings.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'bitbake/lib/toaster') diff --git a/bitbake/lib/toaster/toastermain/settings.py b/bitbake/lib/toaster/toastermain/settings.py index e26ee3c9ee..6e9d85d4c0 100644 --- a/bitbake/lib/toaster/toastermain/settings.py +++ b/bitbake/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()] -- cgit v1.2.3-54-g00ecf