[PATCH 2/3] Display progress or wait window when formatting devices.

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

 



If we are using an external utility to create the format we can use
iutil.execWithPulseProgress. For formats we create using a python
module we can only put up a waitWindow.
---
 storage/formats/fs.py    |    4 ++--
 storage/formats/luks.py  |   34 +++++++++++++++++++++++-----------
 storage/formats/lvmpv.py |   33 ++++++++++++++++++++++++---------
 storage/formats/swap.py  |   22 ++++++++++++++++++----
 4 files changed, 67 insertions(+), 26 deletions(-)

diff --git a/storage/formats/fs.py b/storage/formats/fs.py
index 63a116b..7778ba5 100644
--- a/storage/formats/fs.py
+++ b/storage/formats/fs.py
@@ -327,8 +327,8 @@ class FS(DeviceFormat):
         w = None
         if intf:
             w = intf.progressWindow(_("Formatting"),
-                                    _("Creating filesystem on %s")
-                                    % (self.device,),
+                                    _("Creating %s filesystem on %s")
+                                    % (self.type, self.device),
                                     100, pulse = True)
 
         try:
diff --git a/storage/formats/luks.py b/storage/formats/luks.py
index 668e689..5d28e77 100644
--- a/storage/formats/luks.py
+++ b/storage/formats/luks.py
@@ -163,17 +163,29 @@ class LUKS(DeviceFormat):
         if not self.hasKey:
             raise LUKSError("luks device has no key/passphrase")
 
-        DeviceFormat.create(self, *args, **kwargs)
-        crypto.luks_format(self.device,
-                         passphrase=self.__passphrase,
-                         key_file=self._key_file,
-                         cipher=self.cipher,
-                         key_size=self.key_size)
-
-        self.uuid = crypto.luks_uuid(self.device)
-        self.exists = True
-        self.mapName = "luks-%s" % self.uuid
-        self.notifyKernel()
+        intf = kwargs.get("intf")
+        w = None
+        if intf:
+            w = intf.waitWindow(_("Formatting"),
+                                _("Encrypting %s") % (self.device,))
+
+        try:
+            DeviceFormat.create(self, *args, **kwargs)
+            crypto.luks_format(self.device,
+                             passphrase=self.__passphrase,
+                             key_file=self._key_file,
+                             cipher=self.cipher,
+                             key_size=self.key_size)
+        except Exception:
+            raise
+        else:
+            self.uuid = crypto.luks_uuid(self.device)
+            self.exists = True
+            self.mapName = "luks-%s" % self.uuid
+            self.notifyKernel()
+        finally:
+            if w:
+                w.pop()
 
     def destroy(self, *args, **kwargs):
         """ Create the format. """
diff --git a/storage/formats/lvmpv.py b/storage/formats/lvmpv.py
index faec109..c7b09b2 100644
--- a/storage/formats/lvmpv.py
+++ b/storage/formats/lvmpv.py
@@ -82,17 +82,32 @@ class LVMPhysicalVolume(DeviceFormat):
         """ Create the format. """
         log_method_call(self, device=self.device,
                         type=self.type, status=self.status)
-        DeviceFormat.create(self, *args, **kwargs)
-        # Consider use of -Z|--zero
-        # -f|--force or -y|--yes may be required
+        intf = kwargs.get("intf")
+        w = None
+        if intf:
+            w = intf.progressWindow(_("Formatting"),
+                                    _("Creating %s on %s")
+                                    % (self.name, self.device),
+                                    100, pulse = True)
 
-        # lvm has issues with persistence of metadata, so here comes the
-        # hammer...
-        DeviceFormat.destroy(self, *args, **kwargs)
+        try:
+            DeviceFormat.create(self, *args, **kwargs)
+            # Consider use of -Z|--zero
+            # -f|--force or -y|--yes may be required
 
-        lvm.pvcreate(self.device)
-        self.exists = True
-        self.notifyKernel()
+            # lvm has issues with persistence of metadata, so here comes the
+            # hammer...
+            DeviceFormat.destroy(self, *args, **kwargs)
+
+            lvm.pvcreate(self.device, progress=w)
+        except Exception:
+            raise
+        else:
+            self.exists = True
+            self.notifyKernel()
+        finally:
+            if w:
+                w.pop()
 
     def destroy(self, *args, **kwargs):
         """ Destroy the format. """
diff --git a/storage/formats/swap.py b/storage/formats/swap.py
index b1f0d62..ae33d33 100644
--- a/storage/formats/swap.py
+++ b/storage/formats/swap.py
@@ -133,8 +133,8 @@ class SwapSpace(DeviceFormat):
         """ Create the device. """
         log_method_call(self, device=self.device,
                         type=self.type, status=self.status)
+        intf = kwargs.get("intf")
         force = kwargs.get("force")
-
         if not force and self.exists:
             raise SwapSpaceError("format already exists")
 
@@ -143,9 +143,23 @@ class SwapSpace(DeviceFormat):
         elif self.status:
             raise SwapSpaceError("device exists and is active")
 
-        DeviceFormat.create(self, *args, **kwargs)
-        swap.mkswap(self.device, label=self.label)
-        self.exists = True
+        w = None
+        if intf:
+            w = intf.progressWindow(_("Formatting"),
+                                    _("Creating %s on %s")
+                                    % (self.type, self.device),
+                                    100, pulse = True)
+
+        try:
+            DeviceFormat.create(self, *args, **kwargs)
+            swap.mkswap(self.device, label=self.label, progress=w)
+        except Exception:
+            raise
+        else:
+            self.exists = True
+        finally:
+            if w:
+                w.pop()
 
     def writeKS(self, f):
         f.write("swap")
-- 
1.6.0.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux