[anaconda][master/rhel7-branch][1/3] Add dialog box to warn about formatting DASDs. (#1064423)

Samantha N. Bueno sbueno+anaconda at redhat.com
Mon Mar 3 18:00:40 UTC 2014


Argh, and pretend that 'exit' icon on the dialog title bar is not there.
Because it no longer is in my local copy.

On Mon, Mar 03, 2014 at 12:53:36PM -0500, Samantha N. Bueno wrote:
> A GtkDialog box which shows the progress of dasdfmt as it is run
> against unformatted DASDs.
> 
> Resolves: rhbz#1064423
> ---
>  po/POTFILES.in                             |   2 +
>  pyanaconda/ui/gui/spokes/lib/dasdfmt.glade | 329 +++++++++++++++++++++++++++++
>  pyanaconda/ui/gui/spokes/lib/dasdfmt.py    | 138 ++++++++++++
>  3 files changed, 469 insertions(+)
>  create mode 100644 pyanaconda/ui/gui/spokes/lib/dasdfmt.glade
>  create mode 100644 pyanaconda/ui/gui/spokes/lib/dasdfmt.py
> 
> diff --git a/po/POTFILES.in b/po/POTFILES.in
> index 3d53ce4..4b341fc 100644
> --- a/po/POTFILES.in
> +++ b/po/POTFILES.in
> @@ -76,6 +76,7 @@ pyanaconda/ui/gui/spokes/user.py
>  pyanaconda/ui/gui/spokes/welcome.py
>  pyanaconda/ui/gui/spokes/lib/accordion.py
>  pyanaconda/ui/gui/spokes/lib/cart.py
> +pyanaconda/ui/gui/spokes/lib/dasdfmt.py
>  pyanaconda/ui/gui/spokes/lib/passphrase.py
>  pyanaconda/ui/gui/spokes/lib/refresh.py
>  pyanaconda/ui/gui/spokes/lib/resize.py
> @@ -99,6 +100,7 @@ pyanaconda/ui/gui/spokes/advstorage/fcoe.glade
>  pyanaconda/ui/gui/spokes/advstorage/iscsi.glade
>  pyanaconda/ui/gui/spokes/advstorage/zfcp.glade
>  pyanaconda/ui/gui/spokes/lib/cart.glade
> +pyanaconda/ui/gui/spokes/lib/dasdfmt.glade
>  pyanaconda/ui/gui/spokes/lib/detailederror.glade
>  pyanaconda/ui/gui/spokes/lib/passphrase.glade
>  pyanaconda/ui/gui/spokes/lib/refresh.glade
> diff --git a/pyanaconda/ui/gui/spokes/lib/dasdfmt.glade b/pyanaconda/ui/gui/spokes/lib/dasdfmt.glade
> new file mode 100644
> index 0000000..adc9403
> --- /dev/null
> +++ b/pyanaconda/ui/gui/spokes/lib/dasdfmt.glade
> @@ -0,0 +1,329 @@
> +<?xml version="1.0" encoding="UTF-8"?>
> +<interface>
> +  <!-- interface-requires gtk+ 3.6 -->
> +  <object class="GtkDialog" id="unformattedDasdDialog">
> +    <property name="can_focus">False</property>
> +    <property name="border_width">5</property>
> +    <property name="title" translatable="yes">UNFORMATTED DASDS</property>
> +    <property name="modal">True</property>
> +    <property name="type_hint">dialog</property>
> +    <property name="decorated">False</property>
> +    <child internal-child="vbox">
> +      <object class="GtkBox" id="dialog-vbox1">
> +        <property name="can_focus">False</property>
> +        <property name="orientation">vertical</property>
> +        <property name="spacing">2</property>
> +        <child>
> +          <object class="GtkGrid" id="ud-grid">
> +            <property name="visible">True</property>
> +            <property name="can_focus">False</property>
> +            <property name="row_spacing">12</property>
> +            <property name="column_spacing">6</property>
> +            <child>
> +              <object class="GtkImage" id="ud-image">
> +                <property name="visible">True</property>
> +                <property name="can_focus">False</property>
> +                <property name="stock">gtk-quit</property>
> +                <property name="icon-size">6</property>
> +              </object>
> +              <packing>
> +                <property name="left_attach">0</property>
> +                <property name="top_attach">0</property>
> +                <property name="width">1</property>
> +                <property name="height">1</property>
> +              </packing>
> +            </child>
> +            <child>
> +              <object class="GtkLabel" id="unformattedDasdDesc">
> +                <property name="width_request">300</property>
> +                <property name="visible">True</property>
> +                <property name="can_focus">False</property>
> +                <property name="valign">start</property>
> +                <property name="label" translatable="yes">The following unformatted DASDs have been detected on your system. You can choose to format them now with dasdfmt or cancel to leave them unformatted. Unformatted DASDs can not be used during installation.</property>
> +                <property name="wrap">True</property>
> +                <attributes>
> +                  <attribute name="font-desc" value="Cantarell 12"/>
> +                </attributes>
> +              </object>
> +              <packing>
> +                <property name="left_attach">1</property>
> +                <property name="top_attach">1</property>
> +                <property name="width">1</property>
> +                <property name="height">1</property>
> +              </packing>
> +            </child>
> +            <child>
> +              <object class="GtkLabel" id="unformattedDasdTitle">
> +                <property name="visible">True</property>
> +                <property name="can_focus">False</property>
> +                <property name="halign">start</property>
> +                <property name="label" translatable="yes">Unformatted DASDs Detected</property>
> +                <attributes>
> +                  <attribute name="font-desc" value="Cantarell Bold 12"/>
> +                  <attribute name="weight" value="bold"/>
> +                </attributes>
> +              </object>
> +              <packing>
> +                <property name="left_attach">1</property>
> +                <property name="top_attach">0</property>
> +                <property name="width">1</property>
> +                <property name="height">1</property>
> +              </packing>
> +            </child>
> +            <child>
> +              <placeholder/>
> +            </child>
> +          </object>
> +          <packing>
> +            <property name="expand">True</property>
> +            <property name="fill">True</property>
> +            <property name="position">0</property>
> +          </packing>
> +        </child>
> +        <child>
> +          <object class="GtkLabel" id="udLabel">
> +            <property name="visible">True</property>
> +            <property name="can_focus">False</property>
> +            <property name="label">List unformatted DASDs here.</property>
> +          </object>
> +          <packing>
> +            <property name="expand">False</property>
> +            <property name="fill">True</property>
> +            <property name="position">1</property>
> +          </packing>
> +        </child>
> +        <child>
> +          <object class="GtkBox" id="warningBox">
> +            <property name="visible">True</property>
> +            <property name="can_focus">False</property>
> +            <child>
> +              <object class="GtkImage" id="warnIcon">
> +                <property name="visible">True</property>
> +                <property name="can_focus">False</property>
> +                <property name="stock">gtk-dialog-warning</property>
> +              </object>
> +              <packing>
> +                <property name="expand">False</property>
> +                <property name="fill">True</property>
> +                <property name="position">0</property>
> +              </packing>
> +            </child>
> +            <child>
> +              <object class="GtkLabel" id="label9">
> +                <property name="visible">True</property>
> +                <property name="can_focus">False</property>
> +                <property name="label" translatable="yes">&lt;b&gt;Warning&lt;/b&gt;: All storage changes made using the installer will be lost when you choose to format.</property>
> +                <property name="use_markup">True</property>
> +                <property name="wrap">True</property>
> +              </object>
> +              <packing>
> +                <property name="expand">False</property>
> +                <property name="fill">True</property>
> +                <property name="position">2</property>
> +              </packing>
> +            </child>
> +          </object>
> +          <packing>
> +            <property name="expand">False</property>
> +            <property name="fill">True</property>
> +            <property name="position">2</property>
> +          </packing>
> +        </child>
> +        <child>
> +          <object class="GtkNotebook" id="formatNotebook">
> +            <property name="visible">True</property>
> +            <property name="can_focus">False</property>
> +            <property name="show_tabs">False</property>
> +            <child>
> +              <object class="GtkButton" id="formatButton">
> +                <property name="label" translatable="yes">_Format with dasdfmt</property>
> +                <property name="visible">True</property>
> +                <property name="can_focus">True</property>
> +                <property name="receives_default">True</property>
> +                <property name="halign">center</property>
> +                <property name="valign">center</property>
> +                <property name="use_underline">True</property>
> +                <signal name="clicked" handler="on_format_clicked" swapped="no"/>
> +              </object>
> +            </child>
> +            <child type="tab">
> +              <placeholder/>
> +            </child>
> +            <child>
> +              <object class="GtkGrid" id="formatBox">
> +                <property name="visible">True</property>
> +                <property name="can_focus">False</property>
> +                <property name="halign">center</property>
> +                <property name="valign">center</property>
> +                <property name="row_spacing">18</property>
> +                <property name="column_spacing">6</property>
> +                <child>
> +                  <object class="GtkSpinner" id="spinner4">
> +                    <property name="visible">True</property>
> +                    <property name="can_focus">False</property>
> +                    <property name="active">True</property>
> +                  </object>
> +                  <packing>
> +                    <property name="left_attach">0</property>
> +                    <property name="top_attach">0</property>
> +                    <property name="width">1</property>
> +                    <property name="height">1</property>
> +                  </packing>
> +                </child>
> +                <child>
> +                  <object class="GtkLabel" id="formatLabel">
> +                    <property name="visible">True</property>
> +                    <property name="can_focus">False</property>
> +                    <property name="label" translatable="no">Current DASD being formatted.</property>
> +                  </object>
> +                  <packing>
> +                    <property name="left_attach">1</property>
> +                    <property name="top_attach">0</property>
> +                    <property name="width">1</property>
> +                    <property name="height">1</property>
> +                  </packing>
> +                </child>
> +                <child>
> +                  <object class="GtkLabel" id="returnToHubLabel1">
> +                    <property name="visible">True</property>
> +                    <property name="can_focus">True</property>
> +                    <property name="label" translatable="yes">You may &lt;a href=""&gt;go back to the main menu&lt;/a&gt; to complete other
> +installation options while formatting completes.</property>
> +                    <property name="use_markup">True</property>
> +                    <property name="wrap">True</property>
> +                    <property name="track_visited_links">False</property>
> +                    <signal name="activate-link" handler="return_to_hub_link_clicked" swapped="no"/>
> +                  </object>
> +                  <packing>
> +                    <property name="left_attach">0</property>
> +                    <property name="top_attach">1</property>
> +                    <property name="width">2</property>
> +                    <property name="height">1</property>
> +                  </packing>
> +                </child>
> +              </object>
> +            </child>
> +            <child type="tab">
> +              <placeholder/>
> +            </child>
> +            <child>
> +              <placeholder/>
> +            </child>
> +            <child type="tab">
> +              <placeholder/>
> +            </child>
> +            <child>
> +              <object class="GtkGrid" id="formatDoneBox">
> +                <property name="visible">True</property>
> +                <property name="can_focus">False</property>
> +                <property name="halign">center</property>
> +                <property name="valign">center</property>
> +                <property name="row_spacing">6</property>
> +                <property name="column_spacing">6</property>
> +                <child>
> +                  <object class="GtkLabel" id="label18">
> +                    <property name="visible">True</property>
> +                    <property name="can_focus">False</property>
> +                    <property name="xalign">0</property>
> +                    <property name="label" translatable="yes">&lt;b&gt;Disk formatting complete.&lt;/b&gt;</property>
> +                    <property name="use_markup">True</property>
> +                  </object>
> +                  <packing>
> +                    <property name="left_attach">1</property>
> +                    <property name="top_attach">0</property>
> +                    <property name="width">1</property>
> +                    <property name="height">1</property>
> +                  </packing>
> +                </child>
> +                <child>
> +                  <object class="GtkLabel" id="label19">
> +                    <property name="visible">True</property>
> +                    <property name="can_focus">False</property>
> +                    <property name="xalign">0</property>
> +                    <property name="label" translatable="yes">Pressing 'OK' below will take you to the disk selection screen where you will need to re-select your disks.</property>
> +                    <property name="wrap">True</property>
> +                  </object>
> +                  <packing>
> +                    <property name="left_attach">1</property>
> +                    <property name="top_attach">1</property>
> +                    <property name="width">1</property>
> +                    <property name="height">1</property>
> +                  </packing>
> +                </child>
> +                <child>
> +                  <object class="GtkImage" id="image3">
> +                    <property name="visible">True</property>
> +                    <property name="can_focus">False</property>
> +                    <property name="stock">gtk-apply</property>
> +                  </object>
> +                  <packing>
> +                    <property name="left_attach">0</property>
> +                    <property name="top_attach">0</property>
> +                    <property name="width">1</property>
> +                    <property name="height">2</property>
> +                  </packing>
> +                </child>
> +              </object>
> +              <packing>
> +                <property name="position">3</property>
> +              </packing>
> +            </child>
> +            <child type="tab">
> +              <placeholder/>
> +            </child>
> +          </object>
> +          <packing>
> +            <property name="expand">True</property>
> +            <property name="fill">True</property>
> +            <property name="position">3</property>
> +          </packing>
> +        </child>
> +        <child internal-child="action_area">
> +          <object class="GtkButtonBox" id="dialog-action_area1">
> +            <property name="can_focus">False</property>
> +            <property name="layout_style">end</property>
> +            <child>
> +              <object class="GtkButton" id="udCancelButton">
> +                <property name="label" translatable="yes">_Cancel</property>
> +                <property name="visible">True</property>
> +                <property name="can_focus">True</property>
> +                <property name="receives_default">True</property>
> +                <property name="use_underline">True</property>
> +              </object>
> +              <packing>
> +                <property name="expand">False</property>
> +                <property name="fill">True</property>
> +                <property name="position">0</property>
> +              </packing>
> +            </child>
> +            <child>
> +              <object class="GtkButton" id="udOKButton">
> +                <property name="label" translatable="yes">_OK</property>
> +                <property name="visible">True</property>
> +                <property name="sensitive">False</property>
> +                <property name="can_focus">True</property>
> +                <property name="receives_default">True</property>
> +                <property name="use_underline">True</property>
> +              </object>
> +              <packing>
> +                <property name="expand">False</property>
> +                <property name="fill">True</property>
> +                <property name="position">1</property>
> +              </packing>
> +            </child>
> +          </object>
> +          <packing>
> +            <property name="expand">False</property>
> +            <property name="fill">True</property>
> +            <property name="pack_type">end</property>
> +            <property name="position">4</property>
> +          </packing>
> +        </child>
> +      </object>
> +    </child>
> +    <action-widgets>
> +      <action-widget response="0">udCancelButton</action-widget>
> +      <action-widget response="1">udOKButton</action-widget>
> +    </action-widgets>
> +  </object>
> +</interface>
> diff --git a/pyanaconda/ui/gui/spokes/lib/dasdfmt.py b/pyanaconda/ui/gui/spokes/lib/dasdfmt.py
> new file mode 100644
> index 0000000..8666b56
> --- /dev/null
> +++ b/pyanaconda/ui/gui/spokes/lib/dasdfmt.py
> @@ -0,0 +1,138 @@
> +# DASD format dialog
> +#
> +# Copyright (C) 2014  Red Hat, Inc.
> +#
> +# This copyrighted material is made available to anyone wishing to use,
> +# modify, copy, or redistribute it subject to the terms and conditions of
> +# the GNU General Public License v.2, or (at your option) any later version.
> +# This program is distributed in the hope that it will be useful, but WITHOUT
> +# ANY WARRANTY expressed or implied, including the implied warranties of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
> +# Public License for more details.  You should have received a copy of the
> +# GNU General Public License along with this program; if not, write to the
> +# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> +# 02110-1301, USA.  Any Red Hat trademarks that are incorporated in the
> +# source code or documentation are not subject to the GNU General Public
> +# License and may only be used or replicated with the express permission of
> +# Red Hat, Inc.
> +#
> +# Red Hat Author(s): Samantha N. Bueno <sbueno at redhat.com>
> +#                    Chris Lumens <clumens at redhat.com>
> +#
> +
> +from pyanaconda.threads import threadMgr, AnacondaThread
> +from pyanaconda.ui.gui import GUIObject
> +from pyanaconda.ui.gui.utils import gtk_action_wait, gtk_call_once
> +from pyanaconda import constants
> +from pyanaconda.i18n import _
> +import threading
> +
> +from blivet import storageInitialize
> +from blivet.devicelibs.dasd import format_dasd
> +from blivet.errors import DasdFormatError
> +
> +import logging
> +log = logging.getLogger("anaconda")
> +
> +__all__ = ["DasdFormatDialog"]
> +
> +class DasdFormatDialog(GUIObject):
> +    builderObjects = ["unformattedDasdDialog"]
> +    mainWidgetName = "unformattedDasdDialog"
> +    uiFile = "spokes/lib/dasdfmt.glade"
> +
> +    def __init__(self, data, storage, to_format):
> +        GUIObject.__init__(self, data)
> +
> +        self.storage = storage
> +        self.to_format = to_format
> +
> +        self._notebook = self.builder.get_object("formatNotebook")
> +        self._cancel_button = self.builder.get_object("udCancelButton")
> +        self._ok_button = self.builder.get_object("udOKButton")
> +        self._unformatted_label = self.builder.get_object("udLabel")
> +        self._formatting_label = self.builder.get_object("formatLabel")
> +        self._warn_box = self.builder.get_object("warningBox")
> +        self._hub_label = self.builder.get_object("returnToHubLabel1")
> +
> +        if len(self.to_format) > 0:
> +            self._unformatted_label.set_text("\n".join("/dev/" + d for d in to_format))
> +        else:
> +            self._unformatted_label.set_text("")
> +
> +        # epoch is only increased when user interrupts action to return to hub
> +        self._epoch = 0
> +        self._epoch_lock = threading.Lock()
> +
> +    def run(self):
> +        rc = self.window.run()
> +        with self._epoch_lock:
> +            # Destroy window with epoch lock so we don't accidentally end
> +            # formatting
> +            self.window.destroy()
> +            if rc == 2:
> +                # User clicked uri to return to hub. We need to catch this here so
> +                # that we can halt all further dialog actions
> +                self._epoch += 1
> +        return rc
> +
> +    def return_to_hub_link_clicked(self, label, uri):
> +        """
> +        The user clicked on the link that takes them back to the hub.  We need
> +        to kill the _check_format watcher and then emit a special response ID
> +        indicating the user did not press OK.
> +
> +        NOTE: There is no button with response_id=2.
> +        """
> +        self.window.response(2)
> +
> +    def run_dasdfmt(self, epoch_started, *args):
> +        """ Loop through our disks and run dasdfmt against them. """
> +        for disk in self.to_format:
> +            try:
> +                gtk_call_once(self._formatting_label.set_text, _("Formatting /dev/%s. This may take a moment." % disk))
> +                format_dasd(disk)
> +            except DasdFormatError as err:
> +                # Log errors if formatting fails, but don't halt the installer
> +                log.error(str(err))
> +                continue
> +
> +        # And now to fire up the storage reinitialization.
> +        protectedNames = [d.name for d in self.storage.protectedDevices]
> +        storageInitialize(self.storage, self.data, protectedNames)
> +
> +        with self._epoch_lock:
> +            self.update_dialog(epoch_started)
> +
> +    def on_format_clicked(self, *args):
> +        """
> +        Once the format button is clicked, the option to cancel expires.
> +        We also need to display the spinner showing activity.
> +        """
> +        self._cancel_button.set_sensitive(False)
> +        self._ok_button.set_sensitive(False)
> +        self._notebook.set_current_page(1)
> +
> +        # Loop through all of our unformatted DASDs and format them
> +        threadMgr.add(AnacondaThread(name=constants.THREAD_DASDFMT,
> +                                target=self.run_dasdfmt, args=(self._epoch,)))
> +
> +    @gtk_action_wait
> +    def update_dialog(self, epoch_started):
> +        """
> +        This optionally updates the Gtk dialog box, assuming the user has not
> +        clicked to return back to the summary hub.
> +        """
> +        if epoch_started == self._epoch:
> +            # we only want to change anything on the dialog if we are in the
> +            # same epoch as it is; the only time we should not be running these
> +            # commands is if a user clicks return_to_hub
> +            self._notebook.set_current_page(2)
> +            self._cancel_button.set_sensitive(False)
> +            self._ok_button.set_sensitive(True)
> +
> +            # Seems a little silly to have some of this text still displayed
> +            # when everything is done.
> +            self._unformatted_label.set_text("")
> +            self._hub_label.set_text("")
> +            self._warn_box.set_visible(False)
> -- 
> 1.8.3.1
> 
> _______________________________________________
> anaconda-patches mailing list
> anaconda-patches at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches


More information about the anaconda-patches mailing list