[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH 2/3] Move init questions to InstallInterfaceBase



The code is identical for text mode and gui mode (except for one
copy paste error fixed by the previous commit GRRRR).
---
 gui.py                  |  110 -----------------------------------------------
 installinterfacebase.py |  110 +++++++++++++++++++++++++++++++++++++++++++++++
 text.py                 |  110 -----------------------------------------------
 3 files changed, 110 insertions(+), 220 deletions(-)

diff --git a/gui.py b/gui.py
index bf7e37f..d3423d1 100755
--- a/gui.py
+++ b/gui.py
@@ -940,8 +940,6 @@ class InstallInterface(InstallInterfaceBase):
         root = gtk.gdk.get_default_root_window()
         cursor = gtk.gdk.Cursor(gtk.gdk.LEFT_PTR)
         root.set_cursor(cursor)
-        self._initLabelAnswers = {}
-        self._inconsistentLVMAnswers = {}
 
     def __del__ (self):
         pass
@@ -1173,114 +1171,6 @@ class InstallInterface(InstallInterfaceBase):
         d.destroy()
         return rc
 
-    def resetInitializeDiskQuestion(self):
-        self._initLabelAnswers = {}
-
-    def questionInitializeDisk(self, path, description, size, details=""):
-
-        retVal = False # The less destructive default
-
-        if not path:
-            return retVal
-
-        # we are caching answers so that we don't
-        # ask in each storage.reset() again
-        if path in self._initLabelAnswers:
-            log.info("UI not asking about disk initialization, "
-                     "using cached answer: %s" % self._initLabelAnswers[path])
-            return self._initLabelAnswers[path]
-        elif "all" in self._initLabelAnswers:
-            log.info("UI not asking about disk initialization, "
-                     "using cached answer: %s" % self._initLabelAnswers["all"])
-            return self._initLabelAnswers["all"]
-
-        rc = self.messageWindow(_("Warning"),
-                _("Error processing drive:\n\n"
-                  "%(path)s\n%(size)-0.fMB\n%(description)s\n\n"
-                  "This device may need to be reinitialized.\n\n"
-                  "REINITIALIZING WILL CAUSE ALL DATA TO BE LOST!\n\n"
-                  "This action may also be applied to all other disks "
-                  "needing reinitialization.%(details)s")
-                % {'path': path, 'size': size,
-                   'description': description, 'details': details},
-                type="custom",
-                custom_buttons = [ _("_Ignore"),
-                                   _("Ignore _all"),
-                                   _("_Re-initialize"),
-                                   _("Re-ini_tialize all") ],
-                custom_icon="question")
-        if rc == 0:
-            retVal = False
-        elif rc == 1:
-            path = "all"
-            retVal = False
-        elif rc == 2:
-            retVal = True
-        elif rc == 3:
-            path = "all"
-            retVal = True
-
-        self._initLabelAnswers[path] = retVal
-        return retVal
-
-    def resetReinitInconsistentLVMQuestion(self):
-        self._inconsistentLVMAnswers = {}
-
-    def questionReinitInconsistentLVM(self, pv_names=None, lv_name=None, vg_name=None):
-
-        retVal = False # The less destructive default
-        allSet = frozenset(["all"])
-
-        if not pv_names or (lv_name is None and vg_name is None):
-            return retVal
-
-        # We are caching answers so that we don't ask for ignoring
-        # in each storage.reset() again (note that reinitialization is
-        # done right after confirmation in dialog, not as a planned
-        # action).
-        key = frozenset(pv_names)
-        if key in self._inconsistentLVMAnswers:
-            log.info("UI not asking about disk initialization, "
-                     "using cached answer: %s" % self._inconsistentLVMAnswers[key])
-            return self._inconsistentLVMAnswers[key]
-        elif allSet in self._inconsistentLVMAnswers:
-            log.info("UI not asking about disk initialization, "
-                     "using cached answer: %s" % self._inconsistentLVMAnswers[allSet])
-            return self._inconsistentLVMAnswers[allSet]
-
-        if vg_name is not None:
-            message = "Volume Group %s" % vg_name
-        elif lv_name is not None:
-            message = "Logical Volume %s" % lv_name
-
-        na = {'msg': message, 'pvs': ", ".join(pv_names)}
-        rc = self.messageWindow(_("Warning"),
-                  _("Error processing LVM.\n"
-                    "There is inconsistent LVM data on %(msg)s.  You can "
-                    "reinitialize all related PVs (%(pvs)s) which will erase "
-                    "the LVM metadata, or ignore which will preserve the "
-                    "contents.  This action may also be applied to all other "
-                    "PVs with inconsistent metadata.") % na,
-                type="custom",
-                custom_buttons = [ _("_Ignore"),
-                                   _("Ignore _all"),
-                                   _("_Re-initialize"),
-                                   _("Re-ini_tialize all") ],
-                custom_icon="question")
-        if rc == 0:
-            retVal = False
-        elif rc == 1:
-            key = allSet
-            retVal = False
-        elif rc == 2:
-            retVal = True
-        elif rc == 3:
-            key = allSet
-            retVal = True
-
-        self._inconsistentLVMAnswers[key] = retVal
-        return retVal
-
     def beep(self):
         gtk.gdk.beep()
 
