1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# -*- coding: utf-8 -*-
#
# Copyright (C) 2009 Damien Churchill <damoxc@gmail.com>
#
# This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with
# the additional special exception to link portions of this program with the OpenSSL library.
# See LICENSE for more details.
#
from __future__ import print_function, unicode_literals
import logging
from twisted.internet.error import CannotListenError
from deluge.common import run_profiled
from deluge.ui.ui import UI
log = logging.getLogger(__name__)
class Web(UI):
cmd_description = """Web-based user interface (http://localhost:8112)"""
def __init__(self, *args, **kwargs):
super(Web, self).__init__(
'web', *args, description='Starts the Deluge Web interface', **kwargs
)
self.__server = None
group = self.parser.add_argument_group(_('Web Server Options'))
group.add_argument(
'-i',
'--interface',
metavar='<ip_address>',
action='store',
help=_('IP address for web server to listen on'),
)
group.add_argument(
'-p',
'--port',
metavar='<port>',
type=int,
action='store',
help=_('Port for web server to listen on'),
)
group.add_argument(
'-b',
'--base',
metavar='<path>',
action='store',
help=_('Set the base path that the ui is running on'),
)
group.add_argument(
'--ssl', action='store_true', help=_('Force the web server to use SSL')
)
group.add_argument(
'--no-ssl',
action='store_true',
help=_('Force the web server to disable SSL'),
)
self.parser.add_process_arg_group()
@property
def server(self):
return self.__server
def start(self):
super(Web, self).start()
from deluge.ui.web import server
self.__server = server.DelugeWeb(options=self.options)
def run():
try:
self.server.install_signal_handlers()
self.server.start()
except CannotListenError as ex:
log.error(
'%s \nCheck that deluge-web or webui plugin is not already running.',
ex,
)
except Exception as ex:
log.exception(ex)
raise
run_profiled(
run, output_file=self.options.profile, do_profile=self.options.profile
)
|