On Thu, 2014-03-27 at 13:09 +0000, Alex DAMIAN wrote: > From: Alexandru DAMIAN <[email protected]> > > This patch replaces faulty timezone detection with a version > that simply reads the TZ environment variable if it is set. > > If the TZ is not set, we do a reverse match search among known > timezone definitions and take the first match. > > [YOCTO #5499] > > Signed-off-by: Alexandru DAMIAN <[email protected]> > --- > bitbake/lib/toaster/toastermain/settings.py | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/bitbake/lib/toaster/toastermain/settings.py > b/bitbake/lib/toaster/toastermain/settings.py > index 51fa3cc..98d2ac3 100644 > --- a/bitbake/lib/toaster/toastermain/settings.py > +++ b/bitbake/lib/toaster/toastermain/settings.py > @@ -51,8 +51,16 @@ ALLOWED_HOSTS = [] > # In a Windows environment this must be set to your system time zone. > > # Always use local computer's time zone > -import time > -TIME_ZONE = time.tzname[0] > +import os, subprocess > + > +# the TZ variable overrides any default timezone setting > +if 'TZ' in os.environ: > + TIME_ZONE = os.environ['TZ'] > +else: > + # need to read the /etc/localtime file which is the libc standard > + # and do a reverse-mapping to /usr/share/zoneinfo/; since the timezone > may match any number of identical timezone definitions, > + # we just select the first that matches > + TIME_ZONE = subprocess.Popen("find /usr/share/zoneinfo/ -type f -exec > diff -s {} /etc/localtime \; | grep identical | head -1 | awk '{print $2;}' | > sed 's/\/usr\/share\/zoneinfo\///'", shell=True, stdout = > subprocess.PIPE).communicate()[0].strip()
Forking off a shell pipeline for this is rather ugly, particularly every time the program starts :/ Cheers, Richard -- _______________________________________________ toaster mailing list [email protected] https://lists.yoctoproject.org/listinfo/toaster
