Merge pull request #245 from matrix-org/erikj/configurable_client_location
Allow specifying a directory to host a web client from
This commit is contained in:
commit
747535f20f
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
sys.dont_write_bytecode = True
|
sys.dont_write_bytecode = True
|
||||||
from synapse.python_dependencies import check_requirements
|
from synapse.python_dependencies import check_requirements, DEPENDENCY_LINKS
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
check_requirements()
|
check_requirements()
|
||||||
|
@ -97,9 +97,25 @@ class SynapseHomeServer(HomeServer):
|
||||||
return JsonResource(self)
|
return JsonResource(self)
|
||||||
|
|
||||||
def build_resource_for_web_client(self):
|
def build_resource_for_web_client(self):
|
||||||
import syweb
|
webclient_path = self.get_config().web_client_location
|
||||||
syweb_path = os.path.dirname(syweb.__file__)
|
if not webclient_path:
|
||||||
webclient_path = os.path.join(syweb_path, "webclient")
|
try:
|
||||||
|
import syweb
|
||||||
|
except ImportError:
|
||||||
|
quit_with_error(
|
||||||
|
"Could not find a webclient.\n\n"
|
||||||
|
"Please either install the matrix-angular-sdk or configure\n"
|
||||||
|
"the location of the source to serve via the configuration\n"
|
||||||
|
"option `web_client_location`\n\n"
|
||||||
|
"To install the `matrix-angular-sdk` via pip, run:\n\n"
|
||||||
|
" pip install '%(dep)s'\n"
|
||||||
|
"\n"
|
||||||
|
"You can also disable hosting of the webclient via the\n"
|
||||||
|
"configuration option `web_client`\n"
|
||||||
|
% {"dep": DEPENDENCY_LINKS["matrix-angular-sdk"]}
|
||||||
|
)
|
||||||
|
syweb_path = os.path.dirname(syweb.__file__)
|
||||||
|
webclient_path = os.path.join(syweb_path, "webclient")
|
||||||
# GZip is disabled here due to
|
# GZip is disabled here due to
|
||||||
# https://twistedmatrix.com/trac/ticket/7678
|
# https://twistedmatrix.com/trac/ticket/7678
|
||||||
# (It can stay enabled for the API resources: they call
|
# (It can stay enabled for the API resources: they call
|
||||||
|
@ -259,11 +275,10 @@ class SynapseHomeServer(HomeServer):
|
||||||
|
|
||||||
def quit_with_error(error_string):
|
def quit_with_error(error_string):
|
||||||
message_lines = error_string.split("\n")
|
message_lines = error_string.split("\n")
|
||||||
line_length = max([len(l) for l in message_lines]) + 2
|
line_length = max([len(l) for l in message_lines if len(l) < 80]) + 2
|
||||||
sys.stderr.write("*" * line_length + '\n')
|
sys.stderr.write("*" * line_length + '\n')
|
||||||
for line in message_lines:
|
for line in message_lines:
|
||||||
if line.strip():
|
sys.stderr.write(" %s\n" % (line.rstrip(),))
|
||||||
sys.stderr.write(" %s\n" % (line.strip(),))
|
|
||||||
sys.stderr.write("*" * line_length + '\n')
|
sys.stderr.write("*" * line_length + '\n')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ class ServerConfig(Config):
|
||||||
self.server_name = config["server_name"]
|
self.server_name = config["server_name"]
|
||||||
self.pid_file = self.abspath(config.get("pid_file"))
|
self.pid_file = self.abspath(config.get("pid_file"))
|
||||||
self.web_client = config["web_client"]
|
self.web_client = config["web_client"]
|
||||||
|
self.web_client_location = config.get("web_client_location", None)
|
||||||
self.soft_file_limit = config["soft_file_limit"]
|
self.soft_file_limit = config["soft_file_limit"]
|
||||||
self.daemonize = config.get("daemonize")
|
self.daemonize = config.get("daemonize")
|
||||||
self.print_pidfile = config.get("print_pidfile")
|
self.print_pidfile = config.get("print_pidfile")
|
||||||
|
|
|
@ -43,8 +43,8 @@ CONDITIONAL_REQUIREMENTS = {
|
||||||
|
|
||||||
def requirements(config=None, include_conditional=False):
|
def requirements(config=None, include_conditional=False):
|
||||||
reqs = REQUIREMENTS.copy()
|
reqs = REQUIREMENTS.copy()
|
||||||
for key, req in CONDITIONAL_REQUIREMENTS.items():
|
if include_conditional:
|
||||||
if (config and getattr(config, key)) or include_conditional:
|
for _, req in CONDITIONAL_REQUIREMENTS.items():
|
||||||
reqs.update(req)
|
reqs.update(req)
|
||||||
return reqs
|
return reqs
|
||||||
|
|
||||||
|
@ -52,18 +52,18 @@ def requirements(config=None, include_conditional=False):
|
||||||
def github_link(project, version, egg):
|
def github_link(project, version, egg):
|
||||||
return "https://github.com/%s/tarball/%s/#egg=%s" % (project, version, egg)
|
return "https://github.com/%s/tarball/%s/#egg=%s" % (project, version, egg)
|
||||||
|
|
||||||
DEPENDENCY_LINKS = [
|
DEPENDENCY_LINKS = {
|
||||||
github_link(
|
"syutil": github_link(
|
||||||
project="matrix-org/syutil",
|
project="matrix-org/syutil",
|
||||||
version="v0.0.7",
|
version="v0.0.7",
|
||||||
egg="syutil-0.0.7",
|
egg="syutil-0.0.7",
|
||||||
),
|
),
|
||||||
github_link(
|
"matrix-angular-sdk": github_link(
|
||||||
project="matrix-org/matrix-angular-sdk",
|
project="matrix-org/matrix-angular-sdk",
|
||||||
version="v0.6.6",
|
version="v0.6.6",
|
||||||
egg="matrix_angular_sdk-0.6.6",
|
egg="matrix_angular_sdk-0.6.6",
|
||||||
),
|
),
|
||||||
]
|
}
|
||||||
|
|
||||||
|
|
||||||
class MissingRequirementError(Exception):
|
class MissingRequirementError(Exception):
|
||||||
|
@ -131,7 +131,7 @@ def check_requirements(config=None):
|
||||||
def list_requirements():
|
def list_requirements():
|
||||||
result = []
|
result = []
|
||||||
linked = []
|
linked = []
|
||||||
for link in DEPENDENCY_LINKS:
|
for link in DEPENDENCY_LINKS.values():
|
||||||
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)
|
||||||
|
|
Loading…
Reference in New Issue