[WebUI] Flake8 web.py

This commit is contained in:
Calum Lind 2014-03-06 19:46:08 +00:00
parent 30705d6fc9
commit 66b54d6a27

View File

@ -39,55 +39,59 @@ import deluge.common
from deluge.ui.ui import _UI, UI from deluge.ui.ui import _UI, UI
from optparse import OptionGroup from optparse import OptionGroup
class WebUI(UI): class WebUI(UI):
def __init__(self, args): def __init__(self, args):
import server import server
deluge_web = server.DelugeWeb() deluge_web = server.DelugeWeb()
deluge_web.start() deluge_web.start()
class Web(_UI): class Web(_UI):
help = """Starts the Deluge web interface""" help = """Starts the Deluge web interface"""
def __init__(self): def __init__(self):
super(Web, self).__init__("web") super(Web, self).__init__("web")
self.__server = None self.__server = None
group = OptionGroup(self.parser, "Web Options") group = OptionGroup(self.parser, "Web Options")
group.add_option("-b", "--base", dest="base", group.add_option("-b", "--base", dest="base",
help="Set the base path that the ui is running on (proxying)", help="Set the base path that the ui is running on (proxying)",
action="store", default=None) action="store", default=None)
if not (deluge.common.windows_check() or deluge.common.osx_check()): if not (deluge.common.windows_check() or deluge.common.osx_check()):
group.add_option("-d", "--do-not-daemonize", dest="donotdaemonize", group.add_option("-d", "--do-not-daemonize", dest="donotdaemonize",
help="Do not daemonize the web interface", action="store_true", default=False) help="Do not daemonize the web interface",
action="store_true", default=False)
group.add_option("-P", "--pidfile", dest="pidfile", type="str", group.add_option("-P", "--pidfile", dest="pidfile", type="str",
help="Use pidfile to store process id", help="Use pidfile to store process id",
action="store", default=None) action="store", default=None)
if not deluge.common.windows_check(): if not deluge.common.windows_check():
group.add_option("-U", "--user", dest="user", type="str", group.add_option("-U", "--user", dest="user", type="str",
help="User to switch to. Only use it when starting as root", help="User to switch to. Only use it when starting as root",
action="store", default=None) action="store", default=None)
group.add_option("-g", "--group", dest="group", type="str", group.add_option("-g", "--group", dest="group", type="str",
help="Group to switch to. Only use it when starting as root", help="Group to switch to. Only use it when starting as root",
action="store", default=None) action="store", default=None)
group.add_option("-i", "--interface", dest="interface", group.add_option("-i", "--interface", dest="interface",
type="str", help="Binds the webserver to a specific IP address", type="str", help="Binds the webserver to a specific IP address",
action="store", default=None) action="store", default=None)
group.add_option("-p", "--port", dest="port", type="int", group.add_option("-p", "--port", dest="port", type="int",
help="Sets the port to be used for the webserver", help="Sets the port to be used for the webserver",
action="store", default=None) action="store", default=None)
group.add_option("--profile", dest="profile", group.add_option("--profile", dest="profile",
help="Profile the web server code", help="Profile the web server code",
action="store_true", default=False) action="store_true", default=False)
try: try:
import OpenSSL import OpenSSL
OpenSSL.__version__
except: except:
pass pass
else: else:
group.add_option("--no-ssl", dest="ssl", action="store_false", group.add_option("--no-ssl", dest="ssl", action="store_false",
help="Forces the webserver to disable ssl", default=False) help="Forces the webserver to disable ssl", default=False)
group.add_option("--ssl", dest="ssl", action="store_true", group.add_option("--ssl", dest="ssl", action="store_true",
help="Forces the webserver to use ssl", default=False) help="Forces the webserver to use ssl", default=False)
self.parser.add_option_group(group) self.parser.add_option_group(group)
@property @property
@ -167,6 +171,7 @@ class Web(_UI):
else: else:
run_server() run_server()
def start(): def start():
web = Web() web = Web()
web.start() web.start()