mirror of
https://git.yoctoproject.org/poky
synced 2026-05-31 12:49:46 +00:00
bitbake: toastermain/settings: Avoid python filehandle closure warnings
Switch to using with blocks when accessing files to ensure file descriptors are closed and avoid python warnings. (Bitbake rev: e8574ee78eea23cc35900610bb15e47e40ef5ee1) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
@@ -89,14 +89,17 @@ else:
|
|||||||
from pytz.exceptions import UnknownTimeZoneError
|
from pytz.exceptions import UnknownTimeZoneError
|
||||||
try:
|
try:
|
||||||
if pytz.timezone(zonename) is not None:
|
if pytz.timezone(zonename) is not None:
|
||||||
zonefilelist[hashlib.md5(open(filepath, 'rb').read()).hexdigest()] = zonename
|
with open(filepath, 'rb') as f:
|
||||||
|
zonefilelist[hashlib.md5(f.read()).hexdigest()] = zonename
|
||||||
except UnknownTimeZoneError as ValueError:
|
except UnknownTimeZoneError as ValueError:
|
||||||
# we expect timezone failures here, just move over
|
# we expect timezone failures here, just move over
|
||||||
pass
|
pass
|
||||||
except ImportError:
|
except ImportError:
|
||||||
zonefilelist[hashlib.md5(open(filepath, 'rb').read()).hexdigest()] = zonename
|
with open(filepath, 'rb') as f:
|
||||||
|
zonefilelist[hashlib.md5(f.read()).hexdigest()] = zonename
|
||||||
|
|
||||||
TIME_ZONE = zonefilelist[hashlib.md5(open('/etc/localtime', 'rb').read()).hexdigest()]
|
with open('/etc/localtime', 'rb') as f:
|
||||||
|
TIME_ZONE = zonefilelist[hashlib.md5(f.read()).hexdigest()]
|
||||||
|
|
||||||
# Language code for this installation. All choices can be found here:
|
# Language code for this installation. All choices can be found here:
|
||||||
# http://www.i18nguy.com/unicode/language-identifiers.html
|
# http://www.i18nguy.com/unicode/language-identifiers.html
|
||||||
|
|||||||
Reference in New Issue
Block a user