Author: andar

Revision: 5278

Log:
        Improvements to the new UI class and improve how ConfigManager handles 
setting the config directory

Diff:
Modified: trunk/deluge/configmanager.py
===================================================================
--- trunk/deluge/configmanager.py       2009-05-18 17:43:29 UTC (rev 5277)
+++ trunk/deluge/configmanager.py       2009-05-18 21:34:03 UTC (rev 5278)
@@ -45,18 +45,31 @@
         del self.config_files
 
     def set_config_dir(self, directory):
-        """Sets the config directory"""
-        if directory == None:
-            return
+        """
+        Sets the config directory.
+
+        :param directory: str, the directory where the config info should be
+
+        :returns bool: True if successfully changed directory, False if not
+        """
+
+        if not directory:
+            return False
+
         log.info("Setting config directory to: %s", directory)
         if not os.path.exists(directory):
             # Try to create the config folder if it doesn't exist
             try:
                 os.makedirs(directory)
             except Exception, e:
-                log.warning("Unable to make config directory: %s", e)
+                log.error("Unable to make config directory: %s", e)
+                return False
+        elif not os.path.isdir(directory):
+            log.error("Config directory needs to be a directory!")
+            return False
 
         self.__config_directory = directory
+        return True
 
     def get_config_dir(self):
         return self.config_directory

Modified: trunk/deluge/ui/ui.py
===================================================================
--- trunk/deluge/ui/ui.py       2009-05-18 17:43:29 UTC (rev 5277)
+++ trunk/deluge/ui/ui.py       2009-05-18 21:34:03 UTC (rev 5278)
@@ -71,32 +71,19 @@
     def start(self):
         (self.__options, self.__args) = self.__parser.parse_args()
 
-
         if self.__options.quiet:
             self.__options.loglevel = "none"
 
-        if self.__options.config:
-            if not os.path.isdir(self.__options.config):
-                print "Config option needs to be a directory!"
-                sys.exit(1)
-
-            if not os.path.exists(self.__options.config):
-                # Try to create the config folder if it doesn't exist
-                try:
-                    os.makedirs(self.__options.config)
-                except Exception, e:
-                    pass
-        else:
-            if not os.path.exists(deluge.common.get_default_config_dir()):
-                os.makedirs(deluge.common.get_default_config_dir())
-
         # Setup the logger
         deluge.log.setupLogger(level=self.__options.loglevel, 
filename=self.__options.logfile)
+        log = deluge.log.LOG
 
-        version = deluge.common.get_version()
+        if self.__options.config:
+            if not deluge.configmanager.set_config_dir(self.__options.config):
+                log.error("There was an error setting the config dir! 
Exiting..")
+                sys.exit(1)
 
-        log = deluge.log.LOG
-        log.info("Deluge ui %s", version)
+        log.info("Deluge ui %s", deluge.common.get_version())
         log.debug("options: %s", self.__options)
         log.debug("args: %s", self.__args)
         log.info("Starting ui..")



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to