Package pyanaconda :: Module installinterfacebase
[hide private]
[frames] | no frames]

Source Code for Module pyanaconda.installinterfacebase

  1  # 
  2  # installinterfacebase.py: a baseclass for anaconda interface classes 
  3  # 
  4  # Copyright (C) 2010  Red Hat, Inc.  All rights reserved. 
  5  # 
  6  # This program is free software; you can redistribute it and/or modify 
  7  # it under the terms of the GNU General Public License as published by 
  8  # the Free Software Foundation; either version 2 of the License, or 
  9  # (at your option) any later version. 
 10  # 
 11  # This program is distributed in the hope that it will be useful, 
 12  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
 13  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 14  # GNU General Public License for more details. 
 15  # 
 16  # You should have received a copy of the GNU General Public License 
 17  # along with this program.  If not, see <http://www.gnu.org/licenses/>. 
 18  # 
 19  # Author(s): Hans de Goede <hdegoede@redhat.com> 
 20   
 21  import gettext 
 22  import sys 
 23   
 24  _ = lambda x: gettext.ldgettext("anaconda", x) 
 25  P_ = lambda x, y, z: gettext.ldngettext("anaconda", x, y, z) 
 26   
 27  import logging 
 28  log = logging.getLogger("anaconda") 
 29   
