def __init__(self, options, args, ui_args): from deluge.log import LOG as log log.debug("UI init..") # Set the config directory deluge.configmanager.set_config_dir(options.config) config = deluge.configmanager.ConfigManager("ui.conf", DEFAULT_PREFS) if not options.ui: selected_ui = config["default_ui"] else: selected_ui = options.ui setproctitle("deluge") config.save() del config try: if selected_ui == "gtk": log.info("Starting GtkUI..") from deluge.ui.gtkui.gtkui import GtkUI ui = GtkUI(args) elif selected_ui == "web": log.info("Starting WebUI..") from deluge.ui.web.web import WebUI ui = WebUI(args) elif selected_ui == "console": log.info("Starting ConsoleUI..") from deluge.ui.console.main import ConsoleUI ui = ConsoleUI(ui_args) except ImportError, e: import sys import traceback error_type, error_value, tb = sys.exc_info() stack = traceback.extract_tb(tb) last_frame = stack[-1] if last_frame[0] == __file__: log.error( "Unable to find the requested UI: %s. Please select a different UI with the '-u' option or alternatively use the '-s' option to select a different default UI.", selected_ui, ) else: log.exception(e) log.error("There was an error whilst launching the request UI: %s", selected_ui) log.error("Look at the traceback above for more information.") sys.exit(1)
except: pass import logging log = logging.getLogger(__name__) if options.profile: import hotshot hsp = hotshot.Profile(deluge.configmanager.get_config_dir("deluged.profile")) hsp.start() try: from deluge.core.daemon import Daemon Daemon(options, args) except deluge.error.DaemonRunningError, e: log.error(e) log.error("You cannot run multiple daemons with the same config directory set.") log.error("If you believe this is an error, you can force a start by deleting %s.", deluge.configmanager.get_config_dir("deluged.pid")) sys.exit(1) except Exception, e: log.exception(e) sys.exit(1) finally: if options.profile: hsp.stop() hsp.close() import hotshot.stats stats = hotshot.stats.load(deluge.configmanager.get_config_dir("deluged.profile")) stats.strip_dirs() stats.sort_stats("time", "calls") stats.print_stats(400)
if options.profile: import hotshot hsp = hotshot.Profile( deluge.configmanager.get_config_dir("deluged.profile")) hsp.start() try: from deluge.core.daemon import Daemon Daemon(options, args) except deluge.error.DaemonRunningError, e: log.error(e) log.error( "You cannot run multiple daemons with the same config directory set." ) log.error( "If you believe this is an error, you can force a start by deleting %s.", deluge.configmanager.get_config_dir("deluged.pid")) sys.exit(1) except Exception, e: log.exception(e) sys.exit(1) finally: if options.profile: hsp.stop() hsp.close() import hotshot.stats stats = hotshot.stats.load( deluge.configmanager.get_config_dir("deluged.profile")) stats.strip_dirs() stats.sort_stats("time", "calls") stats.print_stats(400)