[PATCH 5/5] Remove the old cmdline and script interfaces.
Chris Lumens
clumens at redhat.com
Tue Jan 15 18:44:33 UTC 2013
These have all been merged with the new text interface.
---
po/POTFILES.in | 1 -
pyanaconda/cmdline.py | 193 ----------------------------
pyanaconda/script.py | 55 --------
tests/pyanaconda_test/cmdline_test.py | 230 ----------------------------------
4 files changed, 479 deletions(-)
delete mode 100644 pyanaconda/cmdline.py
delete mode 100644 pyanaconda/script.py
delete mode 100644 tests/pyanaconda_test/cmdline_test.py
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 7ff9548..1d7e264 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -4,7 +4,6 @@
# Main anaconda source files
anaconda
pyanaconda/bootloader.py
-pyanaconda/cmdline.py
pyanaconda/constants.py
pyanaconda/image.py
pyanaconda/install.py
diff --git a/pyanaconda/cmdline.py b/pyanaconda/cmdline.py
deleted file mode 100644
index 310ec38..0000000
--- a/pyanaconda/cmdline.py
+++ /dev/null
@@ -1,193 +0,0 @@
-#
-# cmdline.py - non-interactive, very very simple frontend to anaconda
-#
-# Copyright (C) 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 at redhat.com
-#
-
-import time
-import signal
-import parted
-from constants import *
-from flags import flags
-from iutil import strip_markup
-from installinterfacebase import InstallInterfaceBase
-
-import gettext
-_ = lambda x: gettext.ldgettext("anaconda", x)
-
-import logging
-log = logging.getLogger("anaconda")
-
-
-def setupProgressDisplay(anaconda):
- if anaconda.dir == DISPATCH_BACK:
- anaconda.intf.setInstallProgressClass(None)
- return DISPATCH_BACK
- else:
- anaconda.intf.setInstallProgressClass(progressDisplay())
-
- return DISPATCH_FORWARD
-
-stepToClasses = { "install" : setupProgressDisplay }
-
-class WaitWindow:
- def pop(self):
- pass
- def refresh(self):
- pass
- def __init__(self, title, text):
- print(text)
-
-class ProgressWindow:
- def pop(self):
- print("")
-
- def pulse(self):
- pass
-
- def set(self, amount):
- if amount == self.total:
- print(_("Completed"))
-
- def refresh(self):
- pass
-
- def __init__(self, title, text, total, updpct = 0.05, pulse = False):
- self.total = total
- print(text)
- print(_("In progress"))
-
-class InstallInterface(InstallInterfaceBase):
- def __init__(self):
- InstallInterfaceBase.__init__(self)
-# signal.signal(signal.SIGINT, signal.SIG_IGN)
- signal.signal(signal.SIGTSTP, signal.SIG_DFL)
- self.instProgress = None
-
- def __del__(self):
- pass
-
- def reinitializeWindow(self, title, path, size, description):
- errtxt = _("(%s)\nCommand line mode requires all choices to be specified in a "
- "kickstart configuration file." % (title,))
- raise RuntimeError(errtxt)
-
- def shutdown(self):
- pass
-
- def suspend(self):
- pass
-
- def resume(self):
- pass
-
- def progressWindow(self, title, text, total, updpct = 0.05, pulse = False):
- return ProgressWindow(title, text, total, updpct, pulse)
-
- def kickstartErrorWindow(self, text):
- errtxt = _("The following error was found while parsing the "
- "kickstart configuration file:\n\n%s") % (text,)
- raise RuntimeError(errtxt)
-
- def messageWindow(self, title, text, type="ok", default = None,
- custom_icon = None, custom_buttons = []):
- if type == "ok":
- print(text)
- else:
- errtxt = _("(%s)\n%s" % (title, text))
- raise RuntimeError(errtxt)
-
- def detailedMessageWindow(self, title, text, longText=None, type="ok",
- default=None, custom_buttons=None,
- custom_icon=None, expanded=False):
- if longText:
- text += "\n\n%s" % longText
-
- self.messageWindow(title, text, type=type, default=default,
- custom_buttons=custom_buttons, custom_icon=custom_icon)
-
- def passphraseEntryWindow(self, device):
- errtxt = _("Can't have a question in command line mode!")
- errtxt += "\n(passphraseEntryWindow: '%s')" % (device,)
- raise RuntimeError(errtxt)
-
- def enableNetwork(self):
- errtxt = "(enableNetwork)\n"
- errtxt += _("Can't have a question in command line mode!")
- raise RuntimeError(errtxt)
-
- def questionInitializeDASD(self, c, devs):
- errtxt = "(questionInitializeDASD)\n"
- errtxt += _("Can't have a question in command line mode!")
- raise RuntimeError(errtxt)
-
- def mainExceptionWindow(self, shortText, longTextFile):
- print(shortText)
-
- def waitWindow(self, title, text):
- return WaitWindow(title, text)
-
- def beep(self):
- pass
-
- def run(self, anaconda):
- self.anaconda = anaconda
-
- def display_step(self, step):
- if stepToClasses.has_key(step):
- stepToClasses[step](self.anaconda)
- else:
- errtxt = _("In interactive step can't continue. (%s)" %(step,))
- raise RuntimeError(errtxt)
-
- def setInstallProgressClass(self, c):
- self.instProgress = c
-
-class progressDisplay:
- def __init__(self):
- self.pct = 0
- self.display = ""
-
- def __del__(self):
- pass
-
- def processEvents(self):
- pass
- def setShowPercentage(self, val):
- pass
- def get_fraction(self):
- return self.pct
- def set_fraction(self, pct):
- self.pct = pct
- def set_text(self, txt):
- print(txt)
- def set_label(self, txt):
- stripped = strip_markup(txt)
- if stripped != self.display:
- self.display = stripped
- print(self.display)
-
-def setupProgressDisplay(anaconda):
- if anaconda.dir == DISPATCH_BACK:
- anaconda.intf.setInstallProgressClass(None)
- return DISPATCH_BACK
- else:
- anaconda.intf.setInstallProgressClass(progressDisplay())
-
- return DISPATCH_FORWARD
diff --git a/pyanaconda/script.py b/pyanaconda/script.py
deleted file mode 100644
index c4e0074..0000000
--- a/pyanaconda/script.py
+++ /dev/null
@@ -1,55 +0,0 @@
-#
-# script.py - non-interactive, script based anaconda interface
-#
-# Copyright (C) 2011
-# 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): Brian C. Lane <bcl at redhat.com>
-#
-
-from installinterfacebase import InstallInterfaceBase
-import cmdline
-from cmdline import setupProgressDisplay
-
-import gettext
-_ = lambda x: gettext.ldgettext("anaconda", x)
-
-import logging
-log = logging.getLogger("anaconda")
-
-stepToClasses = { "install" : "setupProgressDisplay",
- "complete": "Finished" }
-
-class InstallInterface(cmdline.InstallInterface):
- def enableNetwork(self):
- # Assume we want networking
- return True
-
- def display_step(self, step):
- if stepToClasses.has_key(step):
- s = "nextWin = %s" % (stepToClasses[step],)
- exec s
- nextWin(self.anaconda)
- else:
- errtxt = _("In interactive step can't continue. (%s)" % (step,))
- print(errtxt)
- raise RuntimeError(errtxt)
-
-def Finished(anaconda):
- """ Install is finished. Lets just exit.
- """
- return 0
-
diff --git a/tests/pyanaconda_test/cmdline_test.py b/tests/pyanaconda_test/cmdline_test.py
deleted file mode 100644
index 17cb16a..0000000
--- a/tests/pyanaconda_test/cmdline_test.py
+++ /dev/null
@@ -1,230 +0,0 @@
-#!/usr/bin/python
-
-import mock
-import sys
-
-class CmdLineTest(mock.TestCase):
-
- def setUp(self):
- self.setupModules(["_isys", "block", 'parted', 'storage',
- 'pyanaconda.storage.formats', 'logging',
- 'ConfigParser'])
-
- self.fs = mock.DiskIO()
- self.stdout = sys.stdout
- self.TMP_STDOUT = '/tmp/stdout'
- import pyanaconda.cmdline
-
- def tearDown(self):
- sys.stdout = self.stdout
- self.tearDownModules()
-
- def waitwindow_test(self):
- import pyanaconda.cmdline
- TITLE = 'TITLE'
- TEXT = 'text'
- sys.stdout = self.fs.open(self.TMP_STDOUT, 'w')
- win = pyanaconda.cmdline.WaitWindow(TITLE, TEXT)
- sys.stdout.close()
- self.assertEqual(self.fs[self.TMP_STDOUT], '%s\n' % TEXT)
-
- def progresswindow_1_test(self):
- import pyanaconda.cmdline
- TITLE = 'TITLE'
- TEXT = 'text'
- TOTAL = 100
- sys.stdout = self.fs.open(self.TMP_STDOUT, 'w')
- win = pyanaconda.cmdline.ProgressWindow(TITLE, TEXT, TOTAL)
- sys.stdout.close()
- self.assertTrue(TEXT in self.fs[self.TMP_STDOUT])
-
- def progresswindow_2_test(self):
- import pyanaconda.cmdline
- TITLE = 'TITLE'
- TEXT = 'text'
- TOTAL = 100
- sys.stdout = self.fs.open(self.TMP_STDOUT, 'w')
- win = pyanaconda.cmdline.ProgressWindow(TITLE, TEXT, TOTAL)
- win.set(50)
- sys.stdout.close()
- self.assertTrue(TEXT in self.fs[self.TMP_STDOUT])
-
- def progresswindow_3_test(self):
- import pyanaconda.cmdline
- TITLE = 'TITLE'
- TEXT = 'text'
- TOTAL = 100
-
- sys.stdout = self.fs.open(self.TMP_STDOUT, 'w')
- win = pyanaconda.cmdline.ProgressWindow(TITLE, TEXT, TOTAL)
- win.set(100)
- sys.stdout.close()
- self.assertTrue(TEXT in self.fs[self.TMP_STDOUT])
-
- def installinterface_progresswindow_test(self):
- import pyanaconda.cmdline
- pyanaconda.cmdline.ProgressWindow = mock.Mock(return_value='foo')
-
- intf = pyanaconda.cmdline.InstallInterface()
- ret = intf.progressWindow(0, 0, 0)
- self.assertEqual(ret, 'foo')
-
- def installinterface_kickstarterrorwindow_test(self):
- import pyanaconda.cmdline
- pyanaconda.cmdline.time.sleep = mock.Mock(side_effect=Exception)
- TEXT = 'foobar text'
-
- sys.stdout = self.fs.open(self.TMP_STDOUT, 'w')
- intf = pyanaconda.cmdline.InstallInterface()
- try: intf.kickstartErrorWindow(TEXT)
- except: pass
- sys.stdout.close()
- self.assertTrue(TEXT in self.fs[self.TMP_STDOUT])
-
- def installinterface_messagewindow_1_test(self):
- import pyanaconda.cmdline
- TITLE = 'TITLE'
- TEXT = 'foobar text'
-
- sys.stdout = self.fs.open(self.TMP_STDOUT, 'w')
- intf = pyanaconda.cmdline.InstallInterface()
- intf.messageWindow(TITLE, TEXT)
- sys.stdout.close()
- self.assertEqual(self.fs[self.TMP_STDOUT], '%s\n' % TEXT)
-
- def installinterface_messagewindow_2_test(self):
- import pyanaconda.cmdline
- pyanaconda.cmdline.time.sleep = mock.Mock(side_effect=Exception)
- TITLE = 'TITLE'
- TEXT = 'foobar text'
- TYPE = 'abc'
- CUSTOM_BUTTONS = ['BUT1', 'BUT2']
-
- sys.stdout = self.fs.open(self.TMP_STDOUT, 'w')
- intf = pyanaconda.cmdline.InstallInterface()
- try: intf.messageWindow(TITLE, TEXT, TYPE, custom_buttons=CUSTOM_BUTTONS)
- except: pass
- sys.stdout.close()
- self.assertTrue(TITLE in self.fs[self.TMP_STDOUT])
- self.assertTrue(TEXT in self.fs[self.TMP_STDOUT])
- for but in CUSTOM_BUTTONS:
- self.assertTrue(but in self.fs[self.TMP_STDOUT])
-
- def installinterface_detailedmessagewindow_test(self):
- import pyanaconda.cmdline
- pyanaconda.cmdline.InstallInterface.messageWindow = mock.Mock()
- TITLE = 'TITLE'
- TEXT = 'foobar text'
- LONGTEXT = 'very very very (wait for it) long text.'
-
- intf = pyanaconda.cmdline.InstallInterface()
- intf.detailedMessageWindow(TITLE, TEXT, LONGTEXT)
- self.assertTrue(
- TEXT in pyanaconda.cmdline.InstallInterface.messageWindow.call_args[0][1])
- self.assertTrue(
- LONGTEXT in pyanaconda.cmdline.InstallInterface.messageWindow.call_args[0][1])
-
- def installinterface_passhraseentrywindow_test(self):
- import pyanaconda.cmdline
- pyanaconda.cmdline.time.sleep = mock.Mock(side_effect=Exception)
- DEVICE = 'foodevice'
-
- sys.stdout = self.fs.open(self.TMP_STDOUT, 'w')
- intf = pyanaconda.cmdline.InstallInterface()
- self.assertRaises(Exception, intf.passphraseEntryWindow, DEVICE)
- sys.stdout.close()
- self.assertTrue(DEVICE in self.fs[self.TMP_STDOUT])
-
- def installinterface_enablenetwork_test(self):
- import pyanaconda.cmdline
- pyanaconda.cmdline.time.sleep = mock.Mock(side_effect=Exception)
-
- intf = pyanaconda.cmdline.InstallInterface()
- self.assertRaises(Exception, intf.enableNetwork)
-
- def installinterface_questioninitialize_dasd_test(self):
- import pyanaconda.cmdline
- pyanaconda.cmdline.time.sleep = mock.Mock(side_effect=Exception)
-
- intf = pyanaconda.cmdline.InstallInterface()
- self.assertRaises(Exception, intf.questionInitializeDASD, 'foo', 'bar')
-
- def installinterface_mainexceptionwindow_test(self):
- import pyanaconda.cmdline
- SHORT_TEXT = "short text"
- LONG_TEXT = "long text"
-
- sys.stdout = self.fs.open(self.TMP_STDOUT, 'w')
- intf = pyanaconda.cmdline.InstallInterface()
- intf.mainExceptionWindow(SHORT_TEXT, LONG_TEXT)
- sys.stdout.close()
- self.assertTrue(SHORT_TEXT in self.fs[self.TMP_STDOUT])
-
- def installinterface_waitwindow_test(self):
- import pyanaconda.cmdline
- pyanaconda.cmdline.WaitWindow = mock.Mock()
- TITLE = 'TITLE'
- TEXT = 'text'
-
- intf = pyanaconda.cmdline.InstallInterface()
- intf.waitWindow(TITLE, TEXT)
- self.assertTrue(pyanaconda.cmdline.WaitWindow.called)
- self.assertEqual(pyanaconda.cmdline.WaitWindow.call_args,
- (('TITLE', 'text'), {}))
-
- #def installinterface_run_test(self):
- # pass
-
- def installinterface_setinstallprogressclass_test(self):
- import pyanaconda.cmdline
- CLASS = 65
- intf = pyanaconda.cmdline.InstallInterface()
- intf.setInstallProgressClass(CLASS)
- self.assertEqual(intf.instProgress, CLASS)
-
- def progressdisplay_get_fraction_test(self):
- import pyanaconda.cmdline
- PCT = 44
- pd = pyanaconda.cmdline.progressDisplay()
- pd.pct = PCT
- ret = pd.get_fraction()
- self.assertEqual(ret, PCT)
-
- def progressdisplay_set_fraction_test(self):
- import pyanaconda.cmdline
- PCT = 52
- pd = pyanaconda.cmdline.progressDisplay()
- pd.set_fraction(52)
- self.assertEqual(pd.pct, PCT)
-
- def progressdisplay_set_label_test(self):
- import pyanaconda.cmdline
- pyanaconda.cmdline.strip_markup = mock.Mock(return_value="foo")
- TEXT = 'text'
-
- pd = pyanaconda.cmdline.progressDisplay()
- pd.set_label(TEXT)
- self.assertEqual(pd.display, "foo")
-
- def setupprogressdisplay_1_test(self):
- import pyanaconda.cmdline
- pyanaconda.cmdline.DISPATCH_BACK = -1
- pyanaconda.cmdline.DISPATCH_FORWARD = 1
- anaconda = mock.Mock()
- anaconda.dir = pyanaconda.cmdline.DISPATCH_BACK
-
- ret = pyanaconda.cmdline.setupProgressDisplay(anaconda)
- self.assertEqual(ret, pyanaconda.cmdline.DISPATCH_BACK)
- self.assertTrue(anaconda.intf.setInstallProgressClass.called)
-
- def setupprogressdisplay_2_test(self):
- import pyanaconda.cmdline
- pyanaconda.cmdline.DISPATCH_BACK = -1
- pyanaconda.cmdline.DISPATCH_FORWARD = 1
- anaconda = mock.Mock()
- anaconda.dir = pyanaconda.cmdline.DISPATCH_FORWARD
-
- ret = pyanaconda.cmdline.setupProgressDisplay(anaconda)
- self.assertEqual(ret, pyanaconda.cmdline.DISPATCH_FORWARD)
- self.assertTrue(anaconda.intf.setInstallProgressClass.called)
-
--
1.7.11.2
More information about the anaconda-patches
mailing list