* [PATCH 1/1] bitbake: toaster: fix timezone detection
@ 2014-03-27 13:09 ` Alex DAMIAN
0 siblings, 0 replies; 6+ messages in thread
From: Alex DAMIAN @ 2014-03-27 13:09 UTC (permalink / raw)
To: bitbake-devel, toaster; +Cc: Alexandru DAMIAN
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()
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
--
1.8.3.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 1/1] bitbake: toaster: fix timezone detection
@ 2014-03-27 13:09 ` Alex DAMIAN
0 siblings, 0 replies; 6+ messages in thread
From: Alex DAMIAN @ 2014-03-27 13:09 UTC (permalink / raw)
To: bitbake-devel, toaster
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()
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
--
1.8.3.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Toaster] [PATCH 1/1] bitbake: toaster: fix timezone detection
2014-03-27 13:09 ` Alex DAMIAN
@ 2014-03-27 16:50 ` Richard Purdie
-1 siblings, 0 replies; 6+ messages in thread
From: Richard Purdie @ 2014-03-27 16:50 UTC (permalink / raw)
To: Alex DAMIAN; +Cc: bitbake-devel, toaster
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] bitbake: toaster: fix timezone detection
@ 2014-03-27 16:50 ` Richard Purdie
0 siblings, 0 replies; 6+ messages in thread
From: Richard Purdie @ 2014-03-27 16:50 UTC (permalink / raw)
To: Alex DAMIAN; +Cc: bitbake-devel, toaster
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] bitbake: toaster: fix timezone detection
2014-03-27 13:09 ` Alex DAMIAN
@ 2014-03-28 14:46 ` Alex DAMIAN
-1 siblings, 0 replies; 6+ messages in thread
From: Alex DAMIAN @ 2014-03-28 14:46 UTC (permalink / raw)
To: bitbake-devel, toaster; +Cc: Alexandru DAMIAN
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 | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/bitbake/lib/toaster/toastermain/settings.py b/bitbake/lib/toaster/toastermain/settings.py
index 51fa3cc..e26ee3c 100644
--- a/bitbake/lib/toaster/toastermain/settings.py
+++ b/bitbake/lib/toaster/toastermain/settings.py
@@ -50,9 +50,23 @@ ALLOWED_HOSTS = []
# although not all choices may be available on all operating systems.
# 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]
+# Always use local computer's time zone, find
+import os, hashlib
+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,
+
+ zonefilelist = {}
+ ZONEINFOPATH = '/usr/share/zoneinfo/'
+ 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()
+
+ TIME_ZONE = zonefilelist[hashlib.md5(open('/etc/localtime').read()).hexdigest()]
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] bitbake: toaster: fix timezone detection
@ 2014-03-28 14:46 ` Alex DAMIAN
0 siblings, 0 replies; 6+ messages in thread
From: Alex DAMIAN @ 2014-03-28 14:46 UTC (permalink / raw)
To: bitbake-devel, toaster
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 | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/bitbake/lib/toaster/toastermain/settings.py b/bitbake/lib/toaster/toastermain/settings.py
index 51fa3cc..e26ee3c 100644
--- a/bitbake/lib/toaster/toastermain/settings.py
+++ b/bitbake/lib/toaster/toastermain/settings.py
@@ -50,9 +50,23 @@ ALLOWED_HOSTS = []
# although not all choices may be available on all operating systems.
# 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]
+# Always use local computer's time zone, find
+import os, hashlib
+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,
+
+ zonefilelist = {}
+ ZONEINFOPATH = '/usr/share/zoneinfo/'
+ 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()
+
+ TIME_ZONE = zonefilelist[hashlib.md5(open('/etc/localtime').read()).hexdigest()]
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-03-28 14:46 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [Toaster] " Richard Purdie
2014-03-27 16:50 ` Richard Purdie
2014-03-28 14:46 ` [PATCH] " Alex DAMIAN
2014-03-28 14:46 ` Alex DAMIAN
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.