Don't ask again and again e.g. when going back and forth in custom partitioning UI. Related to bug #527711 which is itself fixed by another patch. (*) Answers are cached in InstallInterface classes. (*) Dialog callback is moved from storage code to InstallInterface classes. --- cmdline.py | 10 +++++++++ gui.py | 37 ++++++++++++++++++++++++++++++++++ storage/__init__.py | 3 ++ storage/devicetree.py | 53 ++++++++++++++---------------------------------- text.py | 37 ++++++++++++++++++++++++++++++++++ 5 files changed, 103 insertions(+), 37 deletions(-) diff --git a/cmdline.py b/cmdline.py index c6c98be..24485f7 100644 --- a/cmdline.py +++ b/cmdline.py @@ -134,6 +134,16 @@ class InstallInterface: while 1: time.sleep(5) + def resetInitializeDiskQuestion(self): + pass + + def questionInitializeDisk(self, path, description, size, details=""): + print(_("Can't have a question in command line mode!")) + print("(questionInitializeDisk)") + # don't exit + while 1: + time.sleep(5) + def mainExceptionWindow(self, shortText, longTextFile): print(shortText) diff --git a/gui.py b/gui.py index fc93af4..2f9f925 100755 --- a/gui.py +++ b/gui.py @@ -987,6 +987,7 @@ class InstallInterface: root = gtk.gdk.get_default_root_window() cursor = gtk.gdk.Cursor(gtk.gdk.LEFT_PTR) root.set_cursor(cursor) + self._initLabelAnswers = {} def __del__ (self): pass @@ -1123,6 +1124,42 @@ class InstallInterface: 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] + + 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!%(details)s") + % {'path': path, 'size': size, + 'description': description, 'details': details}, + type="custom", + custom_buttons = [ _("_Ignore drive"), + _("_Re-initialize drive") ], + custom_icon="question") + if rc == 0: + pass + else: + retVal = True + + self._initLabelAnswers[path] = retVal + return retVal + def beep(self): gtk.gdk.beep() diff --git a/storage/__init__.py b/storage/__init__.py index d50987d..c748362 100644 --- a/storage/__init__.py +++ b/storage/__init__.py @@ -78,6 +78,9 @@ def storageInitialize(anaconda): # populate the udev db udev_trigger(subsystem="block", action="change") + + anaconda.intf.resetInitializeDiskQuestion() + # Set up the protected partitions list now. if os.path.exists("/dev/live") and \ stat.S_ISBLK(os.stat("/dev/live")[stat.ST_MODE]): diff --git a/storage/devicetree.py b/storage/devicetree.py index 6c956fc..f93e44f 100644 --- a/storage/devicetree.py +++ b/storage/devicetree.py @@ -126,41 +126,6 @@ def getLUKSPassphrase(intf, device, globalPassphrase): return (passphrase, isglobal) -# Don't really know where to put this. -def questionInitializeDisk(intf=None, path=None, description=None): - retVal = False # The less destructive default - if not intf or not path: - pass - else: - if not path.startswith('/dev/'): - path = '/dev/' + path - - dev = parted.getDevice(path) - bypath = os.path.basename(deviceNameToDiskByPath(path)) - details = "" - - if description is None: - description = dev.model - - if bypath: - details = "\n\nDevice details:\n%s" % (bypath,) - - rc = intf.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!%(details)s") - % {'path': path, 'size': dev.getSize(), - 'description': description, 'details': details}, - type="custom", - custom_buttons = [ _("_Ignore drive"), - _("_Re-initialize drive") ], - custom_icon="question") - if rc == 0: - pass - else: - retVal = True - return retVal def questionReinitILVM(intf=None, pv_names=None, lv_name=None, vg_name=None): retVal = False # The less destructive default @@ -1364,8 +1329,22 @@ class DeviceTree(object): if self.zeroMbr: initcb = lambda: True else: - initcb = lambda: questionInitializeDisk(self.intf, device.path, - device.description) + # TODO RV is this check still necessary? + if device.path.startswith('/dev/'): + path = device.path + else: + path = '/dev/' + device.path + description = device.description or device.model + bypath = os.path.basename(deviceNameToDiskByPath(path)) + if bypath: + details = "\n\nDevice details:\n%s" % (bypath,) + else: + datails = "" + + initcb = lambda: self.intf.questionInitializeDisk(path, + description, + device.size, + details) try: format = getFormat("disklabel", diff --git a/text.py b/text.py index 60eafb7..6972417 100644 --- a/text.py +++ b/text.py @@ -437,6 +437,7 @@ class InstallInterface: signal.signal(signal.SIGINT, signal.SIG_IGN) signal.signal(signal.SIGTSTP, signal.SIG_IGN) self.screen = SnackScreen() + self._initLabelAnswers = {} def __del__(self): if self.screen: @@ -453,6 +454,42 @@ class InstallInterface: 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] + + 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!%(details)s") + % {'path': path, 'size': size, + 'description': description, 'details': details}, + type="custom", + custom_buttons = [ _("_Ignore drive"), + _("_Re-initialize drive") ], + custom_icon="question") + if rc == 0: + pass + else: + retVal = True + + self._initLabelAnswers[path] = retVal + return retVal + def run(self, anaconda): self.anaconda = anaconda instLang = anaconda.id.instLanguage -- 1.6.0.6 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list