Commits

Anonymous committed 0ec32b6

Completed work on fixing broken gtk ui for all modules.

  • Participants
  • Parent commits 6ce1577

Comments (0)

Files changed (3)

             _("Select which settings you would like to reset back to factory defaults."),
             "\n<b>%s</b>"% _("WARNING: This cannot be undone.")
         )
+        # The skel model
+        self.skelmodel = SKEL.UserSkel(os.getenv("USERNAME"))
         self.set_description(' '.join(tx))
         self.scroll = gtk.ScrolledWindow()
         self.scroll.set_policy(
             gtk.POLICY_AUTOMATIC
         )
         self.datamodel = gtk.ListStore(bool, bool, str, str)
-        settings = SKEL.list_resettable_settings()
-        skeldir = SKEL.skeldir
-        
+        settings = self.skelmodel.list_resettable_settings()
+        skeldir = self.skelmodel.skeldir
+
         for item in settings:
-            filename, desc = item
-            if "*" not in filename:
-                if os.path.exists(os.path.join(skeldir, filename)):
-                    self.datamodel.append(row=(False, True, filename, desc))
+            desc = self.skelmodel._get_skel_description(item)
+            self.datamodel.append([False, True, item, desc])
         
         self.treeview = gtk.TreeView(model = self.datamodel)
         self.treeview.set_headers_visible(False)
     def do_apply_changes(self, widget=None):
         """ Make the call to the backend to apply the changes. """
         reset = self._get_reset_list()
-        if len(reset) <= 0:
-            return dialogs.error(_("Nothing has been selected.  Select what to reset."))
-        uname = os.getenv("USERNAME")
-        ret = SKEL.do_reset_settings(reset, uname)
-        if ret is True:
-            return dialogs.error(_("The settings reset process returned an error."),
-                                 parent=self._parent)
-        else:
-            return dialogs.info(_("Personal settings have been restored back to system defaults."),
-                                parent=self._parent)
-
+        try:
+            self.skelmodel.reset_settings(reset)
+        except AssertionError as e:
+            return dialogs.error(
+                _("An error has occurred!") + "  \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,
+                parent = self._parent)
+        
+        return dialogs.info(
+            _("The settings you selected have been reset back to system defaults."),
+            parent = self._parent
+            )
 
 def __run__(parent=None):
     skeller = gtkSkel(parent=parent)

modules/support/vectorlinux/SKEL.py

 
 class UserSkel(object):
     """ Class for interacting with a user's skel settings """
-    def __init__(self, login=""):
+    def __init__(self, login="", skeldir='/etc/skel'):
         assert login not in ("", None), "You must provide a valid login name"
         self.login = login
-	self.skeldir = "/etc/skel/"
+	self.skeldir = skeldir
 	self.targetdir = os.path.join("/home", self.login)
 
     def _get_skel_description(self, skel=""):
 	else:
 	    os.remove(target)
 	    shutil.copyfile(source, target)
-        # Fix the permissions on the new stuff
-	cmd = ["chown","-R","%s:users"% self.login, target]
-	proc = get_popen(cmd)
-	output, error = proc.communicate()
-	return proc.returncode, error	    
+
+    def _adjust_skel_permissions(self, skel):
+        """ Adjust the permissions for skel"""
+        cmd = ["chown","-R","%s:users"% self.login, os.path.join(self.targetdir, skel)]
+        proc = get_popen(cmd)
+        proc.communicate()
+        # We dont want to raise exceptions here.
+        return
 
     def reset_settings(self, reset_list=[]):
 	""" Reset the settings provided in reset_list. Returns True by default """
-	for item in reset_list:
-	   code, error =  self._wipe_setting(item)
-	   # we want this to raise an exception if subprocess returns an error
-	   assert code == 0, "Subprocess error while resetting %s \n%s"% (item, error)
-
+	for item in reset_list:                
+            self._wipe_setting(item)
+            self._adjust_skel_permissions(item)
 	return True

modules/support/vectorlinux/USERADMIN.py

         if not hasattr(usuario, 'password') or usuario.password is None:
             raise EmptyAttributeError('Password attribute is empty.  Expected a string.')
         if not hasattr(usuario, 'groups') or usuario.groups is None or type(usuario.groups) is not list:
-            raise EmptyAttributeErro('Empty groups attribute.  Expected a list.')
+            raise EmptyAttributeError('Empty groups attribute.  Expected a list.')
         if not hasattr(usuario, 'password') or usuario.password is None:
             raise EmptyAttributeError('Empty password attribute.  Expected a string.')
         assert len(usuario.password) >= 5, "Provided password for new user is too short."