diff --git a/requirements/dev.txt b/requirements/dev.txt index b51613e95c..ca4e20d99c 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -3,6 +3,9 @@ -r moto.txt -r py3k.txt +# Needed for running tools/run-dev.py +-r twisted.txt + # Needed to compute test coverage coverage==4.2 diff --git a/requirements/py2_dev.txt b/requirements/py2_dev.txt index b93566ed5e..a4199d84a6 100644 --- a/requirements/py2_dev.txt +++ b/requirements/py2_dev.txt @@ -1,5 +1,2 @@ -r py2_common.txt -r dev.txt - -# Needed for running tools/run-dev.py --r twisted.txt diff --git a/tools/run-dev.py b/tools/run-dev.py index 5ffaa0c204..437b596e0f 100755 --- a/tools/run-dev.py +++ b/tools/run-dev.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python from __future__ import print_function import optparse @@ -11,17 +11,6 @@ import os if False: from typing import Any -# find out python version -major_version = int(subprocess.check_output(['python', '-c', 'import sys; print(sys.version_info[0])'])) -if major_version != 2: - # use twisted from its python2 venv but use django, tornado, etc. from the python3 venv. - PATH = os.environ["PATH"] - activate_this = "/srv/zulip-venv/bin/activate_this.py" - if not os.path.exists(activate_this): - activate_this = "/srv/zulip-py2-twisted-venv/bin/activate_this.py" - exec(open(activate_this).read(), {}, dict(__file__=activate_this)) # type: ignore # https://github.com/python/mypy/issues/1577 - os.environ["PATH"] = PATH - from twisted.internet import reactor from twisted.web import proxy, server, resource @@ -139,23 +128,22 @@ for cmd in cmds: class Resource(resource.Resource): def getChild(self, name, request): - # type: (str, server.Request) -> resource.Resource + # type: (bytes, server.Request) -> resource.Resource # Assume an HTTP 1.1 request proxy_host = request.requestHeaders.getRawHeaders('Host') request.requestHeaders.setRawHeaders('X-Forwarded-Host', proxy_host) + if (request.uri in [b'/json/get_events'] or + request.uri.startswith(b'/json/events') or + request.uri.startswith(b'/api/v1/events') or + request.uri.startswith(b'/sockjs')): + return proxy.ReverseProxyResource('127.0.0.1', tornado_port, b'/' + name) - if (request.uri in ['/json/get_events'] or - request.uri.startswith('/json/events') or - request.uri.startswith('/api/v1/events') or - request.uri.startswith('/sockjs')): - return proxy.ReverseProxyResource('127.0.0.1', tornado_port, '/'+name) + elif (request.uri.startswith(b'/webpack') or + request.uri.startswith(b'/socket.io')): + return proxy.ReverseProxyResource('127.0.0.1', webpack_port, b'/' + name) - elif (request.uri.startswith('/webpack') or - request.uri.startswith('/socket.io')): - return proxy.ReverseProxyResource('127.0.0.1', webpack_port, '/'+name) - - return proxy.ReverseProxyResource('127.0.0.1', django_port, '/'+name) + return proxy.ReverseProxyResource('127.0.0.1', django_port, b'/'+name) # log which services/ports will be started