Wire up the webclient option

It existed but was hardcoded to True.
Give it an underscore for consistency.
Also don't pull in syweb unless we're actually using the web client.
This commit is contained in:
David Baker 2015-03-17 12:45:37 +01:00
parent 3f7a31d366
commit 7564dac8cb
3 changed files with 24 additions and 8 deletions

View File

@ -60,7 +60,6 @@ import re
import resource import resource
import subprocess import subprocess
import sqlite3 import sqlite3
import syweb
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -83,6 +82,7 @@ class SynapseHomeServer(HomeServer):
return AppServiceRestResource(self) return AppServiceRestResource(self)
def build_resource_for_web_client(self): def build_resource_for_web_client(self):
import syweb
syweb_path = os.path.dirname(syweb.__file__) syweb_path = os.path.dirname(syweb.__file__)
webclient_path = os.path.join(syweb_path, "webclient") webclient_path = os.path.join(syweb_path, "webclient")
return File(webclient_path) # TODO configurable? return File(webclient_path) # TODO configurable?
@ -130,7 +130,7 @@ class SynapseHomeServer(HomeServer):
True. True.
""" """
config = self.get_config() config = self.get_config()
web_client = config.webclient web_client = config.web_client
# list containing (path_str, Resource) e.g: # list containing (path_str, Resource) e.g:
# [ ("/aaa/bbb/cc", Resource1), ("/aaa/dummy", Resource2) ] # [ ("/aaa/bbb/cc", Resource1), ("/aaa/dummy", Resource2) ]
@ -343,7 +343,8 @@ def setup(config_options):
config.setup_logging() config.setup_logging()
check_requirements() # check any extra requirements we have now we have a config
check_requirements(config)
version_string = get_version_string() version_string = get_version_string()
@ -450,6 +451,7 @@ def run(hs):
def main(): def main():
with LoggingContext("main"): with LoggingContext("main"):
# check base requirements
check_requirements() check_requirements()
hs = setup(sys.argv[1:]) hs = setup(sys.argv[1:])
run(hs) run(hs)

View File

@ -28,7 +28,7 @@ class ServerConfig(Config):
self.unsecure_port = args.unsecure_port self.unsecure_port = args.unsecure_port
self.daemonize = args.daemonize self.daemonize = args.daemonize
self.pid_file = self.abspath(args.pid_file) self.pid_file = self.abspath(args.pid_file)
self.webclient = True self.web_client = args.web_client
self.manhole = args.manhole self.manhole = args.manhole
self.soft_file_limit = args.soft_file_limit self.soft_file_limit = args.soft_file_limit
@ -68,6 +68,8 @@ class ServerConfig(Config):
server_group.add_argument('--pid-file', default="homeserver.pid", server_group.add_argument('--pid-file', default="homeserver.pid",
help="When running as a daemon, the file to" help="When running as a daemon, the file to"
" store the pid in") " store the pid in")
server_group.add_argument('--web_client', default=True, type=bool,
help="Whether or not to serve a web client")
server_group.add_argument("--manhole", metavar="PORT", dest="manhole", server_group.add_argument("--manhole", metavar="PORT", dest="manhole",
type=int, type=int,
help="Turn on the twisted telnet manhole" help="Turn on the twisted telnet manhole"

View File

@ -5,7 +5,6 @@ logger = logging.getLogger(__name__)
REQUIREMENTS = { REQUIREMENTS = {
"syutil>=0.0.3": ["syutil"], "syutil>=0.0.3": ["syutil"],
"matrix_angular_sdk>=0.6.5": ["syweb>=0.6.5"],
"Twisted==14.0.2": ["twisted==14.0.2"], "Twisted==14.0.2": ["twisted==14.0.2"],
"service_identity>=1.0.0": ["service_identity>=1.0.0"], "service_identity>=1.0.0": ["service_identity>=1.0.0"],
"pyopenssl>=0.14": ["OpenSSL>=0.14"], "pyopenssl>=0.14": ["OpenSSL>=0.14"],
@ -18,6 +17,19 @@ REQUIREMENTS = {
"pillow": ["PIL"], "pillow": ["PIL"],
"pydenticon": ["pydenticon"], "pydenticon": ["pydenticon"],
} }
CONDITIONAL_REQUIREMENTS = {
"web_client": {
"matrix_angular_sdk>=0.6.5": ["syweb>=0.6.5"],
}
}
def requirements(config=None, include_conditional=False):
reqs = REQUIREMENTS.copy()
for key,req in CONDITIONAL_REQUIREMENTS.items():
if (config and getattr(config, key)) or include_conditional:
reqs.update(req)
return reqs
def github_link(project, version, egg): def github_link(project, version, egg):
@ -46,10 +58,10 @@ class MissingRequirementError(Exception):
pass pass
def check_requirements(): def check_requirements(config=None):
"""Checks that all the modules needed by synapse have been correctly """Checks that all the modules needed by synapse have been correctly
installed and are at the correct version""" installed and are at the correct version"""
for dependency, module_requirements in REQUIREMENTS.items(): for dependency, module_requirements in requirements(config, include_conditional=False).items():
for module_requirement in module_requirements: for module_requirement in module_requirements:
if ">=" in module_requirement: if ">=" in module_requirement:
module_name, required_version = module_requirement.split(">=") module_name, required_version = module_requirement.split(">=")
@ -110,7 +122,7 @@ def list_requirements():
egg = link.split("#egg=")[1] egg = link.split("#egg=")[1]
linked.append(egg.split('-')[0]) linked.append(egg.split('-')[0])
result.append(link) result.append(link)
for requirement in REQUIREMENTS: for requirement in requirements(include_conditional=True):
is_linked = False is_linked = False
for link in linked: for link in linked:
if requirement.replace('-', '_').startswith(link): if requirement.replace('-', '_').startswith(link):