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. --- gui.py | 31 ++++++++++++++++++++++++++++ storage/__init__.py | 3 ++ storage/devicetree.py | 53 ++++++++++++++---------------------------------- 3 files changed, 50 insertions(+), 37 deletions(-) diff --git a/gui.py b/gui.py index 4e65362..17a7c4f 100755 --- a/gui.py +++ b/gui.py @@ -986,6 +986,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 @@ -1122,6 +1123,36 @@ class InstallInterface: d.destroy() return rc + def resetInitializeDiskQuestion(self): + self.initLabelAnswers = {} + + def questionInitializeDisk(self, path="", description="", size=0, + details=""): + retVal = False # The less destructive default + if path: + # we are caching answers so that we don't + # ask in each storage.reset() again + if path in self.initLabelAnswers: + 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 ea89633..4e2af50 100644 --- a/storage/__init__.py +++ b/storage/__init__.py @@ -75,6 +75,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 b528ab2..ea93c74 100644 --- a/storage/devicetree.py +++ b/storage/devicetree.py @@ -123,41 +123,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 @@ -1363,8 +1328,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", -- 1.6.0.6 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list