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
import deluge.common
import deluge.configmanager
def start_ui():
"""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")
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)
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
(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:
options.loglevel = "none"

View File

@ -22,7 +22,7 @@
# Boston, MA 02110-1301, USA.
#
import sys
import deluge.configmanager
from deluge.log import LOG as log
@ -48,19 +48,19 @@ class UI:
config.save()
del config
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.webui.webui import WebUI
ui = WebUI(args)
elif selected_ui == "null":
log.info("Starting NullUI..")
from deluge.ui.null.deluge_shell import NullUI
ui = NullUI(args)
elif selected_ui == "console":
log.info("Starting ConsoleUI..")
from deluge.ui.console.main import ConsoleUI
ui = ConsoleUI(ui_args).run()
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.webui.webui import WebUI
ui = WebUI(args)
elif selected_ui == "console":
log.info("Starting ConsoleUI..")
from deluge.ui.console.main import ConsoleUI
ui = ConsoleUI(ui_args).run()
except ImportError:
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.")
sys.exit(0)