Added '-s', '--set-default-ui' option to deluge

This commit is contained in:
Andrew Resch 2009-01-08 20:27:24 +00:00
parent b9ae2cb2b9
commit 43be3e3e64
2 changed files with 30 additions and 17 deletions

View File

@ -34,6 +34,7 @@ import sys
from optparse import OptionParser from optparse import OptionParser
import deluge.common import deluge.common
import deluge.configmanager
def start_ui(): def start_ui():
"""Entry point for ui script""" """Entry point for ui script"""
@ -58,10 +59,22 @@ def start_ui():
help="Set the log level: none, info, warning, error, critical, debug", action="store", type="str") help="Set the log level: none, info, warning, error, critical, debug", action="store", type="str")
parser.add_option("-q", "--quiet", dest="quiet", parser.add_option("-q", "--quiet", dest="quiet",
help="Sets the log level to 'none', this is the same as `-L none`", action="store_true", default=False) help="Sets the log level to 'none', this is the same as `-L none`", action="store_true", default=False)
parser.add_option("-s", "--set-default-ui", dest="default_ui",
help="Sets the default UI to be run when no UI is specified", action="store", type="str")
# Get the options and args from the OptionParser # Get the options and args from the OptionParser
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
if options.default_ui:
if options.config:
deluge.configmanager.set_config_dir(options.config)
config = deluge.configmanager.ConfigManager("ui.conf")
config["default_ui"] = options.default_ui
config.save()
print "The default UI has been changed to", options.default_ui
sys.exit(0)
if options.quiet: if options.quiet:
options.loglevel = "none" options.loglevel = "none"

View File

@ -22,7 +22,7 @@
# Boston, MA 02110-1301, USA. # Boston, MA 02110-1301, USA.
# #
import sys
import deluge.configmanager import deluge.configmanager
from deluge.log import LOG as log from deluge.log import LOG as log
@ -48,19 +48,19 @@ class UI:
config.save() config.save()
del config del config
if selected_ui == "gtk": try:
log.info("Starting GtkUI..") if selected_ui == "gtk":
from deluge.ui.gtkui.gtkui import GtkUI log.info("Starting GtkUI..")
ui = GtkUI(args) from deluge.ui.gtkui.gtkui import GtkUI
elif selected_ui == "web": ui = GtkUI(args)
log.info("Starting WebUI..") elif selected_ui == "web":
from deluge.ui.webui.webui import WebUI log.info("Starting WebUI..")
ui = WebUI(args) from deluge.ui.webui.webui import WebUI
elif selected_ui == "null": ui = WebUI(args)
log.info("Starting NullUI..") elif selected_ui == "console":
from deluge.ui.null.deluge_shell import NullUI log.info("Starting ConsoleUI..")
ui = NullUI(args) from deluge.ui.console.main import ConsoleUI
elif selected_ui == "console": ui = ConsoleUI(ui_args).run()
log.info("Starting ConsoleUI..") except ImportError:
from deluge.ui.console.main import ConsoleUI log.error("Unable to find the requested UI. Please select a different UI with the '-u' option or alternatively use the '-s' option to select a different default UI.")
ui = ConsoleUI(ui_args).run() sys.exit(0)