Patchwork [bitbake-devel,1/1] bitbake: toaster: Allow toaster to start without pytz

login
register
mail settings
Submitter Alexandru DAMIAN
Date April 9, 2014, 5 p.m.
Message ID <1397062853-13768-1-git-send-email-alexandru.damian@intel.com>
Download mbox | patch
Permalink /patch/70393/
State New
Headers show

Comments

Alexandru DAMIAN - April 9, 2014, 5 p.m.
From: Belen Barros <belen.barros.pena@intel.com>

This patch allows toaster to start without pytz.

Django can work with or without pytz, but in the
time zone fix I mistakenly added a hard dependency
on this module.

This patch eliminates the hard dependency.

Signed-off-by: Belen Barros <belen.barros.pena@intel.com>
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
---
 bitbake/lib/toaster/toastermain/settings.py | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

Patch

diff --git a/bitbake/lib/toaster/toastermain/settings.py b/bitbake/lib/toaster/toastermain/settings.py
index 6e9d85d..40a2b1a 100644
--- a/bitbake/lib/toaster/toastermain/settings.py
+++ b/bitbake/lib/toaster/toastermain/settings.py
@@ -64,15 +64,20 @@  else:
     for dirpath, dirnames, filenames in os.walk(ZONEINFOPATH):
         for fn in filenames:
             filepath = os.path.join(dirpath, fn)
+            zonename = 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
+                try:
+                    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
+            except ImportError:
+            	zonefilelist[hashlib.md5(open(filepath).read()).hexdigest()] = zonename
+		
 
     TIME_ZONE = zonefilelist[hashlib.md5(open('/etc/localtime').read()).hexdigest()]