/[smeserver]/cdrom.image/updates/timezone_text.py
ViewVC logotype

Annotation of /cdrom.image/updates/timezone_text.py

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download) (as text)
Fri Aug 5 02:28:53 2005 UTC (18 years, 11 months ago) by slords
Branch: MAIN
Content type: text/x-python
Add UTC for text back in

1 slords 1.1 # timezone_text.py: text mode timezone selection dialog
2     #
3     # Copyright 2000-2002 Red Hat, Inc.
4     #
5     # This software may be freely redistributed under the terms of the GNU
6     # library public license.
7     #
8     # You should have received a copy of the GNU Library Public License
9     # along with this program; if not, write to the Free Software
10     # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
11     #
12    
13     import string
14     import iutil
15     import os
16     from time import *
17     from snack import *
18     from constants_text import *
19     from rhpl.translate import _, textdomain
20    
21     textdomain("system-config-date")
22    
23     class TimezoneWindow:
24    
25     def getTimezoneList(self):
26     if os.access("/usr/lib/timezones.gz", os.R_OK):
27     cmd = "/usr/bin/gunzip"
28     stdin = os.open("/usr/lib/timezones.gz", 0)
29     else:
30     zoneList = iutil.findtz('/usr/share/zoneinfo', '')
31     cmd = ""
32     stdin = None
33    
34     if cmd != "":
35     zones = iutil.execWithCapture(cmd, [ cmd ], stdin = stdin)
36     zoneList = string.split(zones)
37    
38     if (stdin != None):
39     os.close(stdin)
40    
41     return zoneList
42    
43     def updateSysClock(self):
44     if os.access("/sbin/hwclock", os.X_OK):
45     args = [ "/sbin/hwclock" ]
46     else:
47     args = [ "/usr/sbin/hwclock" ]
48    
49     args.append("--hctosys")
50     args.append("--utc")
51    
52     iutil.execWithRedirect(args[0], args)
53     self.g.setTimer(500)
54     self.updateClock()
55    
56     def updateClock(self):
57     # disable for now
58     return
59    
60     # if os.access("/usr/share/zoneinfo/" + self.l.current(), os.R_OK):
61     # os.environ['TZ'] = self.l.current()
62     # self.label.setText(self.currentTime())
63     # else:
64     # self.label.setText("")
65    
66     def currentTime(self):
67     return "Current time: " + strftime("%X %Z", localtime(time()))
68    
69     def __call__(self, screen, instLang, timezone):
70     timezones = self.getTimezoneList()
71     (default, asUtc, asArc) = timezone.getTimezoneInfo()
72     if not default:
73     default = instLang.getDefaultTimeZone()
74    
75     bb = ButtonBar(screen, [TEXT_OK_BUTTON, TEXT_BACK_BUTTON])
76     t = TextboxReflowed(30,
77     _("What time zone are you located in?"))
78    
79     #
80     # disabling this for now
81     #
82     # self.label = Label(self.currentTime())
83    
84     self.l = Listbox(5, scroll = 1, returnExit = 0)
85    
86     for tz in timezones:
87     self.l.append(_(tz), tz)
88    
89     self.l.setCurrent(default)
90     # self.l.setCallback(self.updateClock)
91    
92     # self.c = Checkbox("System clock uses UTC", isOn = asUtc)
93     # self.c.setCallback(self.updateSysClock)
94    
95     self.g = GridFormHelp(screen, _("Time Zone Selection"), "timezone",
96     1, 5)
97     self.g.add(t, 0, 0)
98     # self.g.add(self.label, 0, 1, padding = (0, 1, 0, 0), anchorLeft = 1)
99     # self.g.add(self.c, 0, 2, padding = (0, 1, 0, 1), anchorLeft = 1)
100     self.g.add(self.l, 0, 3, padding = (0, 0, 0, 1))
101     self.g.add(bb, 0, 4, growx = 1)
102    
103     # disabling for now
104     # self.updateClock()
105     # self.updateSysClock()
106     #
107     # self.g.setTimer(500)
108     #
109     # result = "TIMER"
110     # while result == "TIMER":
111     # result = self.g.run()
112     # if result == "TIMER":
113     # self.updateClock()
114    
115     result = ""
116     while 1:
117     result = self.g.run()
118     rc = bb.buttonPressed (result)
119    
120     if rc == TEXT_BACK_CHECK:
121     screen.popWindow()
122     return INSTALL_BACK
123     else:
124     break
125    
126     screen.popWindow()
127     timezone.setTimezoneInfo(self.l.current(), asUtc = 1)
128    
129     return INSTALL_OK
130    
131    

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed