Fix up error message when not specifying a directory with the --config option and add this to 1.1.x

This commit is contained in:
Andrew Resch 2009-05-11 04:10:05 +00:00
parent d85d8945e7
commit 1f06be95d1

View file

@ -63,7 +63,7 @@ def start_ui():
\t web -- A web-based interface (http://localhost:8112)\n
\t console -- A console or command-line interface""", action="store", type="str")
parser.add_option("-c", "--config", dest="config",
help="Set the config location", action="store", type="str")
help="Set the config folder location", action="store", type="str")
parser.add_option("-l", "--logfile", dest="logfile",
help="Output to designated logfile instead of stdout", action="store", type="str")
parser.add_option("-a", "--args", dest="args",
@ -78,6 +78,17 @@ def start_ui():
# Get the options and args from the OptionParser
(options, args) = parser.parse_args()
if options.config:
if not os.path.exists(options.config):
# Try to create the config folder if it doesn't exist
try:
os.makedirs(options.config)
except Exception, e:
pass
elif not os.path.isdir(options.config):
print "Config option needs to be a directory!"
sys.exit(1)
if options.default_ui:
if options.config:
deluge.configmanager.set_config_dir(options.config)
@ -91,13 +102,6 @@ def start_ui():
if options.quiet:
options.loglevel = "none"
if options.config:
if not os.path.exists(options.config):
# Try to create the config folder if it doesn't exist
try:
os.makedirs(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())