diff --git a/installinterfacebase.py b/installinterfacebase.py
index 1adfd2a..dcf6700 100644
--- a/installinterfacebase.py
+++ b/installinterfacebase.py
@@ -25,6 +25,8 @@ P_ = lambda x, y, z: gettext.ldngettext("anaconda", x, y, z)
 class InstallInterfaceBase(object):
     def __init__(self):
         self._warnedUnusedRaidMembers = []
+        self._initLabelAnswers = {}
+        self._inconsistentLVMAnswers = {}
 
     def messageWindow(self, title, text, type="ok", default = None,
              custom_buttons=None,  custom_icon=None):
@@ -53,6 +55,114 @@ class InstallInterfaceBase(object):
                     ", ".join(unusedRaidMembers)),
                 custom_icon="warning")
 
+    def resetInitializeDiskQuestion(self):
+        self._initLabelAnswers = {}
+
+    def questionInitializeDisk(self, path, description, size, details=""):
+
+        retVal = False # The less destructive default
+
+        if not path:
+            return retVal
+
+        # we are caching answers so that we don't
+        # ask in each storage.reset() again
+        if path in self._initLabelAnswers:
+            log.info("UI not asking about disk initialization, "
+                     "using cached answer: %s" % self._initLabelAnswers[path])
+            return self._initLabelAnswers[path]
+        elif "all" in self._initLabelAnswers:
+            log.info("UI not asking about disk initialization, "
+                     "using cached answer: %s" % self._initLabelAnswers["all"])
+            return self._initLabelAnswers["all"]
+
+        rc = self.messageWindow(_("Warning"),
+                _("Error processing drive:\n\n"
+                  "%(path)s\n%(size)-0.fMB\n%(description)s\n\n"
+                  "This device may need to be reinitialized.\n\n"
+                  "REINITIALIZING WILL CAUSE ALL DATA TO BE LOST!\n\n"
+                  "This action may also be applied to all other disks "
+                  "needing reinitialization.%(details)s")
+                % {'path': path, 'size': size,
+                   'description': description, 'details': details},
+                type="custom",
+                custom_buttons = [ _("_Ignore"),
+                                   _("Ignore _all"),
+                                   _("_Re-initialize"),
+                                   _("Re-ini_tialize all") ],
+                custom_icon="question")
+        if rc == 0:
+            retVal = False
+        elif rc == 1:
+            path = "all"
+            retVal = False
+        elif rc == 2:
+            retVal = True
+        elif rc == 3:
+            path = "all"
+            retVal = True
+
+        self._initLabelAnswers[path] = retVal
+        return retVal
+
+    def resetReinitInconsistentLVMQuestion(self):
+        self._inconsistentLVMAnswers = {}
+
+    def questionReinitInconsistentLVM(self, pv_names=None, lv_name=None, vg_name=None):
+
+        retVal = False # The less destructive default
+        allSet = frozenset(["all"])
+
+        if not pv_names or (lv_name is None and vg_name is None):
+            return retVal
+
+        # We are caching answers so that we don't ask for ignoring
+        # in each storage.reset() again (note that reinitialization is
+        # done right after confirmation in dialog, not as a planned
+        # action).
+        key = frozenset(pv_names)
+        if key in self._inconsistentLVMAnswers:
+            log.info("UI not asking about disk initialization, "
+                     "using cached answer: %s" % self._inconsistentLVMAnswers[key])
+            return self._inconsistentLVMAnswers[key]
+        elif allSet in self._inconsistentLVMAnswers:
+            log.info("UI not asking about disk initialization, "
+                     "using cached answer: %s" % self._inconsistentLVMAnswers[allSet])
+            return self._inconsistentLVMAnswers[allSet]
+
+        if vg_name is not None:
+            message = "Volume Group %s" % vg_name
+        elif lv_name is not None:
+            message = "Logical Volume %s" % lv_name
+
+        na = {'msg': message, 'pvs': ", ".join(pv_names)}
+        rc = self.messageWindow(_("Warning"),
+                  _("Error processing LVM.\n"
+                    "There is inconsistent LVM data on %(msg)s.  You can "
+                    "reinitialize all related PVs (%(pvs)s) which will erase "
+                    "the LVM metadata, or ignore which will preserve the "
+                    "contents.  This action may also be applied to all other "
+                    "PVs with inconsistent metadata.") % na,
+                type="custom",
+                custom_buttons = [ _("_Ignore"),
+                                   _("Ignore _all"),
+                                   _("_Re-initialize"),
+                                   _("Re-ini_tialize all") ],
+                custom_icon="question")
+        if rc == 0:
+            retVal = False
+        elif rc == 1:
+            key = allSet
+            retVal = False
+        elif rc == 2:
+            retVal = True
+        elif rc == 3:
+            key = allSet
+            retVal = True
+
+        self._inconsistentLVMAnswers[key] = retVal
+        return retVal
+
     def questionInitializeDASD(self, c, devs):
         """Ask if unformatted DASD's should be formatted"""
         title = P_("Unformatted DASD Device Found",
diff --git a/text.py b/text.py
index 09d7a0b..ca2961f 100644
--- a/text.py
+++ b/text.py
@@ -443,8 +443,6 @@ class InstallInterface(InstallInterfaceBase):
 	signal.signal(signal.SIGTSTP, signal.SIG_IGN)
 	self.screen = SnackScreen()
         self.instProgress = None
-        self._initLabelAnswers = {}
-        self._inconsistentLVMAnswers = {}
 
     def __del__(self):
 	if self.screen:
@@ -461,114 +459,6 @@ class InstallInterface(InstallInterfaceBase):
             return False
         return True
 
-    def resetInitializeDiskQuestion(self):
-        self._initLabelAnswers = {}
-
-    def questionInitializeDisk(self, path, description, size, details=""):
-
-        retVal = False # The less destructive default
-
-        if not path:
-            return retVal
-
-        # we are caching answers so that we don't
-        # ask in each storage.reset() again
-        if path in self._initLabelAnswers:
-            log.info("UI not asking about disk initialization, "
-                     "using cached answer: %s" % self._initLabelAnswers[path])
-            return self._initLabelAnswers[path]
-        elif "all" in self._initLabelAnswers:
-            log.info("UI not asking about disk initialization, "
-                     "using cached answer: %s" % self._initLabelAnswers["all"])
-            return self._initLabelAnswers["all"]
-
-        rc = self.messageWindow(_("Warning"),
-                _("Error processing drive:\n\n"
-                  "%(path)s\n%(size)-0.fMB\n%(description)s\n\n"
-                  "This device may need to be reinitialized.\n\n"
-                  "REINITIALIZING WILL CAUSE ALL DATA TO BE LOST!\n\n"
-                  "This action may also be applied to all other disks "
-                  "needing reinitialization.%(details)s")
-                % {'path': path, 'size': size,
-                   'description': description, 'details': details},
-                type="custom",
-                custom_buttons = [ _("_Ignore"),
-                                   _("Ignore _all"),
-                                   _("_Re-initialize"),
-                                   _("Re-ini_tialize all") ],
-                custom_icon="question")
-        if rc == 0:
-            retVal = False
-        elif rc == 1:
-            path = "all"
-            retVal = False
-        elif rc == 2:
-            retVal = True
-        elif rc == 3:
-            path = "all"
-            retVal = True
-
-        self._initLabelAnswers[path] = retVal
-        return retVal
-
-    def resetReinitInconsistentLVMQuestion(self):
-        self._inconsistentLVMAnswers = {}
-
-    def questionReinitInconsistentLVM(self, pv_names=None, lv_name=None, vg_name=None):
-
-        retVal = False # The less destructive default
-        allSet = frozenset(["all"])
-
-        if not pv_names or (lv_name is None and vg_name is None):
-            return retVal
-
-        # We are caching answers so that we don't ask for ignoring
-        # in each storage.reset() again (note that reinitialization is
-        # done right after confirmation in dialog, not as a planned
-        # action).
-        key = frozenset(pv_names)
-        if key in self._inconsistentLVMAnswers:
-            log.info("UI not asking about disk initialization, "
-                     "using cached answer: %s" % self._inconsistentLVMAnswers[key])
-            return self._inconsistentLVMAnswers[key]
-        elif allSet in self._inconsistentLVMAnswers:
-            log.info("UI not asking about disk initialization, "
-                     "using cached answer: %s" % self._inconsistentLVMAnswers[allSet])
-            return self._inconsistentLVMAnswers[allSet]
-
-        if vg_name is not None:
-            message = "Volume Group %s" % vg_name
-        elif lv_name is not None:
-            message = "Logical Volume %s" % lv_name
-
-        na = {'msg': message, 'pvs': ", ".join(pv_names)}
-        rc = self.messageWindow(_("Warning"),
-                  _("Error processing LVM.\n"
-                    "There is inconsistent LVM data on %(msg)s.  You can "
-                    "reinitialize all related PVs (%(pvs)s) which will erase "
-                    "the LVM metadata, or ignore which will preserve the "
-                    "contents.  This action may also be applied to all other "
-                    "PVs with inconsistent metadata.") % na,
-                type="custom",
-                custom_buttons = [ _("_Ignore"),
-                                   _("Ignore _all"),
-                                   _("_Re-initialize"),
-                                   _("Re-ini_tialize all") ],
-                custom_icon="question")
-        if rc == 0:
-            retVal = False
-        elif rc == 1:
-            key = allSet
-            retVal = False
-        elif rc == 2:
-            retVal = True
-        elif rc == 3:
-            key = allSet
-            retVal = True
-
-        self._inconsistentLVMAnswers[key] = retVal
-        return retVal
-
     def run(self, anaconda):
         self.anaconda = anaconda
         instLang = anaconda.instLanguage
-- 
1.7.0.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]