From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: Alex DAMIAN <alexandru.damian@intel.com>
Cc: bitbake-devel@lists.openembedded.org, toaster@yoctoproject.org
Subject: Re: [Toaster] [PATCH 1/1] bitbake: toaster: fix timezone detection
Date: Thu, 27 Mar 2014 16:50:52 +0000 [thread overview]
Message-ID: <1395939052.24890.141.camel@ted> (raw)
In-Reply-To: <1395925753-31968-1-git-send-email-alexandru.damian@intel.com>
On Thu, 2014-03-27 at 13:09 +0000, Alex DAMIAN wrote:
> From: Alexandru DAMIAN <alexandru.damian@intel.com>
>
> 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 <alexandru.damian@intel.com>
> ---
> 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
WARNING: multiple messages have this Message-ID (diff)
From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: Alex DAMIAN <alexandru.damian@intel.com>
Cc: bitbake-devel@lists.openembedded.org, toaster@yoctoproject.org
Subject: Re: [PATCH 1/1] bitbake: toaster: fix timezone detection
Date: Thu, 27 Mar 2014 16:50:52 +0000 [thread overview]
Message-ID: <1395939052.24890.141.camel@ted> (raw)
In-Reply-To: <1395925753-31968-1-git-send-email-alexandru.damian@intel.com>
On Thu, 2014-03-27 at 13:09 +0000, Alex DAMIAN wrote:
> From: Alexandru DAMIAN <alexandru.damian@intel.com>
>
> 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 <alexandru.damian@intel.com>
> ---
> 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
next prev parent reply other threads:[~2014-03-27 16:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-27 13:09 [PATCH 1/1] bitbake: toaster: fix timezone detection Alex DAMIAN
2014-03-27 13:09 ` Alex DAMIAN
2014-03-27 16:50 ` Richard Purdie [this message]
2014-03-27 16:50 ` Richard Purdie
2014-03-28 14:46 ` [PATCH] " Alex DAMIAN
2014-03-28 14:46 ` Alex DAMIAN
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1395939052.24890.141.camel@ted \
--to=richard.purdie@linuxfoundation.org \
--cc=alexandru.damian@intel.com \
--cc=bitbake-devel@lists.openembedded.org \
--cc=toaster@yoctoproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.