[PATCH 04/12] Fix the usages of PWQError. (#1014405)

David Shea dshea at redhat.com
Fri Oct 4 18:28:10 UTC 2013


The PWQError exceptions created by the pwquality library do not contain
any named members, so treat them as tuples intead.
---
 pyanaconda/ui/gui/spokes/lib/passphrase.py | 2 +-
 pyanaconda/ui/gui/spokes/password.py       | 4 ++--
 pyanaconda/ui/gui/spokes/user.py           | 2 +-
 pyanaconda/ui/tui/spokes/__init__.py       | 4 ++--
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/lib/passphrase.py b/pyanaconda/ui/gui/spokes/lib/passphrase.py
index 2cd6887..0fcefd9 100644
--- a/pyanaconda/ui/gui/spokes/lib/passphrase.py
+++ b/pyanaconda/ui/gui/spokes/lib/passphrase.py
@@ -107,7 +107,7 @@ class PassphraseDialog(GUIObject):
         try:
             strength = self._pwq.check(passphrase, None, None)
         except pwquality.PWQError as e:
-            self._pwq_error = e.message
+            self._pwq_error = e[1]
 
         if strength < 50:
             val = 1
diff --git a/pyanaconda/ui/gui/spokes/password.py b/pyanaconda/ui/gui/spokes/password.py
index b828317..dc0782d 100644
--- a/pyanaconda/ui/gui/spokes/password.py
+++ b/pyanaconda/ui/gui/spokes/password.py
@@ -115,7 +115,7 @@ class PasswordSpoke(FirstbootSpokeMixIn, NormalSpoke):
             strength = checkPassword(self.pw.get_text())
             _pwq_error = None
         except PWQError as e:
-            _pwq_error = e.message
+            _pwq_error = e[1]
             strength = 0
 
         if strength < 50:
@@ -181,7 +181,7 @@ class PasswordSpoke(FirstbootSpokeMixIn, NormalSpoke):
                 pass
             else:
                 self._error = _("You have provided a weak password: %s. "
-                                " Press Done again to use anyway.") % e.message
+                                " Press Done again to use anyway.") % e[1]
                 self._oldweak = pw
                 return False
 
diff --git a/pyanaconda/ui/gui/spokes/user.py b/pyanaconda/ui/gui/spokes/user.py
index 295e236..2b9e089 100644
--- a/pyanaconda/ui/gui/spokes/user.py
+++ b/pyanaconda/ui/gui/spokes/user.py
@@ -414,7 +414,7 @@ class UserSpoke(FirstbootSpokeMixIn, NormalSpoke):
             strength = self._pwq.check(pwtext, None, None)
             self._pwq_error = None
         except pwquality.PWQError as e:
-            self._pwq_error = e.message
+            self._pwq_error = e[1]
             strength = 0
 
         if not pwtext:
diff --git a/pyanaconda/ui/tui/spokes/__init__.py b/pyanaconda/ui/tui/spokes/__init__.py
index 5dd8424..f4d1a36 100644
--- a/pyanaconda/ui/tui/spokes/__init__.py
+++ b/pyanaconda/ui/tui/spokes/__init__.py
@@ -120,9 +120,9 @@ class EditTUIDialog(NormalTUISpoke):
                     return None
                 strength = checkPassword(pw)
                 if strength < 50:
-                    raise PWQError("The password you have provided is weak.")
+                    raise PWQError((-1, "The password you have provided is weak."))
             except PWQError as e:
-                error = _("You have provided a weak password: %s. " % e.message)
+                error = _("You have provided a weak password: %s. " % e[1])
                 error += _("\nWould you like to use it anyway?")
                 question_window = YesNoDialog(self._app, error)
                 self._app.switch_screen_modal(question_window)
-- 
1.8.3.1



More information about the anaconda-patches mailing list