30 -class InstallInterfaceBase(object):
31 - def __init__(self):
32 self._warnedUnusedRaidMembers = [] 33 self._initLabelAnswers = {} 34 self._inconsistentLVMAnswers = {}
35
36 - def reinitializeWindow(self, title, path, size, description):
37 raise NotImplementedError
38
39 - def messageWindow(self, title, text, type="ok", default = None, 40 custom_buttons=None, custom_icon=None):
41 raise NotImplementedError
42
43 - def detailedMessageWindow(self, title, text, longText=None, type="ok", 44 default=None, custom_icon=None, 45 custom_buttons=[], expanded=False):
46 raise NotImplementedError
47
48 - def methodstrRepoWindow(self, methodstr, exception):
49 """ Called when the repo specified by methodstr could not be found. 50 51 Depending on the interface implementation terminates the program or 52 gives user a chance to specify a new repo path it then returns. The 53 default implementation is to terminate. 54 """ 55 self.messageWindow( 56 _("Error Setting Up Repository"), 57 _("The following error occurred while setting up the " 58 "installation repository:\n\n%(e)s\n\n" 59 "Installation can not continue.") 60 % {'e': exception}, 61 type = "custom", 62 custom_icon="info", 63 custom_buttons=[_("Exit installer")]) 64 sys.exit(0)
65
66 - def unusedRaidMembersWarning(self, unusedRaidMembers):
67 """Warn about unused BIOS RAID members""" 68 unusedRaidMembers = \ 69 filter(lambda m: m not in self._warnedUnusedRaidMembers, 70 unusedRaidMembers) 71 if unusedRaidMembers: 72 self._warnedUnusedRaidMembers.extend(unusedRaidMembers) 73 unusedRaidMembers.sort() 74 self.messageWindow(_("Warning"), 75 P_("Disk %(unusedRaidMems)s contains BIOS RAID metadata, but is not part of " 76 "any recognized BIOS RAID sets. Ignoring disk %(unusedRaidMems)s.", 77 "Disks %(unusedRaidMems)s contain BIOS RAID metadata, but are not part of " 78 "any recognized BIOS RAID sets. Ignoring disks %(unusedRaidMems)s.", 79 len(unusedRaidMembers)) % {"unusedRaidMems": ", ".join(unusedRaidMembers)}, 80 custom_icon="warning")
81
83 self._initLabelAnswers = {}
84
85 - def questionInitializeDisk(self, path, description, size):
86 87 retVal = False # The less destructive default 88 89 if not path: 90 return retVal 91 92 # we are caching answers so that we don't 93 # ask in each storage.reset() again 94 if path in self._initLabelAnswers: 95 log.info("UI not asking about disk initialization, " 96 "using cached answer: %s" % self._initLabelAnswers[path]) 97 return self._initLabelAnswers[path] 98 elif "all" in self._initLabelAnswers: 99 log.info("UI not asking about disk initialization, " 100 "using cached answer: %s" % self._initLabelAnswers["all"]) 101 return self._initLabelAnswers["all"] 102 103 rc = self.reinitializeWindow(_("Storage Device Warning"), 104 path, size, description) 105 106 if rc == 0: 107 retVal = False 108 elif rc == 1: 109 path = "all" 110 retVal = False 111 elif rc == 2: 112 retVal = True 113 elif rc == 3: 114 path = "all" 115 retVal = True 116 117 self._initLabelAnswers[path] = retVal 118 return retVal
119
121 self._inconsistentLVMAnswers = {}
122
123 - def questionReinitInconsistentLVM(self, pv_names=None, lv_name=None, vg_name=None):
124 125 retVal = False # The less destructive default 126 allSet = frozenset(["all"]) 127 128 if not pv_names or (lv_name is None and vg_name is None): 129 return retVal 130 131 # We are caching answers so that we don't ask for ignoring 132 # in each storage.reset() again (note that reinitialization is 133 # done right after confirmation in dialog, not as a planned 134 # action). 135 key = frozenset(pv_names) 136 if key in self._inconsistentLVMAnswers: 137 log.info("UI not asking about disk initialization, " 138 "using cached answer: %s" % self._inconsistentLVMAnswers[key]) 139 return self._inconsistentLVMAnswers[key] 140 elif allSet in self._inconsistentLVMAnswers: 141 log.info("UI not asking about disk initialization, " 142 "using cached answer: %s" % self._inconsistentLVMAnswers[allSet]) 143 return self._inconsistentLVMAnswers[allSet] 144 145 if vg_name is not None: 146 message = "Volume Group %s" % vg_name 147 elif lv_name is not None: 148 message = "Logical Volume %s" % lv_name 149 150 na = {'msg': message, 'pvs': ", ".join(pv_names)} 151 rc = self.messageWindow(_("Warning"), 152 _("Error processing LVM.\n" 153 "There is inconsistent LVM data on %(msg)s. You can " 154 "reinitialize all related PVs (%(pvs)s) which will erase " 155 "the LVM metadata, or ignore which will preserve the " 156 "contents. This action may also be applied to all other " 157 "PVs with inconsistent metadata.") % na, 158 type="custom", 159 custom_buttons = [ _("_Ignore"), 160 _("Ignore _all"), 161 _("_Re-initialize"), 162 _("Re-ini_tialize all") ], 163 custom_icon="question") 164 if rc == 0: 165 retVal = False 166 elif rc == 1: 167 key = allSet 168 retVal = False 169 elif rc == 2: 170 retVal = True 171 elif rc == 3: 172 key = allSet 173 retVal = True 174 175 self._inconsistentLVMAnswers[key] = retVal 176 return retVal
177
178 - def questionInitializeDASD(self, c, devs):
179 """Ask if unformatted DASD's should be formatted""" 180 title = P_("Unformatted DASD Device Found", 181 "Unformatted DASD Devices Found", c) 182 msg = P_("Format uninitialized DASD device?\n\n" 183 "There is %d uninitialized DASD device on this " 184 "system. To continue installation, the device must " 185 "be formatted. Formatting will remove any data on " 186 "this device.", 187 "Format uninitialized DASD devices?\n\n" 188 "There are %d uninitialized DASD devices on this " 189 "system. To continue installation, the devices must " 190 "be formatted. Formatting will remove any data on " 191 "these devices.", c) % c 192 icon = "/usr/share/icons/gnome/32x32/status/dialog-error.png" 193 buttons = [_("_Format"), _("_Ignore")] 194 return self.detailedMessageWindow(title, msg, devs.strip(), 195 type="custom", 196 custom_icon=icon, 197 custom_buttons=buttons, 198 expanded=True)
199
200 - def hardwareError(self, exception):
201 text=_("The installation was stopped due to what seems to be a problem " 202 "with your hardware. The exact error message is:\n\n%s.\n\n " 203 "The installer will now terminate.") % str(exception) 204 self.messageWindow(title=_("Hardware Error Encountered"), 205 text=text, 206 type="custom", 207 custom_icon="error", 208 custom_buttons=[_("_Exit installer")]) 209 sys.exit(0)
210
211 - def unsupported_steps(self):
212 """ List of steps this interface is unable to carry out. """ 213 return []
214