mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-16 07:19:00 +00:00
start new ui class
This commit is contained in:
parent
0905695910
commit
b60dc2d4ca
4 changed files with 76 additions and 5 deletions
|
@ -22,6 +22,8 @@
|
||||||
# Boston, MA 02110-1301, USA.
|
# Boston, MA 02110-1301, USA.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from optparse import OptionParser, OptionGroup
|
||||||
|
import deluge.common
|
||||||
import deluge.configmanager
|
import deluge.configmanager
|
||||||
|
|
||||||
from deluge.log import LOG as log
|
from deluge.log import LOG as log
|
||||||
|
@ -30,6 +32,48 @@ DEFAULT_PREFS = {
|
||||||
"default_ui": "gtk"
|
"default_ui": "gtk"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _UI(object):
|
||||||
|
|
||||||
|
def __init__(self, name="gtk"):
|
||||||
|
log.debug("NewUI init...")
|
||||||
|
self.__name = name
|
||||||
|
|
||||||
|
usage="%prog [options] [actions]",
|
||||||
|
|
||||||
|
self.__parser = OptionParser(version=deluge.common.get_version())
|
||||||
|
|
||||||
|
group = OptionGroup(self.parser, "Common Options")
|
||||||
|
group.add_option("-c", "--config", dest="config",
|
||||||
|
help="Set the config folder location", action="store", type="str")
|
||||||
|
group.add_option("-l", "--logfile", dest="logfile",
|
||||||
|
help="Output to designated logfile instead of stdout", action="store", type="str")
|
||||||
|
group.add_option("-a", "--args", dest="args",
|
||||||
|
help="Arguments to pass to UI, -a '--option args'", action="store", type="str")
|
||||||
|
group.add_option("-L", "--loglevel", dest="loglevel",
|
||||||
|
help="Set the log level: none, info, warning, error, critical, debug", action="store", type="str")
|
||||||
|
group.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)
|
||||||
|
self.parser.add_option_group(group)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
return self.__name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def parser(self):
|
||||||
|
return self.__parser
|
||||||
|
|
||||||
|
@property
|
||||||
|
def options(self):
|
||||||
|
return self.__options
|
||||||
|
|
||||||
|
@property
|
||||||
|
def args(self):
|
||||||
|
return self._args
|
||||||
|
|
||||||
|
def start(self):
|
||||||
|
(self.__options, self.__args) = self.parser.parse_args()
|
||||||
|
|
||||||
class UI:
|
class UI:
|
||||||
def __init__(self, options, args, ui_args):
|
def __init__(self, options, args, ui_args):
|
||||||
log.debug("UI init..")
|
log.debug("UI init..")
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
from webui import start
|
|
@ -22,9 +22,32 @@
|
||||||
# Boston, MA 02110-1301, USA.
|
# Boston, MA 02110-1301, USA.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
class WebUI:
|
|
||||||
def __init__(self, args):
|
|
||||||
import server
|
import server
|
||||||
deluge_web = server.DelugeWeb()
|
from deluge.ui.ui import _UI
|
||||||
deluge_web.start()
|
from optparse import OptionGroup
|
||||||
|
|
||||||
|
class Web(_UI):
|
||||||
|
|
||||||
|
help = """Starts the Deluge web interface"""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super(Web, self).__init__()
|
||||||
|
self.__server = server.DelugeWeb()
|
||||||
|
|
||||||
|
group = OptionGroup(self.parser, "Web Options")
|
||||||
|
group.add_option("-p", "--port", dest="port", type="int",
|
||||||
|
help="Sets the port to be used for the webserver",
|
||||||
|
action="store", default=None)
|
||||||
|
self.parser.add_option_group(group)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def server(self):
|
||||||
|
return self.__server
|
||||||
|
|
||||||
|
def start(self):
|
||||||
|
super(Web, self).start()
|
||||||
|
if self.options.port: self.server.port = self.options.port
|
||||||
|
self.server.start()
|
||||||
|
|
||||||
|
web = Web()
|
||||||
|
start = web.start
|
3
setup.py
3
setup.py
|
@ -361,6 +361,9 @@ setup(
|
||||||
entry_points = """
|
entry_points = """
|
||||||
[console_scripts]
|
[console_scripts]
|
||||||
deluge = deluge.main:start_ui
|
deluge = deluge.main:start_ui
|
||||||
|
deluge-console = deluge.ui.console:start
|
||||||
|
deluge-gtk = deluge.ui.gtkui:start
|
||||||
|
deluge-web = deluge.ui.web:start
|
||||||
deluged = deluge.main:start_daemon
|
deluged = deluge.main:start_daemon
|
||||||
""",
|
""",
|
||||||
ext_package = "deluge",
|
ext_package = "deluge",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue