diff options
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | pyanaconda/Makefile.am | 2 | ||||
-rw-r--r-- | pyanaconda/rescue.py | 2 | ||||
-rw-r--r-- | pyanaconda/text.py | 440 | ||||
-rw-r--r-- | pyanaconda/textw/Makefile.am | 24 | ||||
-rw-r--r-- | pyanaconda/textw/__init__.py | 0 | ||||
-rw-r--r-- | pyanaconda/textw/add_drive_text.py | 441 | ||||
-rw-r--r-- | pyanaconda/textw/complete_text.py | 65 | ||||
-rw-r--r-- | pyanaconda/textw/keyboard_text.py | 67 | ||||
-rw-r--r-- | pyanaconda/textw/language_text.py | 70 | ||||
-rw-r--r-- | pyanaconda/textw/netconfig_text.py | 451 | ||||
-rw-r--r-- | pyanaconda/textw/network_text.py | 32 | ||||
-rw-r--r-- | pyanaconda/textw/partition_text.py | 156 | ||||
-rw-r--r-- | pyanaconda/textw/progress_text.py | 131 | ||||
-rw-r--r-- | pyanaconda/textw/statusline_text.py | 78 | ||||
-rw-r--r-- | pyanaconda/textw/task_text.py | 28 | ||||
-rw-r--r-- | pyanaconda/textw/timezone_text.py | 87 | ||||
-rw-r--r-- | pyanaconda/textw/upgrade_bootloader_text.py | 81 | ||||
-rw-r--r-- | pyanaconda/textw/upgrade_text.py | 156 | ||||
-rw-r--r-- | pyanaconda/textw/userauth_text.py | 108 | ||||
-rw-r--r-- | pyanaconda/textw/zipl_text.py | 66 | ||||
-rw-r--r-- | tests/pyanaconda_test/rescue_test.py | 28 | ||||
-rwxr-xr-x | tests/pylint/runpylint.sh | 3 |
23 files changed, 4 insertions, 2513 deletions
diff --git a/configure.ac b/configure.ac index b2b5f8542..e78e00dfe 100644 --- a/configure.ac +++ b/configure.ac @@ -295,7 +295,6 @@ AC_CONFIG_FILES([Makefile tests/logpicker_test/sending_test/Makefile tests/logpicker_test/archiving_test/Makefile tests/logpicker_test/logmining_test/Makefile - pyanaconda/textw/Makefile data/post-scripts/Makefile utils/Makefile utils/log_picker/Makefile diff --git a/pyanaconda/Makefile.am b/pyanaconda/Makefile.am index f12a3b839..d106f7857 100644 --- a/pyanaconda/Makefile.am +++ b/pyanaconda/Makefile.am @@ -17,7 +17,7 @@ # # Author: Martin Sivak <msivak@redhat.com> -SUBDIRS = installclasses isys textw storage ui packaging +SUBDIRS = installclasses isys storage ui packaging MAINTAINERCLEANFILES = Makefile.in diff --git a/pyanaconda/rescue.py b/pyanaconda/rescue.py index 86d15cb88..3a37570e4 100644 --- a/pyanaconda/rescue.py +++ b/pyanaconda/rescue.py @@ -23,7 +23,7 @@ from snack import * from constants import * from constants_text import * -from text import WaitWindow, OkCancelWindow, ProgressWindow, PassphraseEntryWindow, stepToClasses +from text import WaitWindow, OkCancelWindow, ProgressWindow, PassphraseEntryWindow from flags import flags import sys import os diff --git a/pyanaconda/text.py b/pyanaconda/text.py index 58dde913c..fc92625d6 100644 --- a/pyanaconda/text.py +++ b/pyanaconda/text.py @@ -1,6 +1,4 @@ # -# text.py - text mode frontend to anaconda -# # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Red Hat, Inc. # All rights reserved. # @@ -22,51 +20,14 @@ # from snack import * -import sys -import os -import isys -import iutil -import time -import traceback -import signal -import parted -import product import string -from flags import flags -from textw.constants_text import * +from constants_text import * from constants import * -from network import hasActiveNetDev, getDevices -from installinterfacebase import InstallInterfaceBase -import imp -import textw import gettext _ = lambda x: gettext.ldgettext("anaconda", x) P_ = lambda x, y, z: gettext.ldngettext("anaconda", x, y, z) -import logging -log = logging.getLogger("anaconda") - -stepToClasses = { - "language" : ("language_text", "LanguageWindow"), - "keyboard" : ("keyboard_text", "KeyboardWindow"), - "parttype" : ("partition_text", "PartitionTypeWindow"), - "upgrademigratefs" : ("upgrade_text", "UpgradeMigrateFSWindow"), - "findinstall" : ("upgrade_text", "UpgradeExamineWindow"), - "upgbootloader": ("upgrade_bootloader_text", "UpgradeBootloaderWindow"), - "network" : ("network_text", "HostnameWindow"), - "timezone" : ("timezone_text", "TimezoneWindow"), - "accounts" : ("userauth_text", "RootPasswordWindow"), - "tasksel": ("task_text", "TaskWindow"), - "install" : ("progress_text", "setupForInstall"), - "complete" : ("complete_text", "FinishedWindow"), - "bootloader" : ("zipl_text", ( "ZiplWindow")) -} - -class InstallWindow: - def __call__ (self, screen): - raise RuntimeError, "Unimplemented screen" - class WaitWindow: def pop(self): self.screen.popWindow() @@ -136,85 +97,6 @@ class ProgressWindow: g.draw() self.screen.refresh() -class LuksPassphraseWindow: - def __init__(self, screen, passphrase = "", preexist = False): - self.screen = screen - self.passphrase = passphrase - self.minLength = 8 - self.preexist = preexist - self.txt = _("Choose a passphrase for the encrypted devices. You " - "will be prompted for this passphrase during system boot.") - self.rc = None - - def run(self): - toplevel = GridForm(self.screen, _("Passphrase for encrypted device"), - 1, 5) - - txt = TextboxReflowed(65, self.txt) - toplevel.add(txt, 0, 0) - - passphraseentry = Entry(60, password = 1) - toplevel.add(passphraseentry, 0, 1, (0,0,0,1)) - - confirmentry = Entry(60, password = 1) - toplevel.add(confirmentry, 0, 2, (0,0,0,1)) - - if self.preexist: - globalcheckbox = Checkbox(_("Also add this passphrase to all existing encrypted devices"), isOn = True) - toplevel.add(globalcheckbox, 0, 3) - - buttons = ButtonBar(self.screen, [TEXT_OK_BUTTON, TEXT_CANCEL_BUTTON]) - toplevel.add(buttons, 0, 4, growx=1) - - passphraseentry.set(self.passphrase) - confirmentry.set(self.passphrase) - - while True: - rc = toplevel.run() - res = buttons.buttonPressed(rc) - - passphrase = None - if res == TEXT_OK_CHECK or rc == "F12": - passphrase = passphraseentry.value() - confirm = confirmentry.value() - - if passphrase != confirm: - ButtonChoiceWindow(self.screen, - _("Error with passphrase"), - _("The passphrases you entered were " - "different. Please try again."), - buttons=[TEXT_OK_BUTTON]) - passphraseentry.set("") - confirmentry.set("") - continue - - if len(passphrase) < self.minLength: - ButtonChoiceWindow(self.screen, - _("Error with passphrase"), - P_("The passphrase must be at least " - "%d character long.", - "The passphrase must be at least " - "%d characters long.", - self.minLength) - % (self.minLength,), - buttons=[TEXT_OK_BUTTON]) - passphraseentry.set("") - confirmentry.set("") - continue - else: - passphrase = self.passphrase - passphraseentry.set(self.passphrase) - confirmentry.set(self.passphrase) - - retrofit = False - if self.preexist: - retrofit = globalcheckbox.selected() - self.rc = passphrase - return (self.rc, retrofit) - - def pop(self): - self.screen.popWindow() - class PassphraseEntryWindow: def __init__(self, screen, device): self.screen = screen @@ -248,323 +130,3 @@ class PassphraseEntryWindow: def pop(self): self.screen.popWindow() - -class InstallInterface(InstallInterfaceBase): - def progressWindow(self, title, text, total, updpct = 0.05, pulse = False): - return ProgressWindow(self.screen, title, text, total, updpct, pulse) - - def reinitializeWindow(self, title, path, size, description): - grid = GridForm(self.screen, title, 1, 3) - text = TEXT_REINITIALIZE % {"description": description, "size": size, "devicePath": path} - grid.add(TextboxReflowed(70, text), 0, 0) - - all_devices_cb = Checkbox(TEXT_REINITIALIZE_ALL, isOn=False) - grid.add(all_devices_cb, 0, 1, padding=(0, 1, 0, 0)) - - buttons = [(_("Yes, discard any data"), "yes"), - (_("No, keep any data"), "no")] - grid.buttons = ButtonBar(self.screen, buttons) - grid.add(grid.buttons, 0, 2, padding=(0, 1, 0, 0)) - - result = grid.run() - button_check = grid.buttons.buttonPressed(result) - self.screen.popWindow() - rc = 2 if button_check == "yes" else 0 - if all_devices_cb.selected(): - rc += 1 - return rc - - def setInstallProgressClass(self, c): - self.instProgress = c - - def exitWindow(self, title, text): - return self.messageWindow(title, text, type="custom", - custom_buttons=[_("Exit installer")]) - - def messageWindow(self, title, text, type="ok", default = None, - custom_icon=None, custom_buttons=[]): - text = str(text) - if type == "ok": - ButtonChoiceWindow(self.screen, title, text, - buttons=[TEXT_OK_BUTTON]) - elif type == "yesno": - if default and default == "no": - btnlist = [TEXT_NO_BUTTON, TEXT_YES_BUTTON] - else: - btnlist = [TEXT_YES_BUTTON, TEXT_NO_BUTTON] - rc = ButtonChoiceWindow(self.screen, title, text, - buttons=btnlist) - if rc == "yes": - return 1 - else: - return 0 - elif type == "custom": - tmpbut = [] - for but in custom_buttons: - tmpbut.append(string.replace(but,"_","")) - - rc = ButtonChoiceWindow(self.screen, title, text, width=60, - buttons=tmpbut) - - idx = 0 - for b in tmpbut: - if string.lower(b) == rc: - return idx - idx = idx + 1 - return 0 - else: - return OkCancelWindow(self.screen, title, text) - - def detailedMessageWindow(self, title, text, longText=None, type="ok", - default=None, custom_icon=None, - custom_buttons=[], expanded=False): - t = TextboxReflowed(60, text, maxHeight=8) - - # if it is a string, just print it as it is (#674322) - if isinstance(longText, basestring): - lt = Textbox(60, 6, longText, scroll=1, wrap=1) - # if the argument is anything else we have to join it together (#654074) - else: - lt = Textbox(60, 6, "\n".join(longText), scroll=1, wrap=1) - - g = GridFormHelp(self.screen, title, help, 1, 3) - g.add(t, 0, 0) - g.add(lt, 0, 1, padding = (0, 1, 0, 1)) - - if type == "ok": - bb = ButtonBar(self.screen, [TEXT_OK_BUTTON]) - g.add(bb, 0, 2, growx = 1) - return bb.buttonPressed(g.runOnce(None, None)) - elif type == "yesno": - if default and default == "no": - buttons = [TEXT_NO_BUTTON, TEXT_YES_BUTTON] - else: - buttons = [TEXT_YES_BUTTON, TEXT_NO_BUTTON] - - bb = ButtonBar(self.screen, buttons) - g.add(bb, 0, 2, growx = 1) - rc = bb.buttonPressed(g.runOnce(None, None)) - - if rc == "yes": - return 1 - else: - return 0 - elif type == "custom": - buttons = [] - idx = 0 - - for button in custom_buttons: - buttons.append(string.replace(button, "_", "")) - - bb = ButtonBar(self.screen, buttons) - g.add(bb, 0, 2, growx = 1) - rc = bb.buttonPressed(g.runOnce(None, None)) - - for b in buttons: - if string.lower(b) == rc: - return idx - idx += 1 - - return 0 - else: - return self.messageWindow(title, text, type, default, custom_icon, - custom_buttons) - - def editRepoWindow(self, repoObj): - self.messageWindow(_("Error"), - _("Repository editing is not available in text mode.")) - - def getLuksPassphrase(self, passphrase = "", preexist = False): - w = LuksPassphraseWindow(self.screen, passphrase = passphrase, - preexist = preexist) - rc = w.run() - w.pop() - return rc - - def passphraseEntryWindow(self, device): - w = PassphraseEntryWindow(self.screen, device) - passphrase = w.run() - w.pop() - return passphrase - - def enableNetwork(self): - if len(getDevices) == 0: - return False - from textw.netconfig_text import NetworkConfiguratorText - w = NetworkConfiguratorText(self.screen, self.anaconda) - ret = w.run() - return ret != INSTALL_BACK - - def kickstartErrorWindow(self, text): - s = _("The following error was found while parsing the " - "kickstart configuration file:\n\n%s") %(text,) - self.messageWindow(_("Error Parsing Kickstart Config"), - s, - type = "custom", - custom_buttons = [("_Reboot")], - custom_icon="error") - - def mainExceptionWindow(self, shortText, longTextFile): - from meh.ui.text import MainExceptionWindow - log.critical(shortText) - exnWin = MainExceptionWindow(shortText, longTextFile, screen=self.screen) - return exnWin - - def saveExceptionWindow(self, accountManager, signature, *args, **kwargs): - from meh.ui.text import SaveExceptionWindow - import urlgrabber - - if not hasActiveNetDev(): - if self.messageWindow(_("Warning"), - _("You do not have an active network connection. This is " - "required by some exception saving methods. Would you " - "like to configure your network now?"), - type = "yesno"): - - if not self.enableNetwork(): - self.messageWindow(_("No Network Available"), - _("Remote exception saving methods will not work.")) - else: - urlgrabber.grabber.reset_curl_obj() - - win = SaveExceptionWindow (accountManager, signature, screen=self.screen, - *args, **kwargs) - win.run() - - def waitWindow(self, title, text): - return WaitWindow(self.screen, title, text) - - def beep(self): - # no-op. could call newtBell() if it was bound - pass - - def drawFrame(self): - self.screen.drawRootText (0, 0, self.screen.width * " ") - if productArch: - self.screen.drawRootText (0, 0, _("Welcome to %(productName)s for %(productArch)s") % {'productName': productName, 'productArch': productArch}) - else: - self.screen.drawRootText (0, 0, _("Welcome to %s") % productName) - - self.screen.pushHelpLine(_(" <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen")) - - def setScreen(self, screen): - self.screen = screen - - def shutdown(self): - self.screen.finish() - self.screen = None - - def suspend(self): - self.screen.suspend() - - def resume(self): - self.screen.resume() - - def __init__(self): - InstallInterfaceBase.__init__(self) - signal.signal(signal.SIGINT, signal.SIG_IGN) - signal.signal(signal.SIGTSTP, signal.SIG_IGN) - self.screen = SnackScreen() - self.instProgress = None - - def __del__(self): - if self.screen: - self.screen.finish() - - def isRealConsole(self): - """Returns True if this is a _real_ console that can do things, False - for non-real consoles such as serial, i/p virtual consoles or xen.""" - if flags.serial or flags.virtpconsole: - return False - if isys.isPseudoTTY(0): - return False - if isys.isVioConsole(): - return False - return True - - def run(self, anaconda): - self.anaconda = anaconda - - if not self.isRealConsole(): - self.screen.suspendCallback(spawnShell, self.screen) - - # drop into the python debugger on ctrl-z if we're running in test mode - if flags.debug: - self.screen.suspendCallback(debugSelf, self.screen) - - # draw the frame after setting up the fallback - self.drawFrame() - # and now descend into the dispatcher - self.anaconda.dispatch.dispatch() - - def display_step(self, step): - (file, className) = stepToClasses[step] - while True: - try: - found = imp.find_module(file, textw.__path__) - moduleName = 'pyanaconda.textw.%s' % file - loaded = imp.load_module(moduleName, *found) - nextWindow = loaded.__dict__[className] - break - except ImportError as e: - log.error("loading interface component %s" % className) - log.error(traceback.format_exc()) - rc = ButtonChoiceWindow(self.screen, _("Error!"), - _("An error occurred when attempting " - "to load an installer interface " - "component.\n\nclassName = %s") - % className, - buttons=[_("Exit"), _("Retry")]) - - if rc == string.lower(_("Exit")): - sys.exit(0) - win = nextWindow() - - while True: - rc = win(self.screen, self.anaconda) - if rc == INSTALL_OK: - return DISPATCH_FORWARD - elif rc == INSTALL_NOOP: - return DISPATCH_DEFAULT - elif rc == INSTALL_BACK: - if self.anaconda.dispatch.can_go_back(): - return DISPATCH_BACK - else: - ButtonChoiceWindow(self.screen, _("Cancelled"), - _("I can't go to the previous step " - "from here. You will have to try " - "again."), - buttons=[_("OK")]) - # keep displaying the same dialog until the user gives us - # a better answer - continue - - def unsupported_steps(self): - l = ["cleardiskssel", "filtertype", "filter", "group-selection", - "partition"] - if not iutil.isS390(): - l.append("bootloader") - return l - -def killSelf(screen): - screen.finish() - os._exit(0) - -def debugSelf(screen): - screen.suspend() - import pdb - try: - pdb.set_trace() - except: - sys.exit(-1) - screen.resume() - -def spawnShell(screen): - screen.suspend() - print("\n\nType <exit> to return to the install program.\n") - if os.path.exists("/bin/sh"): - iutil.execConsole() - else: - print("Unable to find /bin/sh to execute! Not starting shell") - time.sleep(5) - screen.resume() diff --git a/pyanaconda/textw/Makefile.am b/pyanaconda/textw/Makefile.am deleted file mode 100644 index 2624967e2..000000000 --- a/pyanaconda/textw/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -# textw/Makefile.am for anaconda -# -# Copyright (C) 2009 Red Hat, Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# -# Author: David Cantrell <dcantrell@redhat.com> - -pkgpyexecdir = $(pyexecdir)/py$(PACKAGE_NAME) -textwdir = $(pkgpyexecdir)/textw -textw_PYTHON = *.py - -MAINTAINERCLEANFILES = Makefile.in diff --git a/pyanaconda/textw/__init__.py b/pyanaconda/textw/__init__.py deleted file mode 100644 index e69de29bb..000000000 --- a/pyanaconda/textw/__init__.py +++ /dev/null diff --git a/pyanaconda/textw/add_drive_text.py b/pyanaconda/textw/add_drive_text.py deleted file mode 100644 index 768681437..000000000 --- a/pyanaconda/textw/add_drive_text.py +++ /dev/null @@ -1,441 +0,0 @@ -# -# Copyright (C) 2010 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/>. -# - -from pyanaconda import iutil -from pyanaconda import network -from pyanaconda.storage import iscsi -from pyanaconda.storage import fcoe -from pyanaconda.storage import zfcp -from snack import * -from constants_text import * -from pyanaconda.constants import * -import pyanaconda.partIntfHelpers as pih -from pyanaconda import isys - -import gettext -_ = lambda x: gettext.ldgettext("anaconda", x) - -import logging -log = logging.getLogger("anaconda") - -# iSCSI Wizard classes and helpers - -class GridEntry(object): - def __init__(self, text, disabled=False, password=False, width=20): - self.text = text - self.disabled = disabled - self.password = password - self.width = width - -class iSCSITextWizard(pih.iSCSIWizard): - def __init__(self, screen): - self.screen = screen - self.entry_target_ip = None - self.entry_initiator = None - self.entry_disc_username = None - self.entry_disc_password = None - self.entry_disc_r_username = None - self.entry_disc_r_password = None - self.entry_login_username = None - self.entry_login_password = None - self.entry_login_r_username = None - self.entry_login_r_password = None - self.listbox_disc = None - self.listbox_login = None - self.listbox_nodes = None - - @staticmethod - def _auth_entries(cred_type): - all_entries = [ - GridEntry(_("CHAP Username:")), - GridEntry(_("CHAP Password:"), password=True), - GridEntry(_("Reverse CHAP Username:")), - GridEntry(_("Reverse CHAP Password:"), password=True) - ] - - entries = [None for i in range(4)] - if cred_type == pih.CRED_ONE[0]: - entries = all_entries[0:2] + [None for i in range(2)] - elif cred_type == pih.CRED_BOTH[0]: - entries = all_entries - return entries - - @staticmethod - def _build_grid(grid_entries): - entries = [] - grid = Grid(2, len(grid_entries)) - for (i, ge) in enumerate(grid_entries): - if ge: - grid.setField(Label(ge.text), 0, i) - entry = Entry(ge.width, password=ge.password) - if ge.disabled: - entry.setFlags(FLAG_DISABLED, FLAGS_SET) - grid.setField(entry, 1, i) - else: - entry = None - # we want Nones in grid_entries result in Nones in return value - entries.append(entry) - return (grid, entries) - - @staticmethod - def _value_when(entry): - return entry.value() if entry else None - - def _discovery_auth_dialog(self): - if self.listbox_disc.current() == pih.CRED_NONE[0]: - # we need not collect anything - return True - - grid = GridForm(self.screen, _("iSCSI Discovery Credentials"), 1, 3) - grid.add(TextboxReflowed(50, - _("Please enter the iSCSI " - "discovery credentials.")), - 0, 0) - auth_entries = self._auth_entries(self.listbox_disc.current()) - (basic_grid, entries) = self._build_grid(auth_entries) - (self.entry_disc_username, - self.entry_disc_password, - self.entry_disc_r_username, - self.entry_disc_r_password) = entries - - grid.add(basic_grid, 0, 1, padding=(0, 1, 0, 1)) - - grid.buttons = ButtonBar(self.screen, - [TEXT_OK_BUTTON,TEXT_CANCEL_BUTTON]) - grid.add(grid.buttons, 0, 2, padding=(0, 1, 0, -1)) - - return self._run_grid(grid) - - def _discovery_setup_dialog(self, initiator, initiator_set): - grid = GridForm(self.screen, _("iSCSI Discovery"), 1, 7) - header_text = TextboxReflowed(60, - _("To use iSCSI disks, you must provide " - "the address of your iSCSI target and " - "the iSCSI initiator name you've " - "configured for your host.")) - grid.add(header_text, 0, 0) - - entry_list = [ - GridEntry(_("Target IP Address:"), width=40), - GridEntry(_("iSCSI Initiator Name:"), - disabled=initiator_set, - width=40) - ] - (basic_grid, (self.entry_target_ip, self.entry_initiator)) = \ - self._build_grid(entry_list) - self.entry_initiator.set(initiator) - grid.add(basic_grid, 0, 1) - - grid.add(TextboxReflowed(60, - _("What kind of iSCSI discovery " - "authentication do you wish to perform:")), - 0, 2, padding=(0, 1, 0, 0)) - - self.listbox_disc = Listbox(3, scroll=1) - self.listbox_disc.append(*reversed(pih.CRED_NONE)) - self.listbox_disc.append(*reversed(pih.CRED_ONE)) - self.listbox_disc.append(*reversed(pih.CRED_BOTH)) - grid.add(self.listbox_disc, 0, 3) - - grid.add(TextboxReflowed(60, - _("What kind of iSCSI login authentication " - "do you wish to perform:")), - 0, 4, padding=(0, 1, 0, 0)) - - self.listbox_login = Listbox(3, scroll=1) - self.listbox_login.append(*reversed(pih.CRED_NONE)) - self.listbox_login.append(*reversed(pih.CRED_ONE)) - self.listbox_login.append(*reversed(pih.CRED_BOTH)) - self.listbox_login.append(*reversed(pih.CRED_REUSE)) - grid.add(self.listbox_login, 0, 5) - - grid.buttons = ButtonBar(self.screen, - [TEXT_OK_BUTTON, TEXT_CANCEL_BUTTON]) - grid.add(grid.buttons, 0, 6, padding=(0, 1, 0, -1)) - - return self._run_grid(grid) - - def _run_grid(self, grid): - result = grid.run() - button = grid.buttons.buttonPressed(result) - self.screen.popWindow() - return bool(button == TEXT_OK_CHECK or result == "F12") - - def destroy_dialogs(self): - pass - - def display_discovery_dialog(self, initiator, initiator_set): - # this is in fact two dialogs here due to limited screen space in TUI - return self._discovery_setup_dialog(initiator, initiator_set) and \ - self._discovery_auth_dialog() - - def display_login_dialog(self): - # in TUI, the login credentials are asked for with nodes list, so this - # should never stop us: - return True - - def display_nodes_dialog(self, found_nodes, ifaces): - grid_height = 4 - basic_grid = None - if self.listbox_login.current() not in \ - (pih.CRED_NONE[0], pih.CRED_REUSE[0]): - auth_entries = self._auth_entries(self.listbox_login.current()) - (basic_grid, entries) = self._build_grid(auth_entries) - (self.entry_login_username, - self.entry_login_password, - self.entry_login_r_username, - self.entry_login_r_password) = entries - - grid_height += 1 - - grid = GridForm(self.screen, _("iSCSI Discovered Nodes"), 1, 5) - grid.add(TextboxReflowed(50, - _("Check the nodes you wish to log into:")), - 0, 0) - - listbox = CheckboxTree(5, scroll=1) - # unfortunately, Listbox.add won't accept node directly as the second - # argument, we have to remember the list and use an index - for i, node in enumerate(found_nodes): - node_description = "%s via %s" % (node.name, - ifaces.get(node.iface, - node.iface)) - listbox.append(node_description, i, selected=True) - grid.add(listbox, 0, 1, padding=(0, 1, 0, 1)) - - if basic_grid: - grid.add(TextboxReflowed(60, - _("Please enter iSCSI login credentials " - "for the selected nodes:")), - 0, 2) - grid.add(basic_grid, 0, 3, padding=(0, 1, 0, 1)) - - grid.buttons = ButtonBar(self.screen, - [TEXT_OK_BUTTON, TEXT_CANCEL_BUTTON]) - grid.add(grid.buttons, 0, 4, padding=(0, 0, 0, -1)) - - rc = self._run_grid(grid) - selected_nodes = [node for (i, node) in enumerate(found_nodes) - if i in listbox.getSelection()] - return (rc, selected_nodes) - - def display_success_dialog(self, success_nodes, fail_nodes, fail_reason, - ifaces): - buttons = [TEXT_OK_BUTTON] - msg = _("Successfully logged into all the selected nodes.") - msg_reason = _("Reason:") - if fail_nodes: - buttons.append(TEXT_RETRY_BUTTON) - msg = _("Could not log into the following nodes:\n") - msg = reduce(lambda s1, s2: "%s\n%s" % (s1, s2), fail_nodes, msg) - if fail_reason: - msg = "%s\n\n%s\n%s" % (msg, msg_reason, fail_reason) - - rc = ButtonChoiceWindow(self.screen, - _("iSCSI Login Results"), - msg, - buttons) - return True if rc == TEXT_OK_CHECK else False - - def get_discovery_dict(self): - - dct = { - 'username' : self._value_when(self.entry_disc_username), - 'password' : self._value_when(self.entry_disc_password), - 'r_username' : self._value_when(self.entry_disc_r_username), - 'r_password' : self._value_when(self.entry_disc_r_password) - } - entered_ip = self.entry_target_ip.value() - (ip, port) = pih.parse_ip(entered_ip) - dct["ipaddr"] = ip - dct["port"] = port - return dct - - def get_initiator(self): - return self.entry_initiator.value() - - def get_login_dict(self): - auth_kind = self.listbox_login.current() - if auth_kind == pih.CRED_REUSE[0]: - discovery_dict = self.get_discovery_dict() - dct = dict((k,discovery_dict[k]) for k in discovery_dict if k in - ['username', - 'password', - 'r_username', - 'r_password']) - else: - dct = { - 'username' : self._value_when(self.entry_login_username), - 'password' : self._value_when(self.entry_login_password), - 'r_username' : self._value_when(self.entry_login_r_username), - 'r_password' : self._value_when(self.entry_login_r_password) - } - - return dct - - def set_initiator(self, initiator, initiator_set): - pass - -# general add drive stuff - -class addDriveDialog(object): - def __init__(self, anaconda): - self.anaconda = anaconda - - def addDriveDialog(self, screen): - newdrv = [] - if iscsi.has_iscsi(): - if iscsi.iscsi().mode == "none": - newdrv.append("Add iSCSI target") - newdrv.append("Add iSCSI target - use interface binding") - elif iscsi.iscsi().mode == "bind": - newdrv.append("Add iSCSI target - use interface binding") - elif iscsi.iscsi().mode == "default": - newdrv.append("Add iSCSI target") - if iutil.isS390(): - newdrv.append( "Add zFCP LUN" ) - if fcoe.has_fcoe(): - newdrv.append("Add FCoE SAN") - - if len(newdrv) == 0: - return INSTALL_BACK - - (button, choice) = ListboxChoiceWindow(screen, - _("Advanced Storage Options"), - _("How would you like to modify " - "your drive configuration?"), - newdrv, - [ TEXT_OK_BUTTON, TEXT_BACK_BUTTON], - width=55, height=3) - - if button == TEXT_BACK_CHECK: - return INSTALL_BACK - if newdrv[choice] == "Add zFCP LUN": - try: - return self.addZFCPDriveDialog(screen) - except ValueError as e: - ButtonChoiceWindow(screen, _("Error"), str(e)) - return INSTALL_BACK - elif newdrv[choice] == "Add FCoE SAN": - try: - return self.addFcoeDriveDialog(screen) - except ValueError as e: - ButtonChoiceWindow(screen, _("Error"), str(e)) - return INSTALL_BACK - elif newdrv[choice].startswith("Add iSCSI target"): - bind = newdrv[choice] == "Add iSCSI target - use interface binding" - try: - return self.addIscsiDriveDialog(screen, bind) - except (ValueError, IOError) as e: - ButtonChoiceWindow(screen, _("Error"), str(e)) - return INSTALL_BACK - - def addZFCPDriveDialog(self, screen): - (button, entries) = EntryWindow(screen, - _("Add FCP Device"), - _("zSeries machines can access industry-standard SCSI devices via Fibre Channel (FCP). You need to provide a 16 bit device number, a 64 bit World Wide Port Name (WWPN), and a 64 bit FCP LUN for each device."), - prompts = [ "Device number", - "WWPN", - "FCP LUN" ] ) - if button == TEXT_CANCEL_CHECK: - return INSTALL_BACK - - devnum = entries[0].strip() - wwpn = entries[1].strip() - fcplun = entries[2].strip() - - # This may throw a value error, which gets handled by addDriveDialog() - zfcp.ZFCP().addFCP(devnum, wwpn, fcplun) - - return INSTALL_OK - - def addFcoeDriveDialog(self, screen): - devs = network.getDevices() - devs.sort() - - if not devs: - ButtonChoiceWindow(screen, _("Error"), - _("No network cards present.")) - return INSTALL_BACK - - grid = GridFormHelp(screen, _("Add FCoE SAN"), "fcoeconfig", - 1, 4) - - tb = TextboxReflowed(60, - _("Select which NIC is connected to the FCoE SAN.")) - grid.add(tb, 0, 0, anchorLeft = 1, padding = (0, 0, 0, 1)) - - interfaceList = Listbox(height=len(devs), scroll=1) - for dev in devs: - hwaddr = isys.getMacAddress(dev) - if hwaddr: - desc = "%s - %.50s" % (dev, hwaddr) - else: - desc = dev - - interfaceList.append(desc, dev) - - interfaceList.setCurrent(devs[0]) - grid.add(interfaceList, 0, 1, padding = (0, 1, 0, 0)) - - dcbCheckbox = Checkbox(_("Use DCB"), 1) - grid.add(dcbCheckbox, 0, 2, anchorLeft = 1) - autovlanCheckbox = Checkbox(_("Use auto vlan"), 1) - grid.add(autovlanCheckbox, 0, 3, anchorLeft = 1) - - buttons = ButtonBar(screen, [TEXT_OK_BUTTON, TEXT_BACK_BUTTON] ) - grid.add(buttons, 0, 4, anchorLeft = 1, growx = 1) - - result = grid.run() - if buttons.buttonPressed(result) == TEXT_BACK_CHECK: - screen.popWindow() - return INSTALL_BACK - - nic = interfaceList.current() - dcb = dcbCheckbox.selected() - auto_vlan = autovlanCheckbox.selected() - - fcoe.fcoe().addSan(nic=nic, dcb=dcb, auto_vlan=auto_vlan, - intf=self.anaconda.intf) - - screen.popWindow() - return INSTALL_OK - - def addIscsiDriveDialog(self, screen, bind=False): - if not network.hasActiveNetDev(): - ButtonChoiceWindow(screen, _("Error"), - "Must have a network configuration set up " - "for iSCSI config. Please boot with " - "'linux asknetwork'") - log.info("addIscsiDriveDialog(): early exit, network disabled.") - return INSTALL_BACK - - # This will modify behaviour of iscsi.discovery() function - if iscsi.iscsi().mode == "none" and not bind: - iscsi.iscsi().delete_interfaces() - elif (iscsi.iscsi().mode == "none" and bind) \ - or iscsi.iscsi().mode == "bind": - active = set(network.getActiveNetDevs()) - created = set(iscsi.iscsi().ifaces.values()) - iscsi.iscsi().create_interfaces(active - created) - - wizard = iSCSITextWizard(screen) - login_ok_nodes = pih.drive_iscsi_addition(self.anaconda, wizard) - if len(login_ok_nodes): - return INSTALL_OK - log.info("addIscsiDriveDialog(): no new nodes added") - return INSTALL_BACK diff --git a/pyanaconda/textw/complete_text.py b/pyanaconda/textw/complete_text.py deleted file mode 100644 index 3c4e3f396..000000000 --- a/pyanaconda/textw/complete_text.py +++ /dev/null @@ -1,65 +0,0 @@ -# -# complete_text.py: text mode congratulations windows -# -# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 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/>. -# - -from snack import * -from constants_text import * -from pyanaconda.constants import * -import gettext -from pyanaconda import platform -_ = lambda x: gettext.ldgettext("anaconda", x) - -class FinishedWindow: - - def __call__ (self, screen, anaconda): - bootstr = "" - buttonstr = _("Reboot") - - bottomstr = _("<Enter> to exit") - - screen.pushHelpLine (string.center(bottomstr, screen.width)) - - if isinstance(anaconda.platform, platform.S390): - txt = _("Congratulations, your %s installation is complete.\n\n") % (productName,) - - if not anaconda.canReIPL: - buttonstr = _("Shutdown") - - txt = txt + _("Please shutdown to use the installed system.\n") - else: - txt = txt + _("Please reboot to use the installed system.\n") - - if not anaconda.reIPLMessage is None: - txt = txt + "\n" + anaconda.reIPLMessage + "\n\n" - - txt = txt + _("Note that updates may be available to ensure the proper " - "functioning of your system and installation of these " - "updates is recommended after the reboot.") - else: - txt = _("Congratulations, your %s installation is complete.\n\n" - "Please reboot to use the installed system. " - "Note that updates may be available to ensure the proper " - "functioning of your system and installation of these " - "updates is recommended after the reboot.") %(productName,) - - - rc = ButtonChoiceWindow (screen, _("Complete"), txt, - [ buttonstr ], help = "finished", width=60) - - return INSTALL_OK diff --git a/pyanaconda/textw/keyboard_text.py b/pyanaconda/textw/keyboard_text.py deleted file mode 100644 index 9e0a32b95..000000000 --- a/pyanaconda/textw/keyboard_text.py +++ /dev/null @@ -1,67 +0,0 @@ -# -# keyboard_text: text mode keyboard setup dialogs -# -# 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/>. -# - -from pyanaconda import isys -from snack import * -from constants_text import * -from pyanaconda.flags import flags - -from pyanaconda.constants import * -import gettext -_ = lambda x: gettext.ldgettext("anaconda", x) - -import logging -log = logging.getLogger("anaconda") - -class KeyboardWindow: - def __call__(self, screen, anaconda): - if flags.serial or flags.virtpconsole: - return INSTALL_NOOP - keyboards = anaconda.keyboard.modelDict.keys() - keyboards.sort () - - if anaconda.keyboard.beenset: - default = anaconda.keyboard.get () - else: - default = anaconda.instLanguage.getDefaultKeyboard() - - if default not in keyboards: - default = 'us' - - (button, choice) = \ - ListboxChoiceWindow(screen, _("Keyboard Selection"), - _("Which model keyboard is attached to this computer?"), keyboards, - buttons = [TEXT_OK_BUTTON, TEXT_BACK_BUTTON], width = 30, scroll = 1, height = 8, - default = default, help = "kybd") - - if button == TEXT_BACK_CHECK: - return INSTALL_BACK - - anaconda.keyboard.set (keyboards[choice]) - anaconda.keyboard.beenset = 1 - - anaconda.keyboard.activate() - - # FIXME: eventually, kbd.activate will do this - try: - isys.loadKeymap(keyboards[choice]) - except SystemError as e: - log.error("Could not install keymap %s: %s" % (keyboards[choice], e)) - return INSTALL_OK - diff --git a/pyanaconda/textw/language_text.py b/pyanaconda/textw/language_text.py deleted file mode 100644 index 81461bd56..000000000 --- a/pyanaconda/textw/language_text.py +++ /dev/null @@ -1,70 +0,0 @@ -# -# language_text.py: text mode language selection dialog -# -# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 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/>. -# - -from snack import * -from constants_text import * - -from pyanaconda.constants import * -import gettext -_ = lambda x: gettext.ldgettext("anaconda", x) - -import logging -log = logging.getLogger("anaconda") - -class LanguageWindow: - def __call__(self, screen, anaconda): - languages = anaconda.instLanguage.available () - languages.sort() - - current = anaconda.instLanguage.instLang - - height = min((8, len(languages))) - buttons = [TEXT_OK_BUTTON, TEXT_BACK_BUTTON] - - translated = [] - for lang in languages: - translated.append ((_(lang), anaconda.instLanguage.getLangByName(lang))) - (button, choice) = \ - ListboxChoiceWindow(screen, _("Language Selection"), - _("What language would you like to use during the " - "installation process?"), translated, - buttons, width = 30, default = _(current), scroll = 1, - height = height, help = "lang") - - if button == TEXT_BACK_CHECK: - return INSTALL_BACK - - if not anaconda.instLanguage.textSupported(choice): - ButtonChoiceWindow(screen, "Language Unavailable", - "%s display is unavailable in text mode. The " - "installation will continue in English." % (choice,), - buttons=[TEXT_OK_BUTTON]) - anaconda.instLanguage.instLang = choice - anaconda.instLanguage.systemLang = choice - anaconda.timezone.setTimezoneInfo(anaconda.instLanguage.getDefaultTimeZone()) - return INSTALL_OK - - anaconda.instLanguage.instLang = choice - anaconda.instLanguage.systemLang = choice - anaconda.timezone.setTimezoneInfo(anaconda.instLanguage.getDefaultTimeZone()) - - anaconda.intf.drawFrame() - - return INSTALL_OK diff --git a/pyanaconda/textw/netconfig_text.py b/pyanaconda/textw/netconfig_text.py deleted file mode 100644 index daa732989..000000000 --- a/pyanaconda/textw/netconfig_text.py +++ /dev/null @@ -1,451 +0,0 @@ -# -# netconfig_text.py: Configure a network interface now. -# -# Copyright (C) 2008 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): Chris Lumens <clumens@redhat.com> -# David Cantrell <dcantrell@redhat.com> -# - - -from pyanaconda import isys -from pyanaconda import network -from snack import * -from constants_text import * - -import gettext -_ = lambda x: gettext.ldgettext("anaconda", x) - -class NetworkConfiguratorText: - def _handleIPError(self, field, errmsg): - self.intf.messageWindow(_("Error With Data"), - _("An error occurred converting the " - "value entered for " - "\"%(field)s\":\n%(errmsg)s") \ - % {'field': field, 'errmsg': errmsg}) - - def _handleIPMissing(self, field): - self.intf.messageWindow(_("Error With Data"), - _("A value is required for the field %s") % field) - - def __init__(self, screen, intf): - self.screen = screen - self.netdevs = network.getDevices() - - self._initValues() - - def _initValues(self): - self.ipv4Selected = 1 - self.ipv6Selected = 1 - self.ipv4Method = "v4dhcp" - self.ipv6Method = "v6auto" - self.ipv4Address = "" - self.ipv4Prefix = "" - self.ipv4Gateway = "" - self.ipv4Nameserver = "" - self.ipv6Address = "" - self.ipv6Prefix = "" - self.ipv6Gateway = "" - self.ipv6Nameserver = "" - - def run(self): - - dev_list = [] - selected_devname = None - - devnames = self.netdevs.sort() - - # Preselect device set in kickstart - ksdevice = network.get_ksdevice_name() - - for devname in devnames: - hwaddr = isys.getMacAddress(devname) - - if hwaddr: - desc = "%s - %.50s" % (devname, hwaddr) - else: - desc = devname - - if selected_devname is None: - selected_devname = devname - - if ksdevice and ksdevice == devname: - selected_devname = devname - dev_list.append((desc, devname)) - - while True: - w = self.deviceSelectionForm(dev_list, selected_devname) - result = w.run() - button = w.buttons.buttonPressed(result) - - if button == TEXT_BACK_CHECK: - self.screen.popWindow() - return INSTALL_BACK - - selected_devname = self.interfaceList.current() - - while True: - w = self.configForm(selected_devname) - result = w.run() - button = w.buttons.buttonPressed(result) - - if button == TEXT_BACK_CHECK: - self.screen.popWindow() - self.screen.popWindow() - break - - self._readValues() - if (self._checkValues() and - self._applyValues(selected_devname)): - self.screen.popWindow() - self.screen.popWindow() - return INSTALL_OK - else: - self.screen.popWindow() - - def deviceSelectionForm(self, dev_list, preselected_dev=None): - - grid = GridFormHelp(self.screen, _("Enable network interface"), "netselection", - 1, 9) - - tb = TextboxReflowed(60, _("This requires that you have an active " - "network connection during the installation " - "process. Please select network " - "interface to configure.")) - grid.add(tb, 0, 0, anchorLeft = 1, padding = (0, 0, 0, 1)) - - self.interfaceList = Listbox(3, scroll = 1, returnExit = 0) - - for (desc, dev) in dev_list: - self.interfaceList.append(desc, dev) - if preselected_dev: - self.interfaceList.setCurrent(preselected_dev) - - grid.add(self.interfaceList, 0, 1, padding = (0, 0, 0, 1)) - - grid.buttons = ButtonBar(self.screen, [TEXT_OK_BUTTON, TEXT_BACK_BUTTON] ) - grid.add(grid.buttons, 0, 2, anchorLeft = 1, growx = 1) - - return grid - - def configForm(self, devname): - - # Create device configuration screen - grid = GridFormHelp(self.screen, _("Enable network interface"), "netconfig", - 1, 13) - - tb = TextboxReflowed(60, _("Configure interface %s " - "to be used during installation process.") - % devname) - grid.add(tb, 0, 0, anchorLeft = 1, padding = (0, 0, 0, 1)) - - self.ipv4Checkbox = Checkbox(_("Enable IPv4 Support"), - isOn=self.ipv4Selected) - grid.add(self.ipv4Checkbox, 0, 1, anchorLeft = 1, padding = (0, 0, 0, 0), growx = 1) - self.v4radio = RadioGroup() - self.v4radio_auto = self.v4radio.add(_("Dynamic IP configuration (DHCP)"), - "v4dhcp", - self.ipv4Method=="v4dhcp") - self.v4radio_manual = self.v4radio.add(_("Manual Configuration"), - "v4manual", - self.ipv4Method=="v4manual") - grid.add(self.v4radio_auto, 0, 2, anchorLeft = 1, padding = (2, 0, 0, 0), growx = 1) - grid.add(self.v4radio_manual, 0, 3, anchorLeft = 1, padding = (2, 0, 0, 0), growx = 1) - - - ipv4Grid = Grid(4, 3) - ipv4Grid.setField(Label(_("IPv4 Address:")), 0, 0, padding = (0, 0, 1, 0), - anchorLeft = 1) - self.ipv4AddressEntry = Entry(20, scroll=1) - self.ipv4AddressEntry.set(self.ipv4Address) - ipv4Grid.setField(self.ipv4AddressEntry, 1, 0) - ipv4Grid.setField(Label("/"), 2, 0) - self.ipv4PrefixEntry = Entry(3, scroll=0) - self.ipv4PrefixEntry.set(self.ipv4Prefix) - ipv4Grid.setField(self.ipv4PrefixEntry, 3, 0) - ipv4Grid.setField(Label(_("Gateway:")), 0, 1, padding = (0, 0, 0, 0), - anchorLeft = 1) - self.ipv4GatewayEntry = Entry(20, scroll=1) - self.ipv4GatewayEntry.set(self.ipv4Gateway) - ipv4Grid.setField(self.ipv4GatewayEntry, 1, 1) - ipv4Grid.setField(Label(_("Nameserver:")), 0, 2, padding = (0, 0, 0, 0), - anchorLeft = 1) - self.ipv4NameserverEntry = Entry(20, scroll=1) - self.ipv4NameserverEntry.set(self.ipv4Nameserver) - ipv4Grid.setField(self.ipv4NameserverEntry, 1, 2) - - grid.add(ipv4Grid, 0, 4, anchorLeft = 1, padding = (6, 0, 0, 0)) - - self.ipv6Checkbox = Checkbox(_("Enable IPv6 Support"), - isOn=self.ipv6Selected) - grid.add(self.ipv6Checkbox, 0, 5, anchorLeft = 1, padding = (0, 0, 0, 0), growx = 1) - self.v6radio = RadioGroup() - self.v6radio_auto = self.v6radio.add(_("Automatic neighbor discovery"), - "v6auto", - self.ipv6Method=="v6auto") - self.v6radio_dhcp = self.v6radio.add(_("Dynamic IP Configuration (DHCPv6)"), - "v6dhcp", - self.ipv6Method=="v6dhcp") - self.v6radio_manual = self.v6radio.add(_("Manual Configuration"), - "v6manual", - self.ipv6Method=="v6manual") - grid.add(self.v6radio_auto, 0, 6, anchorLeft = 1, padding = (2, 0, 0, 0), growx = 1) - grid.add(self.v6radio_dhcp, 0, 7, anchorLeft = 1, padding = (2, 0, 0, 0), growx = 1) - grid.add(self.v6radio_manual, 0, 8, anchorLeft = 1, padding = (2, 0, 0, 0), growx = 1) - - ipv6Grid = Grid(4, 3) - ipv6Grid.setField(Label(_("IPv6 Address:")), 0, 0, padding = (0, 0, 1, 0), - anchorLeft = 1) - self.ipv6AddressEntry = Entry(41, scroll=1) - self.ipv6AddressEntry.set(self.ipv6Address) - ipv6Grid.setField(self.ipv6AddressEntry, 1, 0) - ipv6Grid.setField(Label("/"), 2, 0) - self.ipv6PrefixEntry = Entry(4, scroll=0) - self.ipv6PrefixEntry.set(self.ipv6Prefix) - ipv6Grid.setField(self.ipv6PrefixEntry, 3, 0) - ipv6Grid.setField(Label(_("Gateway:")), 0, 1, padding = (0, 0, 0, 0), - anchorLeft = 1) - self.ipv6GatewayEntry = Entry(41, scroll=1) - self.ipv6GatewayEntry.set(self.ipv6Gateway) - ipv6Grid.setField(self.ipv6GatewayEntry, 1, 1) - ipv6Grid.setField(Label(_("Nameserver:")), 0, 2, padding = (0, 0, 0, 0), - anchorLeft = 1) - self.ipv6NameserverEntry = Entry(41, scroll=1) - self.ipv6NameserverEntry.set(self.ipv6Nameserver) - ipv6Grid.setField(self.ipv6NameserverEntry, 1, 2) - - grid.add(ipv6Grid, 0, 9, anchorLeft = 1, padding = (6, 0, 0, 0)) - - grid.buttons = ButtonBar(self.screen, [TEXT_OK_BUTTON, TEXT_BACK_BUTTON]) - grid.add(grid.buttons, 0, 10, anchorLeft = 1, growx = 1) - - self.v4radio_manual.setCallback(self._ipv4MethodToggled) - self.v4radio_auto.setCallback(self._ipv4MethodToggled) - self.v6radio_manual.setCallback(self._ipv6MethodToggled) - self.v6radio_auto.setCallback(self._ipv6MethodToggled) - self.v6radio_dhcp.setCallback(self._ipv6MethodToggled) - self.ipv4Checkbox.setCallback(self._ipv4MethodToggled) - self.ipv6Checkbox.setCallback(self._ipv6MethodToggled) - - self._ipv4MethodToggled() - self._ipv6MethodToggled() - - return grid - - - def _readValues(self): - self.ipv4Selected = self.ipv4Checkbox.selected() - self.ipv6Selected = self.ipv6Checkbox.selected() - self.ipv4Method = self.v4radio.getSelection() - self.ipv6Method = self.v6radio.getSelection() - self.ipv4Address = self.ipv4AddressEntry.value() - self.ipv4Prefix = self.ipv4PrefixEntry.value() - self.ipv4Gateway = self.ipv4GatewayEntry.value() - self.ipv4Nameserver = self.ipv4NameserverEntry.value() - self.ipv6Address = self.ipv6AddressEntry.value() - self.ipv6Prefix = self.ipv6PrefixEntry.value() - self.ipv6Gateway = self.ipv6GatewayEntry.value() - self.ipv6Nameserver = self.ipv6NameserverEntry.value() - - def _checkValues(self): - if not self.ipv4Selected and not self.ipv6Selected: - self.intf.messageWindow(_("Missing protocol"), - _("You must select at least one protocol version")) - return False - - if self.ipv4Selected: - if self.ipv4Method == "v4manual": - try: - network.sanityCheckIPString(self.ipv4Address) - except network.IPMissing as msg: - self._handleIPMissing(_("IPv4 Address")) - return False - except network.IPError as msg: - self._handleIPError(_("IPv4 Address"), msg) - return False - - if not self.ipv4Prefix: - self._handleIPMissing(_("IPv4 Prefix")) - return False - elif (int(self.ipv4Prefix) < 0 or - int(self.ipv4Prefix) > 32): - msg = _("IPv4 CIDR prefix must be between 0 and 32.") - self._handleIPError(_("IPv4 Prefix"), msg) - return False - - if self.ipv4Gateway: - try: - network.sanityCheckIPString(self.ipv4Gateway) - except network.IPError as msg: - self._handleIPError(_("IPv4 Gateway"), msg) - return False - - if self.ipv4Nameserver: - for addr in self.ipv4Nameserver.split(','): - addr.split() - try: - network.sanityCheckIPString(addr) - except network.IPError as msg: - self._handleIPError(_("IPv4 Nameserver"), msg) - return False - - if self.ipv6Selected: - if self.ipv6Method == "v6manual": - try: - network.sanityCheckIPString(self.ipv6Address) - except network.IPMissing as msg: - self._handleIPMissing(_("IPv6 Address")) - return False - except network.IPError as msg: - self._handleIPError(_("IPv6 Address"), msg) - return False - - if not self.ipv6Prefix: - self._handleIPMissing(_("IPv6 Prefix")) - return False - elif (int(self.ipv6Prefix) < 0 or - int(self.ipv6Prefix) > 128): - msg = _("IPv6 CIDR prefix must be between 0 and 128.") - self._handleIPError(_("IPv6 Prefix"), msg) - return False - - if self.ipv6Gateway: - try: - network.sanityCheckIPString(self.ipv6Gateway) - except network.IPError as msg: - self._handleIPError(_("IPv6 Gateway"), msg) - return False - if self.ipv6Nameserver: - for addr in self.ipv6Nameserver.split(','): - addr.split() - try: - network.sanityCheckIPString(addr) - except network.IPError as msg: - self._handleIPError(_("IPv6 Nameserver"), msg) - return False - - return True - - def _applyValues(self, devname): - """Activates device devname. - - Returns True in case of success, False if failed. - """ - - dev = network.NetworkDevice(ROOT_PATH, devname) - dev.loadIfcfgFile() - - nameservers = '' - - if self.ipv4Selected: - if self.ipv4Method == "v4dhcp": - dev.set(("BOOTPROTO", "dhcp")) - elif self.ipv4Method == "v4manual": - dev.set(("BOOTPROTO", "static")) - dev.set(("IPADDR", self.ipv4Address)) - dev.set(("PREFIX", self.ipv4Prefix)) - if self.ipv4Gateway: - dev.set(("GATEWAY", self.ipv4Gateway)) - if self.ipv4Nameserver: - nameservers += self.ipv4Nameserver - else: - dev.unset("BOOTPROTO") - dev.unset("IPADDR") - dev.unset("PREFIX") - dev.unset("GATEWAY") - - if self.ipv6Selected: - dev.set(("IPV6INIT", "yes")) - if self.ipv6Method == "v6auto": - dev.set(("IPV6_AUTOCONF", "yes")) - elif self.ipv6Method == "v6dhcp": - dev.set(("IPV6_AUTOCONF", "no")) - dev.set(("DHCPV6C", "yes")) - elif self.ipv6Method == "v6manual": - dev.set(("IPV6_AUTOCONF", "no")) - dev.set(("IPV6ADDR", "%s/%s" % (self.ipv6Address, - self.ipv6Prefix))) - if self.ipv6Gateway: - dev.set(("IPV6_DEFAULTGW", self.ipv6Gateway)) - if self.ipv6Nameserver: - if nameservers: - nameservers += ',' - nameservers += self.ipv6Nameserver - else: - dev.set(("IPV6INIT", "no")) - - self.netdevs[devname].unsetDNS() - if nameservers: - self.netdevs[devname].setDNS(nameservers) - - dev.set(('ONBOOT', 'yes')) - - w = self.intf.waitWindow(_("Configuring Network Interfaces"), _("Waiting for NetworkManager")) - dev.writeIfcfgFile() - result = network.waitForConnection() - w.pop() - if not result: - self.intf.messageWindow(_("Network Error"), - _("There was an error configuring " - "network device %s") % dev.iface) - dev.set(("ONBOOT", "no")) - dev.writeIfcfgFile() - return False - - return True - - def _ipv4MethodToggled(self, *args): - if (self.v4radio.getSelection() == "v4manual" and - self.ipv4Checkbox.selected()): - flag = FLAGS_RESET - else: - flag = FLAGS_SET - - self.ipv4AddressEntry.setFlags(FLAG_DISABLED, flag) - self.ipv4PrefixEntry.setFlags(FLAG_DISABLED, flag) - self.ipv4GatewayEntry.setFlags(FLAG_DISABLED, flag) - self.ipv4NameserverEntry.setFlags(FLAG_DISABLED, flag) - - # Update flags for radio buttons based on whether ipv4 is selected - if self.ipv4Checkbox.selected(): - self.v4radio_auto.w.checkboxSetFlags(FLAG_DISABLED, FLAGS_RESET) - self.v4radio_manual.w.checkboxSetFlags(FLAG_DISABLED, FLAGS_RESET) - else: - self.v4radio_auto.w.checkboxSetFlags(FLAG_DISABLED, FLAGS_SET) - self.v4radio_manual.w.checkboxSetFlags(FLAG_DISABLED, FLAGS_SET) - - def _ipv6MethodToggled(self, *args): - if (self.v6radio.getSelection() == "v6manual" and - self.ipv6Checkbox.selected()): - flag = FLAGS_RESET - else: - flag = FLAGS_SET - - self.ipv6AddressEntry.setFlags(FLAG_DISABLED, flag) - self.ipv6PrefixEntry.setFlags(FLAG_DISABLED, flag) - self.ipv6GatewayEntry.setFlags(FLAG_DISABLED, flag) - self.ipv6NameserverEntry.setFlags(FLAG_DISABLED, flag) - - # Update flags for radio buttons based on whether ipv6 is selected - if self.ipv6Checkbox.selected(): - self.v6radio_auto.w.checkboxSetFlags(FLAG_DISABLED, FLAGS_RESET) - self.v6radio_dhcp.w.checkboxSetFlags(FLAG_DISABLED, FLAGS_RESET) - self.v6radio_manual.w.checkboxSetFlags(FLAG_DISABLED, FLAGS_RESET) - else: - self.v6radio_auto.w.checkboxSetFlags(FLAG_DISABLED, FLAGS_SET) - self.v6radio_dhcp.w.checkboxSetFlags(FLAG_DISABLED, FLAGS_SET) - self.v6radio_manual.w.checkboxSetFlags(FLAG_DISABLED, FLAGS_SET) diff --git a/pyanaconda/textw/network_text.py b/pyanaconda/textw/network_text.py deleted file mode 100644 index a33d7f544..000000000 --- a/pyanaconda/textw/network_text.py +++ /dev/null @@ -1,32 +0,0 @@ -# -# network_text.py: text mode network configuration dialogs -# -# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 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): Jeremy Katz <katzj@redhat.com> -# Michael Fulbright <msf@redhat.com> -# David Cantrell <dcantrell@redhat.com> -# -from constants_text import * -from pyanaconda import network - -class HostnameWindow: - def __call__(self, screen, anaconda): - hname = network.getHostname() - return INSTALL_OK - -# vim:tw=78:ts=4:et:sw=4 diff --git a/pyanaconda/textw/partition_text.py b/pyanaconda/textw/partition_text.py deleted file mode 100644 index 96702cea9..000000000 --- a/pyanaconda/textw/partition_text.py +++ /dev/null @@ -1,156 +0,0 @@ -# -# partition_text.py: allows the user to choose how to partition their disks -# in text mode -# -# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 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): Jeremy Katz <katzj@redhat.com> -# - -import os, sys -from pyanaconda import isys -import copy -from pyanaconda import network -import parted -from pyanaconda.partIntfHelpers import * -from snack import * -from constants_text import * -from pyanaconda.constants import * -from add_drive_text import addDriveDialog - -import gettext -_ = lambda x: gettext.ldgettext("anaconda", x) - -import logging -log = logging.getLogger("anaconda") - -class PartitionTypeWindow: - def typeboxChange(self, (typebox, drivelist)): - flag = FLAGS_RESET - if typebox.current() == CLEARPART_TYPE_NONE: - flag = FLAGS_SET - # XXX need a way to disable the checkbox tree - - def clearDrivelist(self): - # XXX remove parted object refs - # need to put in clear() method for checkboxtree in snack - self.drivelist.key2item = {} - self.drivelist.item2key = {} - - def __call__(self, screen, anaconda): - self.anaconda = anaconda - - while True: - g = GridFormHelp(screen, _("Partitioning Type"), "autopart", 1, 6) - - txt = TextboxReflowed(65, _("Installation requires partitioning of your hard drive. The default layout is suitable for most users. Select what space to use and which drives to use as the install target.")) - g.add(txt, 0, 0, (0, 0, 0, 0)) - - opts = ((_("Use entire drive"), CLEARPART_TYPE_ALL), - (_("Replace existing Linux system"), CLEARPART_TYPE_LINUX), - (_("Use free space"), CLEARPART_TYPE_NONE)) - typebox = Listbox(height = len(opts), scroll = 0) - for (txt, val) in opts: - typebox.append(txt, val) - - if anaconda.storage.config.clearPartType is None: - preselection = CLEARPART_TYPE_LINUX - else: - preselection = anaconda.storage.config.clearPartType - typebox.setCurrent(preselection) - - g.add(typebox, 0, 1, (0, 1, 0, 0)) - - # list of drives to select which to clear - subgrid = Grid(1, 2) - subgrid.setField(TextboxReflowed(55, _("Which drive(s) do you want to " - "use for this installation?")), - 0, 0) - drivelist = CheckboxTree(height=2, scroll=1) - subgrid.setField(drivelist, 0, 1) - g.add(subgrid, 0, 2, (0, 1, 0, 0)) - - bb = ButtonBar(screen, [ TEXT_OK_BUTTON, TEXT_BACK_BUTTON ]) - g.add(bb, 0, 5, (0,1,0,0)) - - - typebox.setCallback(self.typeboxChange, (typebox, drivelist)) - self.drivelist = drivelist - - g.addHotKey("F2") - screen.pushHelpLine (_("<Space>,<+>,<-> selection | <F2> Add drive | <F12> next screen")) - - # restore the drive list each time - disks = filter(lambda d: not d.format.hidden, anaconda.storage.disks) - cleardrives = anaconda.storage.config.clearPartDisks - - for disk in disks: - model = disk.model - - if not cleardrives or len(cleardrives) < 1: - selected = 1 - else: - if disk.name in cleardrives: - selected = 1 - else: - selected = 0 - - sizestr = "%8.0f MB" % (disk.size,) - diskdesc = "%6s %s (%s)" % (disk.name, sizestr, model[:23],) - - drivelist.append(diskdesc, selected = selected) - - rc = g.run() - - if len(self.drivelist.getSelection()) > 0: - sel = map(lambda s: s.split()[0], self.drivelist.getSelection()) - else: - sel = [] - partmethod_ans = typebox.current() - res = bb.buttonPressed(rc) - - self.clearDrivelist() - screen.popHelpLine() - screen.popWindow() - - if rc == "F2": - addDialog = addDriveDialog(anaconda) - if addDialog.addDriveDialog(screen) != INSTALL_BACK: - anaconda.storage.reset() - continue - - if res == TEXT_BACK_CHECK: - return INSTALL_BACK - - if anaconda.storage.checkNoDisks(): - continue - - if len(sel) < 1: - mustHaveSelectedDrive(anaconda.intf) - continue - - anaconda.dispatch.request_steps("autopartitionexecute") - anaconda.storage.doAutoPart = True - anaconda.storage.config.clearPartType = partmethod_ans - anaconda.storage.config.clearPartDisks = sel - break - - anaconda.dispatch.skip_steps("bootloader") - - return INSTALL_OK - - diff --git a/pyanaconda/textw/progress_text.py b/pyanaconda/textw/progress_text.py deleted file mode 100644 index 3735eaeec..000000000 --- a/pyanaconda/textw/progress_text.py +++ /dev/null @@ -1,131 +0,0 @@ -# -# progress_text.py: text mode install/upgrade progress dialog -# -# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 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/>. -# - -from pyanaconda.constants import * -from snack import * -from constants_text import * -from pyanaconda.iutil import strip_markup - -import gettext -_ = lambda x: gettext.ldgettext("anaconda", x) - -import logging -log = logging.getLogger("anaconda") - -class InstallProgressWindow: - def __init__(self, screen): - self.screen = screen - self.drawn = False - - self.pct = 0 - - def __del__ (self): - if self.drawn: - self.screen.popWindow () - - def _setupScreen(self): - screen = self.screen - - self.grid = GridForm(self.screen, _("Package Installation"), 1, 6) - - self.width = 65 - self.progress = Scale(self.width, 100) - self.grid.add (self.progress, 0, 1, (0, 1, 0, 0)) - - self.label = Label("") - self.grid.add(self.label, 0, 2, (0, 1, 0, 0), anchorLeft = 1) - - self.info = Textbox(self.width, 4, "", wrap = 1) - self.grid.add(self.info, 0, 3, (0, 1, 0, 0)) - - self.grid.draw() - screen.refresh() - self.drawn = True - - def processEvents(self): - if not self.drawn: - return - self.grid.draw() - self.screen.refresh() - - def setShowPercentage(self, val): - pass - - def get_fraction(self): - return self.pct - - def set_fraction(self, pct): - if not self.drawn: - self._setupScreen() - - if pct > 1.0: - pct = 1.0 - - self.progress.set(int(pct * 100)) - self.pct = pct - self.processEvents() - - def set_label(self, txt): - if not self.drawn: - self._setupScreen() - - self.info.setText(strip_markup(txt)) - self.processEvents() - - def set_text(self, txt): - if not self.drawn: - self._setupScreen() - - if len(txt) > self.width: - txt = txt[:self.width] - else: - spaces = (self.width - len(txt)) / 2 - txt = (" " * spaces) + txt - - self.label.setText(strip_markup(txt)) - self.processEvents() - -class setupForInstall: - - def __call__(self, screen, anaconda): - if anaconda.dir == DISPATCH_BACK: - anaconda.intf.setInstallProgressClass(None) - return INSTALL_BACK - - anaconda.intf.setInstallProgressClass(InstallProgressWindow(screen)) - return INSTALL_OK - -if __name__ == "__main__": - screen = SnackScreen() - ipw = InstallProgressWindow(screen) - - import time - ipw._setupScreen() - time.sleep(2) - - ipw.set_label("testing blah\n<b>blahblahb</b>lahbl ahalsdfkj") - ipw.set_text("blah blah blah") - ipw.set_fraction(0.25) - time.sleep(2) - - p = ipw.get_fraction() - - screen.finish() - print(p) diff --git a/pyanaconda/textw/statusline_text.py b/pyanaconda/textw/statusline_text.py deleted file mode 100644 index 4a4a3dbff..000000000 --- a/pyanaconda/textw/statusline_text.py +++ /dev/null @@ -1,78 +0,0 @@ -# -# statusline_text.py: text mode status line management functions -# -# Copyright (C) 2000, 2001 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/>. -# - -# XXX this file appears to be unused. - -import string -import copy - -class CleanStatusLine: - - def centerLabel(self, str, space): - return string.center(str, space) - - def formatStatusLine(self, args): - if len(args) == 1: - return self.centerLabel(args[0], self.width) - - nonspaces = 0 - for i in args: - nonspaces = nonspaces + len(i) - - spaceEach = (self.width-nonspaces)/len(args) - outstr = "" - - j = 0 - for i in args: - str = self.centerLabel(i, len(i) + spaceEach) - outstr = outstr + str - j = j + 1 - if j != len(args): - outstr = outstr + "|" - - return outstr - - def setdefaultStatusLine(self, rargs, largs): - self.rargs = rargs - self.largs = largs - - -# def defaultStatusLine(self): -# def __str__(self): -# args = copy.deepcopy(self.largs) -# args.extend(self.rargs) -# return self.formatStatusLine(args) - -# def customStatusLine(self, optargs): - def __str__(self): - args = copy.deepcopy(self.largs) - if self.optargs != None: - args.extend(self.optargs) - args.extend(self.rargs) - return self.formatStatusLine(args) - - - def __init__(self, args, optargs=None): -# self.largs = ["<Tab>/<Alt-Tab> between elements"] -# self.rargs = ["<F12> next screen"] - (self.largs, self.rargs) = args - self.optargs = optargs - - self.width = 80 - diff --git a/pyanaconda/textw/task_text.py b/pyanaconda/textw/task_text.py deleted file mode 100644 index 416e572ed..000000000 --- a/pyanaconda/textw/task_text.py +++ /dev/null @@ -1,28 +0,0 @@ -# -# task_gui.py: Choose tasks for installation -# -# Copyright (C) 2006 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/>. -# - -from constants_text import * -from pyanaconda.constants import * - -class TaskWindow: - def __call__(self, screen, anaconda): - anaconda.backend.resetPackageSelections() - anaconda.backend.selectGroup("Core") - - return INSTALL_OK diff --git a/pyanaconda/textw/timezone_text.py b/pyanaconda/textw/timezone_text.py deleted file mode 100644 index 7c9b00548..000000000 --- a/pyanaconda/textw/timezone_text.py +++ /dev/null @@ -1,87 +0,0 @@ -# -# timezone_text.py: text mode timezone selection dialog -# -# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 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/>. -# - -import sys -from pyanaconda import iutil -from time import * -from snack import * -from constants_text import * -from scdate.core import zonetab - -from pyanaconda.constants import * -import gettext -_ = lambda x: gettext.ldgettext("anaconda", x) - -sys.path.append("/usr/share/system-config-date") - -class TimezoneWindow: - def getTimezoneList(self): - zt = zonetab.ZoneTab() - zoneList = [ x.tz for x in zt.getEntries() ] - zoneList.sort() - return zoneList - - def currentTime(self): - return "Current time: " + strftime("%X %Z", localtime(time())) - - def __call__(self, screen, anaconda): - timezones = self.getTimezoneList() - (default, asUtc) = anaconda.timezone.getTimezoneInfo() - if not default: - default = anaconda.instLanguage.getDefaultTimeZone() - - bb = ButtonBar(screen, [TEXT_OK_BUTTON, TEXT_BACK_BUTTON]) - t = TextboxReflowed(30, - _("In which time zone are you located?")) - - if not anaconda.ksdata and not anaconda.bootloader.has_windows: - asUtc = True - - self.l = Listbox(5, scroll = 1, returnExit = 0) - - for tz in timezones: - self.l.append(gettext.ldgettext("system-config-date", tz), tz) - - self.l.setCurrent(default.replace("_", " ")) - - self.c = Checkbox(_("System clock uses UTC"), isOn = asUtc) - - self.g = GridFormHelp(screen, _("Time Zone Selection"), "timezone", - 1, 5) - self.g.add(t, 0, 0) - self.g.add(self.c, 0, 2, padding = (0, 1, 0, 1), anchorLeft = 1) - self.g.add(self.l, 0, 3, padding = (0, 0, 0, 1)) - self.g.add(bb, 0, 4, growx = 1) - - result = "" - while True: - result = self.g.run() - rc = bb.buttonPressed (result) - - if rc == TEXT_BACK_CHECK: - screen.popWindow() - return INSTALL_BACK - else: - break - - screen.popWindow() - anaconda.timezone.setTimezoneInfo(self.l.current().replace(" ", "_"), asUtc = self.c.selected()) - - return INSTALL_OK diff --git a/pyanaconda/textw/upgrade_bootloader_text.py b/pyanaconda/textw/upgrade_bootloader_text.py deleted file mode 100644 index 78740cb5d..000000000 --- a/pyanaconda/textw/upgrade_bootloader_text.py +++ /dev/null @@ -1,81 +0,0 @@ -# -# upgrade_bootloader_text.py: text bootloader dialog for upgrades -# -# Copyright (C) 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): Jeremy Katz <katzj@redhat.com> -# - -import snack -from constants_text import INSTALL_OK, INSTALL_BACK, TEXT_BACK_CHECK -from constants_text import TEXT_OK_BUTTON, TEXT_BACK_BUTTON - -import gettext -_ = lambda x: gettext.ldgettext("anaconda", x) - -import logging -log = logging.getLogger("anaconda") - -class UpgradeBootloaderWindow: - def __call__(self, screen, anaconda): - self.screen = screen - - self.dispatch = anaconda.dispatch - self.anaconda = anaconda - - (newbl, nobl) = (False, False) - if self.dispatch.step_enabled("bootloader"): - newbl = True - elif self.dispatch.step_disabled("instbootloader"): - nobl = True - else: - newbl = True - - blradio = snack.RadioGroup() - self.newbl_radio = blradio.add(_("_Create new boot loader configuration"), - "newbl", newbl) - self.nobl_radio = blradio.add(_("_Skip boot loader updating"), - "nobl", nobl) - - buttons = snack.ButtonBar(screen, [TEXT_OK_BUTTON, TEXT_BACK_BUTTON]) - - grid = snack.GridFormHelp(screen, _("Upgrade Boot Loader Configuration"), - "bl-upgrade", 1, 5) - - grid.add(self.newbl_radio, 0, 1, (0,0,0,0)) - grid.add(self.nobl_radio, 0, 2, (0,0,0,0)) - grid.add(buttons, 0, 3, growx = 1) - - while True: - result = grid.run() - - button = buttons.buttonPressed(result) - - if button == TEXT_BACK_CHECK: - screen.popWindow() - return INSTALL_BACK - - if blradio.getSelection() == "nobl": - self.dispatch.skip_steps("bootloader") - self.dispatch.skip_steps("instbootloader") - self.anaconda.bootloader.skip_bootloader = True - else: - self.dispatch.request_steps_gently("bootloader") - self.anaconda.bootloader.skip_bootloader = False - - screen.popWindow() - return INSTALL_OK - diff --git a/pyanaconda/textw/upgrade_text.py b/pyanaconda/textw/upgrade_text.py deleted file mode 100644 index c65ec49a3..000000000 --- a/pyanaconda/textw/upgrade_text.py +++ /dev/null @@ -1,156 +0,0 @@ -# -# upgrade_text.py: text mode upgrade dialogs -# -# Copyright (C) 2001 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/>. -# - -from pyanaconda import isys -from pyanaconda import iutil -from pyanaconda import upgrade -from constants_text import * -from snack import * -from pyanaconda.flags import flags -from pyanaconda.constants import * -from pyanaconda.storage.formats import getFormat -from pyanaconda.storage.deviceaction import ActionMigrateFormat - -import gettext -_ = lambda x: gettext.ldgettext("anaconda", x) - -import logging -log = logging.getLogger("anaconda") - -seenExamineScreen = False - -class UpgradeMigrateFSWindow: - def __call__ (self, screen, anaconda): - migent = anaconda.storage.migratableDevices - - g = GridFormHelp(screen, _("Migrate File Systems"), "upmigfs", 1, 4) - - text = (_("This release of %(productName)s supports " - "an updated file system, which has several " - "benefits over the file system traditionally shipped " - "in %(productName)s. This installation program can migrate " - "formatted partitions without data loss.\n\n" - "Which of these partitions would you like to migrate?") % - {'productName': productName}) - - tb = TextboxReflowed(60, text) - g.add(tb, 0, 0, anchorLeft = 1, padding = (0, 0, 0, 1)) - - partlist = CheckboxTree(height=4, scroll=1) - for device in migent: - if not device.format.exists: - migrating = True - else: - migrating = False - - # FIXME: the fstype at least will be wrong here - partlist.append("%s - %s - %s" % (device.path, - device.format.type, - device.format.mountpoint), - device, migrating) - - g.add(partlist, 0, 1, padding = (0, 0, 0, 1)) - - buttons = ButtonBar(screen, [TEXT_OK_BUTTON, TEXT_BACK_BUTTON] ) - g.add(buttons, 0, 3, anchorLeft = 1, growx = 1) - - while True: - result = g.run() - - if (buttons.buttonPressed(result)): - result = buttons.buttonPressed(result) - - if result == TEXT_BACK_CHECK: - screen.popWindow() - return INSTALL_BACK - - # Cancel any previously scheduled migrate actions first. - for entry in partlist.getSelection(): - actions = anaconda.storage.devicetree.findActions(device=entry[1], - type="migrate") - if not actions: - continue - - for action in actions: - anaconda.storage.devicetree.cancelAction(action) - - # Then schedule an action for whatever rows were selected. - for entry in partlist.getSelection(): - newfs = getFormat(entry[1].format.migrationTarget) - if not newfs: - log.warning("failed to get new filesystem type (%s)" - % entry[1].format.migrationTarget) - continue - - action = ActionMigrateFormat(entry[1]) - anaconda.storage.devicetree.registerAction(action) - - screen.popWindow() - return INSTALL_OK - -class UpgradeExamineWindow: - def __call__ (self, screen, anaconda): - parts = anaconda.rootParts - - height = min(len(parts), 11) + 1 - if height == 12: - scroll = 1 - else: - scroll = 0 - partList = [] - partList.append(_("Reinstall System")) - - global seenExamineScreen - - default = 1 - - for (device, desc) in parts: - partList.append("%s (%s)" %(desc, device.path)) - - (button, choice) = ListboxChoiceWindow(screen, _("System to Upgrade"), - _("There seem to be one or more existing Linux installations " - "on your system.\n\nPlease choose one to upgrade, " - "or select 'Reinstall System' to freshly install " - "your system."), partList, - [ TEXT_OK_BUTTON, - TEXT_BACK_BUTTON ], - width = 55, scroll = scroll, - height = height, - default = default, - help = "upgraderoot") - - if button == TEXT_BACK_CHECK: - return INSTALL_BACK - else: - if choice == 0: - root = None - else: - root = parts[choice - 1] - - if root is not None: - upgrade.setSteps(anaconda) - anaconda.upgrade = True - - anaconda.upgradeRoot = [(root[0], root[1])] - anaconda.rootParts = parts - else: - anaconda.upgradeRoot = None - - seenExamineScreen = True - return INSTALL_OK diff --git a/pyanaconda/textw/userauth_text.py b/pyanaconda/textw/userauth_text.py deleted file mode 100644 index 8008a636c..000000000 --- a/pyanaconda/textw/userauth_text.py +++ /dev/null @@ -1,108 +0,0 @@ -# -# userauth_text.py: text mode authentication setup dialogs -# -# Copyright (C) 2000, 2001, 2002, 2008 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/>. -# - -from snack import * -from constants_text import * -import pwquality - -from pyanaconda.constants import * -import gettext -_ = lambda x: gettext.ldgettext("anaconda", x) - -class RootPasswordWindow: - def __call__ (self, screen, anaconda): - toplevel = GridFormHelp(screen, _("Root Password"), "rootpw", 1, 3) - - toplevel.add(TextboxReflowed(37, - _("Pick a root password. You must " - "type it twice to ensure you know " - "it and do not make a typing " - "mistake. ")), - 0, 0, (0, 0, 0, 1)) - - if anaconda.users.rootPassword["isCrypted"]: - anaconda.users.rootPassword["password"] = "" - - entry1 = Entry(24, password=1, - text=anaconda.users.rootPassword["password"]) - entry2 = Entry(24, password=1, - text=anaconda.users.rootPassword["password"]) - passgrid = Grid(2, 2) - passgrid.setField(Label(_("Password:")), 0, 0, (0, 0, 1, 0), - anchorLeft=1) - passgrid.setField(Label(_("Password (confirm):")), 0, 1, (0, 0, 1, 0), - anchorLeft=1) - passgrid.setField(entry1, 1, 0) - passgrid.setField(entry2, 1, 1) - toplevel.add(passgrid, 0, 1, (0, 0, 0, 1)) - - bb = ButtonBar(screen, (TEXT_OK_BUTTON, TEXT_BACK_BUTTON)) - toplevel.add(bb, 0, 2, growx = 1) - - while 1: - toplevel.setCurrent(entry1) - result = toplevel.run() - rc = bb.buttonPressed(result) - if rc == TEXT_BACK_CHECK: - screen.popWindow() - return INSTALL_BACK - if len(entry1.value()) < 6: - ButtonChoiceWindow(screen, _("Password Length"), - _("The root password must be at least 6 characters long."), - buttons = [ TEXT_OK_BUTTON ], width = 50) - elif entry1.value() != entry2.value(): - ButtonChoiceWindow(screen, _("Password Mismatch"), - _("The passwords you entered were different. Please " - "try again."), buttons = [ TEXT_OK_BUTTON ], width = 50) - elif self.hasBadChars(entry1.value()): - ButtonChoiceWindow(screen, _("Error with Password"), - _("Requested password contains non-ASCII characters, " - "which are not allowed."), - buttons = [ TEXT_OK_BUTTON ], width = 50) - else: - try: - settings = pwquality.PWQSettings() - settings.read_config() - settings.check(entry1.value(), None, "root") - except pwquality.PWQError as (e, msg): - ret = anaconda.intf.messageWindow(_("Weak Password"), - _("You have provided a weak password: %s\n\n" - "Would you like to continue with this password?" - % (msg, )), - type = "yesno", default="no") - if ret == 1: - break - else: - break - - entry1.set("") - entry2.set("") - - screen.popWindow() - anaconda.users.rootPassword["password"] = entry1.value() - anaconda.users.rootPassword["isCrypted"] = False - return INSTALL_OK - - def hasBadChars(self, pw): - allowed = string.digits + string.ascii_letters + \ - string.punctuation + " " - for letter in pw: - if letter not in allowed: - return True - return False diff --git a/pyanaconda/textw/zipl_text.py b/pyanaconda/textw/zipl_text.py deleted file mode 100644 index 01f7e77b1..000000000 --- a/pyanaconda/textw/zipl_text.py +++ /dev/null @@ -1,66 +0,0 @@ -# -# zipl_text.py: text mode z/IPL setup dialog -# -# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 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/>. -# - -from snack import * -from constants_text import * - -from pyanaconda.constants import * -from pyanaconda.storage.dasd import getDasdPorts - -import gettext -_ = lambda x: gettext.ldgettext("anaconda", x) - -class ZiplWindow: - def __call__(self, screen, anaconda): - self.bl = anaconda.bootloader - - t = TextboxReflowed(53, - _("The z/IPL Boot Loader will be installed " - "on your system after installation is complete. " - "You can now enter any additional kernel parameters " - "required by your machine or setup.")) - - kernelentry = Entry(48, scroll = 1, returnExit = 1) - kernelparms = str(self.bl.boot_args) - dasd_ports = "dasd=%s" % getDasdPorts() - if dasd_ports and "dasd" not in self.bl.boot_args: - kernelparms += " dasd=%s" % getDasdPorts() - kernelentry.set(kernelparms) - - buttons = ButtonBar(screen, [TEXT_OK_BUTTON, - TEXT_BACK_BUTTON ] ) - - grid = GridFormHelp(screen, _("z/IPL Configuration"), - "zipl-s390", 1, 5) - grid.add(t, 0, 0) - sg = Grid(2, 1) - sg.setField(Label(_("Kernel Parameters") + ": "), 0, 0, anchorLeft=1) - sg.setField(kernelentry, 1, 0, anchorLeft=1) - grid.add(sg, 0, 1, padding = (0, 1, 0, 1)) - grid.add(buttons, 0, 2, growx = 1) - - result = grid.runOnce () - button = buttons.buttonPressed(result) - - if button == TEXT_BACK_CHECK: - return INSTALL_BACK - - self.bl.boot_args.update(kernelentry.value().split()) - return INSTALL_OK diff --git a/tests/pyanaconda_test/rescue_test.py b/tests/pyanaconda_test/rescue_test.py index b369d3eda..b93f75ebe 100644 --- a/tests/pyanaconda_test/rescue_test.py +++ b/tests/pyanaconda_test/rescue_test.py @@ -112,34 +112,6 @@ class RescueTest(mock.TestCase): ret = ri.enableNetwork(anaconda) self.assertFalse(ret) - def rescueinterface_enablenetwork_2_test(self): - import pyanaconda.rescue - import pyanaconda.textw.netconfig_text - pyanaconda.rescue.INSTALL_BACK = -1 - pyanaconda.textw.netconfig_text.NetworkConfiguratorText = mock.Mock() - pyanaconda.textw.netconfig_text.NetworkConfiguratorText().run.return_value =\ - "foo" - anaconda = mock.Mock() - anaconda.network.netdevices = {'foo': 'as'} - - ri = pyanaconda.rescue.RescueInterface() - ret = ri.enableNetwork(anaconda) - self.assertTrue(ret) - - def rescueinterface_enablenetwork_3_test(self): - import pyanaconda.rescue - import pyanaconda.textw.netconfig_text - pyanaconda.rescue.INSTALL_BACK = "foo" - pyanaconda.textw.netconfig_text.NetworkConfiguratorText = mock.Mock() - pyanaconda.textw.netconfig_text.NetworkConfiguratorText().run.return_value =\ - pyanaconda.rescue.INSTALL_BACK - anaconda = mock.Mock() - anaconda.network.netdevices = {'bar': 'asdf'} - - ri = pyanaconda.rescue.RescueInterface() - ret = ri.enableNetwork(anaconda) - self.assertFalse(ret) - def rescueinterface_passphraseentrywindow_test(self): import pyanaconda.rescue RET = ('secret', False) diff --git a/tests/pylint/runpylint.sh b/tests/pylint/runpylint.sh index 13ad187dd..afd95fcdb 100755 --- a/tests/pylint/runpylint.sh +++ b/tests/pylint/runpylint.sh @@ -85,8 +85,7 @@ for i in $(find pyanaconda -type f -name '*py'); do sys.path.insert(1, "pyanaconda/isys/.libs"); \ sys.path.insert(2, "pyanaconda/isys"); \ sys.path.insert(3, "pyanaconda"); \ - sys.path.insert(4, "pyanaconda/.libs"); \ - sys.path.insert(6, "pyanaconda/textw")' \ + sys.path.insert(4, "pyanaconda/.libs")' \ -i y -r n --disable=C,R --rcfile=/dev/null \ $DISABLED_WARN_OPTIONS \ $DISABLED_ERR_OPTIONS \ |