mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-26 10:05:19 +00:00
Improvements to the new UI class and improve how ConfigManager handles
setting the config directory
This commit is contained in:
parent
62bc9d1844
commit
df21107e3f
@ -45,18 +45,31 @@ class _ConfigManager:
|
||||
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
|
||||
|
@ -71,32 +71,19 @@ class _UI(object):
|
||||
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)
|
||||
|
||||
version = deluge.common.get_version()
|
||||
|
||||
log = deluge.log.LOG
|
||||
log.info("Deluge ui %s", 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.info("Deluge ui %s", deluge.common.get_version())
|
||||
log.debug("options: %s", self.__options)
|
||||
log.debug("args: %s", self.__args)
|
||||
log.info("Starting ui..")
|
||||
|
Loading…
x
Reference in New Issue
Block a user