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 <alexandru.damian@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Alexandru DAMIAN
2014-04-01 15:28:15 +00:00
committed by Richard Purdie
parent 70288db2e9
commit 1d631fba8a

View File

@@ -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()]