7077090 Solaris 11 installer (timezone screen) should update date/time when user selects target timezone
authorDermot <Dermot.McCluskey@Oracle.COM>
Sun, 21 Aug 2011 16:31:49 +0100
changeset 1408 92e8da409b8b
parent 1407 233016449e4a
child 1409 5b828d0506d9
7077090 Solaris 11 installer (timezone screen) should update date/time when user selects target timezone
usr/src/cmd/gui-install/src/timezone.py
usr/src/cmd/gui-install/src/timezone_screen.py
--- a/usr/src/cmd/gui-install/src/timezone.py	Fri Aug 19 18:35:38 2011 -0600
+++ b/usr/src/cmd/gui-install/src/timezone.py	Sun Aug 21 16:31:49 2011 +0100
@@ -29,6 +29,9 @@
 import pygtk
 pygtk.require('2.0')
 
+import logging
+import os
+
 import gobject
 import gtk
 import pango
@@ -36,6 +39,9 @@
 from solaris_install.gui_install.gui_install_common import modal_dialog, \
     COLOR_WHITE, GLADE_DIR, GLADE_ERROR_MSG
 from solaris_install.gui_install.map import Map, TZTimezone
+from solaris_install.logger import INSTALL_LOGGER_NAME
+
+LOGGER = None
 
 
 class Timezone(gtk.VBox):
@@ -165,10 +171,24 @@
                     self.map.allocation.width, self.map.allocation.height)
                 self.map.window.invalidate_rect(rect, False)
 
-    def __init__(self, builder):
+                LOGGER.debug("Changing TZ to %s" % tz.tz_name)
+                # Save new TZ to the environment so that future calls
+                # to datetime.now() & Co will reflect the new timezone
+                os.environ['TZ'] = tz.tz_name
+                # Call the TimeZoneScreen to update the date/time for new TZ
+                self.parent_screen.set_current_date_and_time()
+
+    def __init__(self, builder, parent_screen):
+        global LOGGER
+        LOGGER = logging.getLogger(INSTALL_LOGGER_NAME)
+
         gtk.VBox.__init__(self)
 
         self.builder = builder
+        # Save a reference to the TimeZoneScreen that contains this
+        # Timezone object, so we can call its set_current_date_and_time()
+        # when a different time zone is selected.
+        self.parent_screen = parent_screen
 
         self.map = Map()
         self.map.load_timezones()
@@ -311,7 +331,7 @@
         itz = self.tz_combo.get_active() - 1
 
         if ictnt < 0 or ictry < 0 or itz < 0:
-            print "ERROR - Time Zone Invalid"
+            LOGGER.warn("WARNING - Time Zone Invalid")
             return (None, None, None)
 
         continent = self.map.world.continents[ictnt]
--- a/usr/src/cmd/gui-install/src/timezone_screen.py	Fri Aug 19 18:35:38 2011 -0600
+++ b/usr/src/cmd/gui-install/src/timezone_screen.py	Sun Aug 21 16:31:49 2011 +0100
@@ -118,7 +118,6 @@
         if not self.set_system_clock():
             # Not a fatal error
             LOGGER.warn("WARNING: Failed to set TZ and/or date/time")
-            print "WARNING: Failed to set TZ and/or date/time"
 
         # Save the user-entered details to the DOC
         engine = InstallEngine.get_instance()
@@ -131,7 +130,7 @@
                 country.name, timezone.tz_name)
 
     def ui_init(self):
-        self.timezone = Timezone(self.builder)
+        self.timezone = Timezone(self.builder, self)
         self.timezone.show()
         self.outervbox.pack_start(self.timezone,
             expand=False, fill=False, padding=0)
@@ -318,7 +317,6 @@
         try:
             p = Popen.check_call(cmd, stdout=Popen.STORE)
         except CalledProcessError, err:
-            print "ERROR: [%s] [%s]" % (cmd, err)
             LOGGER.error("ERROR: [%s] [%s]" % (cmd, err))
             return False