/[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.3 - (hide annotations) (download) (as text)
Wed Apr 5 21:11:51 2006 UTC (18 years, 7 months ago) by slords
Branch: MAIN
Changes since 1.2: +1 -0 lines
Content type: text/x-python
Cleanup

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

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