summaryrefslogtreecommitdiffstats
path: root/textw
diff options
context:
space:
mode:
authorErik Troan <ewt@redhat.com>1999-12-11 21:10:27 +0000
committerErik Troan <ewt@redhat.com>1999-12-11 21:10:27 +0000
commit784a328d02c137bad5a09f4aa22d04ce65726fc1 (patch)
treea650cda355766c49f8a67a17b5d4234b1b47167e /textw
parent53f24630f3b8fdf1a3a82b765f251fc9f5adb207 (diff)
downloadanaconda-784a328d02c137bad5a09f4aa22d04ce65726fc1.tar.gz
anaconda-784a328d02c137bad5a09f4aa22d04ce65726fc1.tar.xz
anaconda-784a328d02c137bad5a09f4aa22d04ce65726fc1.zip
added time display
Diffstat (limited to 'textw')
-rw-r--r--textw/partitioning.py1
-rw-r--r--textw/timezone.py105
2 files changed, 105 insertions, 1 deletions
diff --git a/textw/partitioning.py b/textw/partitioning.py
index cfca7ddcc..38700800f 100644
--- a/textw/partitioning.py
+++ b/textw/partitioning.py
@@ -1,4 +1,3 @@
-#import gettext
import iutil
import os
import isys
diff --git a/textw/timezone.py b/textw/timezone.py
new file mode 100644
index 000000000..e776c0121
--- /dev/null
+++ b/textw/timezone.py
@@ -0,0 +1,105 @@
+import string
+import iutil
+import os
+from time import *
+from snack import *
+from textw.constants import *
+from text import _
+
+class TimezoneWindow:
+
+ def getTimezoneList(self, test):
+ if not os.access("/usr/lib/timezones.gz", os.R_OK):
+ if test:
+ cmd = "./gettzlist"
+ stdin = None
+ else:
+ zoneList = iutil.findtz('/usr/share/zoneinfo', '')
+ cmd = ""
+ stdin = None
+ else:
+ cmd = "/usr/bin/gunzip"
+ stdin = os.open("/usr/lib/timezones.gz", 0)
+
+ if cmd != "":
+ zones = iutil.execWithCapture(cmd, [ cmd ], stdin = stdin)
+ zoneList = string.split(zones)
+
+ if (stdin != None):
+ os.close(stdin)
+
+ return zoneList
+
+ def updateSysClock(self):
+ if os.access("/sbin/hwclock", os.X_OK):
+ args = [ "/sbin/hwclock" ]
+ else:
+ args = [ "/usr/sbin/hwclock" ]
+
+ args.append("--hctosys")
+ if self.c.selected():
+ args.append("--utc")
+
+ iutil.execWithRedirect(args[0], args)
+ self.g.setTimer(500)
+ self.updateClock()
+
+ def updateClock(self):
+ os.environ['TZ'] = self.l.current()
+ self.label.setText(self.currentTime())
+
+ def currentTime(self):
+ return "Current time: " + strftime("%X %Z", localtime(time()))
+
+ def __call__(self, screen, todo, test):
+ timezones = self.getTimezoneList(test)
+ rc = todo.getTimezoneInfo()
+ if rc:
+ (default, asUtc, asArc) = rc
+ else:
+ default = "US/Eastern"
+ asUtc = 0
+
+ bb = ButtonBar(screen, [(_("OK"), "ok"), (_("Back"), "back")])
+ t = TextboxReflowed(30,
+ _("What time zone are you located in?"))
+
+ self.label = Label(self.currentTime())
+
+ self.l = Listbox(5, scroll = 1, returnExit = 0)
+
+ for tz in timezones:
+ self.l.append(tz, tz)
+
+ self.l.setCurrent(default)
+ self.l.setCallback(self.updateClock)
+
+ self.c = Checkbox(_("Hardware clock set to GMT?"), isOn = asUtc)
+ self.c.setCallback(self.updateSysClock)
+
+ self.g = GridForm(screen, _("Time Zone Selection"), 1, 5)
+ self.g.add(t, 0, 0)
+ self.g.add(self.label, 0, 1, padding = (0, 1, 0, 0), anchorLeft = 1)
+ self.g.add(self.c, 0, 2, padding = (0, 1, 0, 1), anchorLeft = 1)
+ self.g.add(self.l, 0, 3, padding = (0, 0, 0, 1))
+ self.g.add(bb, 0, 4, growx = 1)
+ self.g.setTimer(500)
+
+ result = "TIMER"
+ while result == "TIMER":
+ result = self.g.run()
+ if result == "TIMER":
+ self.label.setText(self.currentTime())
+
+ screen.popWindow()
+
+ button = bb.buttonPressed(result)
+
+ if button == "back":
+ return INSTALL_BACK
+
+ todo.setTimezoneInfo(self.l.current(), asUtc = self.c.selected())
+
+ return INSTALL_OK
+
+