Those steps have been dead code since 2004, commit 724c8db86c39536b6c84eb5b1a845d5be5bae4c5. --- pyanaconda/__init__.py | 1 - pyanaconda/dispatch.py | 4 +- pyanaconda/gui.py | 1 - pyanaconda/iw/upgrade_swap_gui.py | 202 --------------------------------- pyanaconda/text.py | 1 - pyanaconda/textw/upgrade_text.py | 103 ----------------- pyanaconda/upgrade.py | 30 ----- tests/pyanaconda_test/upgrade_test.py | 57 --------- 8 files changed, 1 insertions(+), 398 deletions(-) delete mode 100644 pyanaconda/iw/upgrade_swap_gui.py diff --git a/pyanaconda/__init__.py b/pyanaconda/__init__.py index ccbf07b..a9cfa35 100644 --- a/pyanaconda/__init__.py +++ b/pyanaconda/__init__.py @@ -83,7 +83,6 @@ class Anaconda(object): self.updateSrc = None self.upgrade = flags.cmdline.has_key("preupgrade") self.upgradeRoot = None - self.upgradeSwapInfo = None self._users = None self.mehConfig = None self.clearPartTypeSelection = None # User's GUI selection diff --git a/pyanaconda/dispatch.py b/pyanaconda/dispatch.py index 0f4499a..c2783c4 100644 --- a/pyanaconda/dispatch.py +++ b/pyanaconda/dispatch.py @@ -40,7 +40,7 @@ from bootloader import writeBootloader from flags import flags from upgrade import upgradeMountFilesystems from upgrade import restoreTime -from upgrade import upgradeSwapSuggestion, upgradeMigrateFind +from upgrade import upgradeMigrateFind from upgrade import findRootParts, queryUpgradeContinue from installmethod import doMethodComplete from kickstart import doKickstart, runPostScripts @@ -156,8 +156,6 @@ class Dispatcher(object): self._add_step("upgrademount", upgradeMountFilesystems) self._add_step("restoretime", restoreTime) self._add_step("upgradecontinue", queryUpgradeContinue) - self._add_step("upgradeswapsuggestion", upgradeSwapSuggestion) - self._add_step("addswap") self._add_step("upgrademigfind", upgradeMigrateFind) self._add_step("upgrademigratefs") self._add_step("storagedone", storageComplete) diff --git a/pyanaconda/gui.py b/pyanaconda/gui.py index f9b428f..00872c4 100755 --- a/pyanaconda/gui.py +++ b/pyanaconda/gui.py @@ -71,7 +71,6 @@ stepToClass = { "parttype" : ("autopart_type", "PartitionTypeWindow"), "cleardiskssel": ("cleardisks_gui", "ClearDisksWindow"), "findinstall" : ("examine_gui", "UpgradeExamineWindow"), - "addswap" : ("upgrade_swap_gui", "UpgradeSwapWindow"), "upgrademigratefs" : ("upgrade_migratefs_gui", "UpgradeMigrateFSWindow"), "bootloader": ("bootloader_main_gui", "MainBootloaderWindow"), "upgbootloader": ("upgrade_bootloader_gui", "UpgradeBootloaderWindow"), diff --git a/pyanaconda/iw/upgrade_swap_gui.py b/pyanaconda/iw/upgrade_swap_gui.py deleted file mode 100644 index ba9e557..0000000 --- a/pyanaconda/iw/upgrade_swap_gui.py +++ /dev/null @@ -1,202 +0,0 @@ -# -# upgrade_swap_gui.py: dialog for adding swap files for 2.4 -# -# Copyright (C) 2001, 2002 Red Hat, Inc. All rights reserved. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# -# Author(s): Mike Fulbright <msf@xxxxxxxxxx> -# - -from pyanaconda import iutil -from pyanaconda import upgrade -from pyanaconda import gui -import gobject -import gtk -from iw_gui import * -from pyanaconda.flags import flags - -from pyanaconda.constants import * -import gettext -_ = lambda x: gettext.ldgettext("anaconda", x) - -class UpgradeSwapWindow (InstallWindow): - windowTitle = N_("Upgrade Swap Partition") - - 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: - dev = model.get_value(iter, 0) - size = model.get_value(iter, 1) - 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: - self.storage.createSwapFile(dev, val) - self.dispatch.skipStep("addswap") - - return None - - def toggle (self, data): - self.swapbox.set_sensitive(self.option1.get_active()) - - def clist_cb(self, clist, row, col, data): - self.row = row - - def getScreen (self, anaconda): - self.neededSwap = 0 - self.storage = anaconda.storage - self.intf = anaconda.intf - self.dispatch = anaconda.dispatch - - rc = anaconda.upgradeSwapInfo - - self.neededSwap = 1 - self.row = 0 - box = gtk.VBox (False, 5) - box.set_border_width (5) - - label = gtk.Label(_("You currently have %(swapAmount)dMB of swap configured, which " - "is less than the recommended minimum of %(swapSuggestion)sMB. You " - "may optionally create more swap space on one of " - "your file systems now.") % {"swapAmount": iutil.swapAmount()/1024, - "swapSuggestion": iutil.swapSuggestion()[0]/1024}) - - label.set_alignment (0.5, 0.0) - label.set_line_wrap (True) - box.pack_start(label, False) - - hs = gtk.HSeparator() - box.pack_start(hs, False) - - self.option1 = gtk.RadioButton(None, - (_("I _want to create a swap file"))) - box.pack_start(self.option1, False) - - (fsList, suggSize, suggMntPoint) = rc - - self.swapbox = gtk.VBox(False, 5) - box.pack_start(self.swapbox, False) - - label = gui.MnemonicLabel (_("Select the _partition to put the swap file on:")) - a = gtk.Alignment(0.2, 0.5) - a.add(label) - self.swapbox.pack_start(a, False) - - self.store = gtk.ListStore(gobject.TYPE_STRING, - gobject.TYPE_STRING, - gobject.TYPE_STRING) - - for (dev, size) in fsList: - iter = self.store.append() - self.store.set_value(iter, 0, dev) - self.store.set_value(iter, 1, str(size)) - - self.view=gtk.TreeView(self.store) - label.set_mnemonic_widget(self.view) - - i = 0 - for title in [(_("Mount Point")), (_("Partition")), (_("Free Space (MB)"))]: - col = gtk.TreeViewColumn(title, gtk.CellRendererText(), text=i) - self.view.append_column(col) - i = i + 1 - - sw = gtk.ScrolledWindow() - sw.add(self.view) - sw.set_shadow_type(gtk.SHADOW_IN) - sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) - sw.set_size_request(300, 90) - a = gtk.Alignment(0.5, 0.5) - a.add(sw) - self.swapbox.pack_start(a, False, True, 10) - - rootiter = self.store.get_iter_first() - sel = self.view.get_selection() - sel.select_iter(rootiter) - - label = gtk.Label (_("A minimum swap file size of " - "%d MB is recommended. Please enter a size for the swap " - "file:") % suggSize) - label.set_size_request(400, 40) - label.set_line_wrap (True) - a = gtk.Alignment(0.5, 0.5) - a.add(label) - self.swapbox.pack_start(a, False, True, 10) - - - hbox = gtk.HBox(False, 5) - a = gtk.Alignment(0.4, 0.5) - a.add(hbox) - self.swapbox.pack_start(a, False) - - label = gui.MnemonicLabel (_("Swap file _size (MB):")) - hbox.pack_start(label, False) - - self.entry = gtk.Entry(4) - label.set_mnemonic_widget(self.entry) - self.entry.set_size_request(40, 25) - self.entry.set_text(str(suggSize)) - hbox.pack_start(self.entry, False, True, 10) - - self.option2 = gtk.RadioButton(self.option1, - (_("I _don't want to create a swap " - "file"))) - box.pack_start(self.option2, False, True, 20) - - self.option1.connect("toggled", self.toggle) - return box - - - def warning(self): - rc = self.intf.messageWindow(_("Warning"), - _("A swap file is strongly recommended. " - "Failure to create one could cause the installer " - "to abort abnormally. Are you sure you wish " - "to continue?"), type = "yesno") - return rc - - def swapWrongSize(self): - rc = self.intf.messageWindow(_("Warning"), - _("The swap file must be between 1 and 2000 MB in size."), - type = "okcancel") - return rc - - def swapTooBig(self): - rc = self.intf.messageWindow(_("Warning"), - _("There is not enough space on the device you " - "selected for the swap partition."), - type = "okcancel") - return rc diff --git a/pyanaconda/text.py b/pyanaconda/text.py index 6e5185f..6f756f5 100644 --- a/pyanaconda/text.py +++ b/pyanaconda/text.py @@ -52,7 +52,6 @@ stepToClasses = { "language" : ("language_text", "LanguageWindow"), "keyboard" : ("keyboard_text", "KeyboardWindow"), "parttype" : ("partition_text", "PartitionTypeWindow"), - "addswap" : ("upgrade_text", "UpgradeSwapWindow"), "upgrademigratefs" : ("upgrade_text", "UpgradeMigrateFSWindow"), "findinstall" : ("upgrade_text", "UpgradeExamineWindow"), "upgbootloader": ("upgrade_bootloader_text", "UpgradeBootloaderWindow"), diff --git a/pyanaconda/textw/upgrade_text.py b/pyanaconda/textw/upgrade_text.py index e7683b2..23166a5 100644 --- a/pyanaconda/textw/upgrade_text.py +++ b/pyanaconda/textw/upgrade_text.py @@ -103,109 +103,6 @@ class UpgradeMigrateFSWindow: screen.popWindow() return INSTALL_OK -class UpgradeSwapWindow: - def __call__ (self, screen, anaconda): - (fsList, suggSize, suggDev) = anaconda.upgradeSwapInfo - - ramDetected = iutil.memInstalled()/1024 - - text = _("You currently have %(swapAmount)dMB of swap configured, which " - "is less than the recommended minimum of %(swapSuggestion)sMB. You " - "may optionally create more swap space on one of " - "your file systems now.") % {"swapAmount": iutil.swapAmount()/1024, - "swapSuggestion": iutil.swapSuggestion()[0]/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 (device, size) in fsList: - listbox.append("%-25s %-15s %6dMB" % (device.format.mountpoint, - device.path, - size), - count) - - if (device == suggDev): - 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): - (dev, 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() - anaconda.storage.createSwapFile(dev, val) - anaconda.dispatch.skipStep("addswap") - return INSTALL_OK - - raise ValueError - class UpgradeExamineWindow: def __call__ (self, screen, anaconda): parts = anaconda.rootParts diff --git a/pyanaconda/upgrade.py b/pyanaconda/upgrade.py index 9fe8175..24309e3 100644 --- a/pyanaconda/upgrade.py +++ b/pyanaconda/upgrade.py @@ -163,36 +163,6 @@ def restoreTime(anaconda): except RuntimeError: log.error("Failed to set the clock.") -# returns None if no more swap is needed -def upgradeSwapSuggestion(anaconda): - swap = iutil.swapAmount()/1024 - (suggestedMin, suggestedMax) = iutil.swapSuggestion(quiet=1) - - anaconda.dispatch.skipStep("addswap", 0) - if suggestedMin <= swap: - anaconda.dispatch.skipStep("addswap") - return None - - fsList = [] - - for device in anaconda.storage.fsset.devices: - if not device.format: - continue - if device.format.mountable and device.format.linuxNative: - if not device.format.status: - continue - space = isys.pathSpaceAvailable(anaconda.rootPath + device.format.mountpoint) - if space > 16: - info = (device, space) - fsList.append(info) - - suggDev = None - for (device, size) in fsList: - if size > suggestedMin+100: - suggDev = device - - anaconda.upgradeSwapInfo = (fsList, suggestedMin, suggDev) - # XXX handle going backwards def upgradeMountFilesystems(anaconda): # mount everything and turn on swap diff --git a/tests/pyanaconda_test/upgrade_test.py b/tests/pyanaconda_test/upgrade_test.py index 3c849ec..d694afb 100644 --- a/tests/pyanaconda_test/upgrade_test.py +++ b/tests/pyanaconda_test/upgrade_test.py @@ -192,63 +192,6 @@ class UpgradeTest(mock.TestCase): self.assertFalse(pyanaconda.upgrade.os.environ.has_key('TZ')) self.assertTrue(pyanaconda.upgrade.copyFromSysimage.called) self.assertTrue(pyanaconda.upgrade.iutil.execWithRedirect.called) - - def upgrade_swap_suggestion_1_test(self): - """upgradeSwapSuggestion - 4GB RAM, 6GB SWAP""" - import pyanaconda.upgrade - pyanaconda.upgrade.iutil = mock.Mock() - pyanaconda.upgrade.iutil.memInstalled.return_value = 4194304 - pyanaconda.upgrade.iutil.swapAmount.return_value = 6291456 - anaconda = mock.Mock() - pyanaconda.upgrade.upgradeSwapSuggestion(anaconda) - self.assertFalse(pyanaconda.upgrade.iutil.swapAmount.called) - self.assertEqual(anaconda.dispatch.skipStep.call_args, - (('addswap', 1), {})) - - def upgrade_swap_suggestion_2_test(self): - """upgradeSwapSuggestion - 128MB RAM and 256MB SWAP""" - import pyanaconda.upgrade - pyanaconda.upgrade.iutil = mock.Mock() - pyanaconda.upgrade.iutil.memInstalled.return_value = 131072 - pyanaconda.upgrade.iutil.swapAmount.return_value = 262144 - anaconda = mock.Mock() - pyanaconda.upgrade.upgradeSwapSuggestion(anaconda) - self.assertTrue(pyanaconda.upgrade.iutil.swapAmount.called) - self.assertEqual(anaconda.dispatch.skipStep.call_args, - (('addswap', 1), {})) - - def upgrade_swap_suggestion_3_test(self): - """upgradeSwapSuggestion - 192MB RAM and 320MB SWAP""" - import pyanaconda.upgrade - pyanaconda.upgrade.iutil = mock.Mock() - pyanaconda.upgrade.iutil.memInstalled.return_value = 196608 - pyanaconda.upgrade.iutil.swapAmount.return_value = 327680 - anaconda = mock.Mock() - pyanaconda.upgrade.upgradeSwapSuggestion(anaconda) - self.assertTrue(pyanaconda.upgrade.iutil.swapAmount.called) - self.assertEqual(anaconda.dispatch.skipStep.call_args, - (('addswap', 1), {})) - - def upgrade_swap_suggestion_4_test(self): - """upgradeSwapSuggestion - 128MB RAM and 128MB SWAP""" - import pyanaconda.upgrade - DEV_SIZE = 256 - pyanaconda.upgrade.iutil = mock.Mock() - pyanaconda.upgrade.iutil.memInstalled.return_value = 131072 - pyanaconda.upgrade.iutil.swapAmount.return_value = 131072 - pyanaconda.upgrade.isys = mock.Mock() - pyanaconda.upgrade.isys.pathSpaceAvailable.return_value = DEV_SIZE - DEVICE = mock.Mock() - DEVICE.format.mountable = True - DEVICE.format.linuxNative = True - DEVICE.format.mountpoint = '/mnt' - anaconda = mock.Mock() - anaconda.rootPath = '' - anaconda.storage.fsset.devices = [DEVICE] - pyanaconda.upgrade.upgradeSwapSuggestion(anaconda) - self.assertTrue(pyanaconda.upgrade.iutil.swapAmount.called) - self.assertEqual(anaconda.upgradeSwapInfo, - ([(DEVICE, DEV_SIZE)], 128, DEVICE)) def upgrade_mount_filesystems_1_test(self): import pyanaconda.upgrade -- 1.7.3.3 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list