def getNext (self): #-If the user doesn't need to add swap, we don't do anything if not self.neededSwap: return None if self.option2.get_active(): rc = self.warning() if rc == 0: raise gui.StayOnScreen else: return None selection = self.view.get_selection() (model, iter) = selection.get_selected() if iter: mnt = model.get_value(iter, 0) part = model.get_value(iter, 1) size = int(model.get_value(iter, 2)) val = int(self.entry.get_text()) else: raise RuntimeError, "unknown value for upgrade swap location" if val > 2000 or val < 1: rc = self.swapWrongSize() raise gui.StayOnScreen elif (val+16) > size: rc = self.swapTooBig() raise gui.StayOnScreen else: if flags.setupFilesystems: upgrade.createSwapFile(self.instPath, self.fsset, mnt, val) self.dispatch.skipStep("addswap", 1) return None
def __call__(self, screen, anaconda): (fsList, suggSize, suggMntPoint) = anaconda.id.upgradeSwapInfo ramDetected = iutil.memInstalled() / 1024 text = _("The 2.4 kernel needs significantly more swap than older " "kernels, as much as twice as much swap space as RAM on the " "system. You currently have %dMB of swap configured, but " "you may create additional swap space on one of your " "file systems now.") % (iutil.swapAmount() / 1024) tb = TextboxReflowed(60, text) amount = Entry(10, scroll=0) amount.set(str(suggSize)) l = len(fsList) scroll = 0 if l > 4: l = 4 scroll = 1 listbox = Listbox(l, scroll=scroll) liLabel = Label("%-25s %-15s %8s" % (_("Mount Point"), _("Partition"), _("Free Space"))) count = 0 for (mnt, part, size) in fsList: listbox.append("%-25s /dev/%-10s %6dMB" % (mnt, part, size), count) if (mnt == suggMntPoint): listbox.setCurrent(count) count = count + 1 buttons = ButtonBar( screen, [TEXT_OK_BUTTON, (_("Skip"), "skip"), TEXT_BACK_BUTTON]) amGrid = Grid(2, 3) amGrid.setField(Label(_("RAM detected (MB):")), 0, 0, anchorLeft=1, padding=(0, 0, 1, 0)) amGrid.setField(Label(str(ramDetected)), 1, 0, anchorLeft=1) amGrid.setField(Label(_("Suggested size (MB):")), 0, 1, anchorLeft=1, padding=(0, 0, 1, 0)) amGrid.setField(Label(str(suggSize)), 1, 1, anchorLeft=1) amGrid.setField(Label(_("Swap file size (MB):")), 0, 2, anchorLeft=1, padding=(0, 0, 1, 0)) amGrid.setField(amount, 1, 2) liGrid = Grid(1, 2) liGrid.setField(liLabel, 0, 0) liGrid.setField(listbox, 0, 1) g = GridFormHelp(screen, _("Add Swap"), "upgradeswap", 1, 4) g.add(tb, 0, 0, anchorLeft=1, padding=(0, 0, 0, 1)) g.add(amGrid, 0, 1, padding=(0, 0, 0, 1)) g.add(liGrid, 0, 2, padding=(0, 0, 0, 1)) g.add(buttons, 0, 3, anchorLeft=1, growx=1) while 1: result = g.run() if (buttons.buttonPressed(result)): result = buttons.buttonPressed(result) if result == TEXT_BACK_CHECK: screen.popWindow() return INSTALL_BACK elif result == "skip": screen.popWindow() return INSTALL_OK val = amount.value() try: val = int(val) except ValueError: anaconda.intf.messageWindow( _("Error"), _("The value you entered is not a " "valid number.")) if type(val) == type(1): (mnt, part, size) = fsList[listbox.current()] if size < (val + 16): anaconda.intf.messageWindow( _("Error"), _("There is not enough space on the " "device you selected for the swap " "partition.")) elif val > 2000 or val < 1: anaconda.intf.messageWindow( _("Warning"), _("The swap file must be between 1 " "and 2000 MB in size.")) else: screen.popWindow() if flags.setupFilesystems: upgrade.createSwapFile(anaconda.rootPath, anaconda.id.fsset, mnt, val) anaconda.dispatch.skipStep("addswap", 1) return INSTALL_OK raise ValueError
def __call__ (self, screen, anaconda): (fsList, suggSize, suggMntPoint) = anaconda.id.upgradeSwapInfo ramDetected = iutil.memInstalled()/1024 text = _("The 2.4 kernel needs significantly more swap than older " "kernels, as much as twice as much swap space as RAM on the " "system. You currently have %dMB of swap configured, but " "you may create additional swap space on one of your " "file systems now.") % (iutil.swapAmount() / 1024) tb = TextboxReflowed(60, text) amount = Entry(10, scroll = 0) amount.set(str(suggSize)) l = len(fsList) scroll = 0 if l > 4: l = 4 scroll = 1 listbox = Listbox(l, scroll = scroll) liLabel = Label("%-25s %-15s %8s" % (_("Mount Point"), _("Partition"), _("Free Space"))) count = 0 for (mnt, part, size) in fsList: listbox.append("%-25s /dev/%-10s %6dMB" % (mnt, part, size), count) if (mnt == suggMntPoint): listbox.setCurrent(count) count = count + 1 buttons = ButtonBar(screen, [TEXT_OK_BUTTON, (_("Skip"), "skip"), TEXT_BACK_BUTTON] ) amGrid = Grid(2, 3) amGrid.setField(Label(_("RAM detected (MB):")), 0, 0, anchorLeft = 1, padding = (0, 0, 1, 0)) amGrid.setField(Label(str(ramDetected)), 1, 0, anchorLeft = 1) amGrid.setField(Label(_("Suggested size (MB):")), 0, 1, anchorLeft = 1, padding = (0, 0, 1, 0)) amGrid.setField(Label(str(suggSize)), 1, 1, anchorLeft = 1) amGrid.setField(Label(_("Swap file size (MB):")), 0, 2, anchorLeft = 1, padding = (0, 0, 1, 0)) amGrid.setField(amount, 1, 2) liGrid = Grid(1, 2) liGrid.setField(liLabel, 0, 0) liGrid.setField(listbox, 0, 1) g = GridFormHelp(screen, _("Add Swap"), "upgradeswap", 1, 4) g.add(tb, 0, 0, anchorLeft = 1, padding = (0, 0, 0, 1)) g.add(amGrid, 0, 1, padding = (0, 0, 0, 1)) g.add(liGrid, 0, 2, padding = (0, 0, 0, 1)) g.add(buttons, 0, 3, anchorLeft = 1, growx = 1) while 1: result = g.run() if (buttons.buttonPressed(result)): result = buttons.buttonPressed(result) if result == TEXT_BACK_CHECK: screen.popWindow() return INSTALL_BACK elif result == "skip": screen.popWindow() return INSTALL_OK val = amount.value() try: val = int(val) except ValueError: anaconda.intf.messageWindow(_("Error"), _("The value you entered is not a " "valid number.")) if type(val) == type(1): (mnt, part, size) = fsList[listbox.current()] if size < (val + 16): anaconda.intf.messageWindow(_("Error"), _("There is not enough space on the " "device you selected for the swap " "partition.")) elif val > 2000 or val < 1: anaconda.intf.messageWindow(_("Warning"), _("The swap file must be between 1 " "and 2000 MB in size.")) else: screen.popWindow() if flags.setupFilesystems: upgrade.createSwapFile(anaconda.rootPath, anaconda.id.fsset, mnt, val) anaconda.dispatch.skipStep("addswap", 1) return INSTALL_OK raise ValueError