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

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

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


Revision 1.3 - (hide annotations) (download) (as text)
Mon Aug 1 16:06:47 2005 UTC (19 years, 4 months ago) by slords
Branch: MAIN
Changes since 1.2: +3 -2 lines
Content type: text/x-python
Make upgrade default choice
Verify reinstall before starting

1 slords 1.1 #
2     # upgrade_text.py: text mode upgrade dialogs
3     #
4     # Copyright 2001 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 isys
16     import iutil
17     import upgrade
18     from constants_text import *
19     from snack import *
20     from fsset import *
21     from flags import flags
22     from constants import *
23     import smeupgradeclass
24     UpgradeClass = smeupgradeclass.InstallClass
25    
26     from rhpl.log import log
27     from rhpl.translate import _
28    
29     class UpgradeMigrateFSWindow:
30     def __call__ (self, screen, thefsset):
31    
32     migent = thefsset.getMigratableEntries()
33    
34     g = GridFormHelp(screen, _("Migrate File Systems"), "upmigfs", 1, 4)
35    
36     text = _("This release of %s supports "
37     "the ext3 journalling file system. It has several "
38     "benefits over the ext2 file system traditionally shipped "
39     "in %s. It is possible to migrate the ext2 "
40     "formatted partitions to ext3 without data loss.\n\n"
41     "Which of these partitions would you like to migrate?"
42     % (productName, productName))
43    
44     tb = TextboxReflowed(60, text)
45     g.add(tb, 0, 0, anchorLeft = 1, padding = (0, 0, 0, 1))
46    
47     partlist = CheckboxTree(height=4, scroll=1)
48     for entry in migent:
49     if entry.fsystem.getName() != entry.origfsystem.getName():
50     migrating = 1
51     else:
52     migrating = 0
53    
54     partlist.append("/dev/%s - %s - %s" % (entry.device.getDevice(),
55     entry.origfsystem.getName(),
56     entry.mountpoint), entry, migrating)
57    
58     g.add(partlist, 0, 1, padding = (0, 0, 0, 1))
59    
60     buttons = ButtonBar(screen, [TEXT_OK_BUTTON, TEXT_BACK_BUTTON] )
61     g.add(buttons, 0, 3, anchorLeft = 1, growx = 1)
62    
63     while 1:
64     result = g.run()
65    
66     if (buttons.buttonPressed(result)):
67     result = buttons.buttonPressed(result)
68    
69     if result == TEXT_BACK_CHECK:
70     screen.popWindow()
71     return INSTALL_BACK
72    
73     # reset
74     for entry in migent:
75     entry.setFormat(0)
76     entry.setMigrate(0)
77     entry.fsystem = entry.origfsystem
78    
79     for entry in partlist.getSelection():
80     entry.setMigrate(1)
81     entry.fsystem = fileSystemTypeGet("ext3")
82    
83     screen.popWindow()
84     return INSTALL_OK
85    
86     class UpgradeSwapWindow:
87     def __call__ (self, screen, intf, fsset, instPath, swapInfo, dispatch):
88     rc = swapInfo
89    
90     (fsList, suggSize, suggMntPoint) = rc
91    
92     ramDetected = iutil.memInstalled()/1024
93    
94     text = _("The 2.4 kernel needs significantly more swap than older "
95     "kernels, as much as twice as much swap space as RAM on the "
96     "system. You currently have %dMB of swap configured, but "
97     "you may create additional swap space on one of your "
98     "file systems now.") % (iutil.swapAmount() / 1024)
99    
100     tb = TextboxReflowed(60, text)
101     amount = Entry(10, scroll = 0)
102     amount.set(str(suggSize))
103    
104     l = len(fsList)
105     scroll = 0
106     if l > 4:
107     l = 4
108     scroll = 1
109     listbox = Listbox(l, scroll = scroll)
110    
111     liLabel = Label("%-25s %-15s %8s" % (_("Mount Point"),
112     _("Partition"), _("Free Space")))
113    
114     count = 0
115     for (mnt, part, size) in fsList:
116     listbox.append("%-25s /dev/%-10s %6dMB" % (mnt, part, size), count)
117    
118     if (mnt == suggMntPoint):
119     listbox.setCurrent(count)
120    
121     count = count + 1
122    
123     buttons = ButtonBar(screen, [TEXT_OK_BUTTON, (_("Skip"), "skip"),
124     TEXT_BACK_BUTTON] )
125    
126     amGrid = Grid(2, 3)
127     amGrid.setField(Label(_("RAM detected (MB):")), 0, 0, anchorLeft = 1,
128     padding = (0, 0, 1, 0))
129     amGrid.setField(Label(str(ramDetected)), 1, 0, anchorLeft = 1)
130     amGrid.setField(Label(_("Suggested size (MB):")), 0, 1, anchorLeft = 1,
131     padding = (0, 0, 1, 0))
132     amGrid.setField(Label(str(suggSize)), 1, 1, anchorLeft = 1)
133     amGrid.setField(Label(_("Swap file size (MB):")), 0, 2, anchorLeft = 1,
134     padding = (0, 0, 1, 0))
135     amGrid.setField(amount, 1, 2)
136    
137     liGrid = Grid(1, 2)
138     liGrid.setField(liLabel, 0, 0)
139     liGrid.setField(listbox, 0, 1)
140    
141     g = GridFormHelp(screen, _("Add Swap"), "upgradeswap", 1, 4)
142     g.add(tb, 0, 0, anchorLeft = 1, padding = (0, 0, 0, 1))
143     g.add(amGrid, 0, 1, padding = (0, 0, 0, 1))
144     g.add(liGrid, 0, 2, padding = (0, 0, 0, 1))
145     g.add(buttons, 0, 3, anchorLeft = 1, growx = 1)
146    
147     while 1:
148     result = g.run()
149    
150     if (buttons.buttonPressed(result)):
151     result = buttons.buttonPressed(result)
152    
153     if result == TEXT_BACK_CHECK:
154     screen.popWindow()
155     return INSTALL_BACK
156     elif result == "skip":
157     screen.popWindow()
158     return INSTALL_OK
159    
160     val = amount.value()
161    
162     try:
163     val = int(val)
164     except ValueError:
165     intf.messageWindow(_("Error"),
166     _("The value you entered is not a "
167     "valid number."))
168    
169     if type(val) == type(1):
170     (mnt, part, size) = fsList[listbox.current()]
171     if size < (val + 16):
172     intf.messageWindow(_("Error"),
173     _("There is not enough space on the "
174     "device you selected for the swap "
175     "partition."))
176     elif val > 2000 or val < 1:
177     intf.messageWindow(_("Warning"),
178     _("The swap file must be between 1 "
179     "and 2000 MB in size."))
180     else:
181     screen.popWindow()
182     if flags.setupFilesystems:
183     upgrade.createSwapFile(instPath, fsset, mnt, val)
184     dispatch.skipStep("addswap", 1)
185     return INSTALL_OK
186    
187     raise ValueError
188    
189     class UpgradeExamineWindow:
190     def __call__ (self, screen, dispatch, intf, id, chroot):
191     parts = id.rootParts
192    
193     height = min(len(parts), 11) + 1
194     if height == 12:
195     scroll = 1
196     else:
197     scroll = 0
198     partList = []
199     partList.append(_("Reinstall System"))
200    
201     for (drive, fs, desc) in parts:
202     if drive[:5] != "/dev/":
203     devname = "/dev/" + drive
204     else:
205     devname = drive
206     partList.append("%s (%s)" %(desc, drive))
207    
208     (button, choice) = ListboxChoiceWindow(screen, _("System to Upgrade"),
209     _("One or more existing Linux installations "
210     "have been found "
211     "on your system.\n\nPlease choose one to upgrade, "
212     "or select 'Reinstall System' to freshly install "
213     "your system."), partList,
214     [ TEXT_OK_BUTTON,
215     TEXT_BACK_BUTTON ],
216     width = 55, scroll = scroll,
217     height = height,
218 slords 1.3 help = "upgraderoot",
219     default = 1)
220 slords 1.1
221     if button == TEXT_BACK_CHECK:
222     return INSTALL_BACK
223     else:
224     if choice == 0:
225     root = None
226     else:
227     root = parts[choice - 1]
228    
229     if root is not None:
230     c = UpgradeClass(flags.expert)
231     c.setSteps(dispatch)
232     c.setInstallData(id)
233    
234     id.upgradeRoot = [(root[0], root[1])]
235     id.rootParts = parts
236     dispatch.skipStep("installtype", skip = 1)
237     else:
238 slords 1.3 dispatch.skipStep("installtype", skip = 0)
239 slords 1.1 id.upgradeRoot = None
240    
241     return INSTALL_OK
242    
243     class CustomizeUpgradeWindow:
244     def __call__ (self, screen, dispatch, intf, id, chroot):
245     if id.upgradeRoot is None:
246     return INSTALL_NOOP
247     rc = ButtonChoiceWindow (screen, _("Customize Packages to Upgrade"),
248     _("The packages you have installed, "
249     "and any other packages which are "
250     "needed to satisfy their "
251     "dependencies, have been selected "
252     "for installation. Would you like "
253     "to customize the set of packages "
254     "that will be upgraded?"),
255     buttons = [ _("Yes"), _("No"),
256     TEXT_BACK_BUTTON],
257     help = "custupgrade")
258    
259     if rc == TEXT_BACK_CHECK:
260     return INSTALL_BACK
261    
262     if rc == string.lower (_("No")):
263     dispatch.skipStep("indivpackage")
264     else:
265     dispatch.skipStep("indivpackage", skip = 0)
266    
267     return INSTALL_OK
268    

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