diff --git a/deluge/main.py b/deluge/main.py index 2308f9f71..57e7c0615 100644 --- a/deluge/main.py +++ b/deluge/main.py @@ -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())