Commits

Anonymous committed aaba80d

Begin readjusting the urwid interface

Comments (0)

Files changed (3)

 import gtk
 import sys
 import os
+from shutil import Error
 from support import widgets
 from support import dialogs
 from support.vectorlinux import SKEL
                 _("An error has occurred!") + "  \n\n%s"% e,
                 parent = self._parent
                 )
+        except Error as e:
+            return dialogs.error(
+                _("There was an error reverting settings") + "\n\n%s"% e,
+                parent = self._parent
+                )
         except OSError as e:
             return dialogs.error(
                 _("An error has occured while restoring original configuration") + "\n\n%s"% e,

modules/tui/tui_password.py

         error = ""
         if user is None:
             user = os.getenv("USERNAME")
+        # request the password change
         try:
-            ret = PASSWORDS.change_password(user, oldpass, newpass)
-        except etype, emsg:
-            error = emsg
-        if error:
+            PASSWORDS.change_password(user, oldpass, newpass):
+        except PASSWORDS.BadPasswordException:
             dia = dialogs.Error(
                 parent = self.parent,
-                message = _("The following error was produced while attempting to change the password")+ \
-                "\n%s"%error,
-                buttons = [("OK", self.return_to_module)]  
+                message = _("The current password you entered is incorrect.  Your password remains unchanged."),
+                buttons = [("OK", self.return_to_module)]
+                )
+            return self.parent.pop_module_dialog(dia)
+        except PASSWORDS.BadNewPasswordException:
+            dia = dialogs.error(
+                parent = self.parent,
+                message = ' '.join(
+                    _("The new password you entered does not meet the minimum requirements."), " ",
+                    _("Passwords should be at least 6 characters long.")
+                    ),
+                buttons = [("OK", self.return_to_module)]                    
+                )
+            return self.parent.pop_module_dialog(dia)
+        dia = dialogs.Info(
+            parent = self.parent,
+            message = _("Your password has been successfully changed."),
+            buttons = [("OK", self.return_home)]
             )
-        elif ret > 0:
-            dia = dialogs.Error(
-                parent = self.parent,
-                message = _("Unable to change password."),
-                buttons = [("OK", self.return_to_module)]
-            )
-        else:
-            dia = dialogs.Info(
-                parent = self.parent,
-                message = _("You password has been successfully changed."),
-                buttons = [("OK", self.return_home)]
-            )
-        # pop the resulting dialog
-        self.parent.pop_module_dialog(dia)
-        
+        return self.parent.pop_module_dialog(dia)        
     
     def return_to_module(self, widget=None):
         """ Used to return here after a dialog has been popped """
 def __run__(parent_toplevel):
     #mod = AboutVL(parent_toplevel)
     mod = PassDialog(parent_toplevel)
-    parent_toplevel.pop_module(mod)
+    parent_toplevel.pop_module(mod)

modules/tui/tui_skel.py

 import urwid
 import os
 import sys
+from shutil import Error
 if os.getcwd() not in sys.path:
     sys.path.append(os.getcwd())
 from modules.support.vectorlinux import SKEL
         self.parent = parent
         msgx = _("Select which settings you would like to reset. "\
                  "WARNING: This cannot be undone.")
-        settings = SKEL.list_resettable_settings()
+        self.skelmodel = SKEL.UserSkel(os.getenv("USERNAME"))
+        settings = self.skelmodel.list_resettable_settings()
         self._settings_to_reset = []
         _body = []
         self.settings_boxes = []
-        for file, desc in settings:
-            # The checkbox holds the file / dirname as the user data argument
+        for skel in settings:
+            # the checkbox holds the file / dirname as the user_data argument
+            desc = self.skelmodel._get_skel_description(skel)
             cb = urwid.CheckBox(desc,
-                                on_state_change=self.checkbox_toggle,
-                                user_data=file)
+                                on_state_change = self.checkbox_toggle,
+                                user_data = skel)
+
             self.settings_boxes.append(cb)
             wrap = urwid.AttrWrap(cb, 'button', 'button sel')
             _body.append(wrap)
         # first we want to close the current dialog...
         self.parent.return_to_module_stack(widget)
         # Now perform the actions
-        res = SKEL.do_reset_settings(
-            self._settings_to_reset, os.getenv("USERNAME"))
-        # Now we want to pop a dialog showing the results.
-        if res: # this would have a value of soemthing went wrong.
+        try:
+            self.skelmodel.reset_settings(self._settings_to_reset)
+        except AssertionError as e:
             dia = dialogs.Error(
                 parent = self.parent,
-                message = _("Unable to reset settings."),
-                buttons = [("OK", self.return_home)]                
+                message = _("An error has occurred!") + "\n\n%s"% e,
+                buttons = [("OK", self.return_home)]
+                )
+            return self.parent.pop_module_dialog(dia)
+        except Error as e:
+            dia = dialogs.Error(
+                parent = self.parent,
+                message = _("Error") + "\n\n%s"% e,
+                buttons = [("OK", self.return_home)]
+                )
+        except OSError as e:
+            dia = dialogs.Error(
+                parent = self.parent,
+                message = _("An error has occured!") + "\n\n%s"% e,
+                buttons = [("OK", self.return_home)]
+                )
+            return self.parent.pop_module_dialog(dia)
+
+        dia = dialogs.Info(
+            parent = self.parent,
+            message = _("The settings you selected have been reverted to system defaults."),
+            buttons = [("OK", self.return_home)]
             )
-        else:
-            dia = dialogs.Info(
-                parent = self.parent,
-                message = _("Your selected settings were successfully reverted to default values."),
-                buttons = [("OK", self.return_home)]
-            )
-
-        self.parent.pop_module_dialog(dia)
+        return self.parent.pop_module_dialog(dia)
     
     def return_home(self, widget):
         return self.parent.return_home(widget)