mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 06:53:25 +00:00
test_server: Improve warning in venv check.
This (1) changes test_server to use the common `check_venv` method and (2) improves check_venv to provide a clearer error message in the case that you're inside Vagrant but not in a venv. Tweaked by tabbott to borrow logic from run_dev.py.
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
|
import os
|
||||||
|
import pwd
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
def check_venv(filename):
|
def check_venv(filename):
|
||||||
@@ -9,5 +11,10 @@ def check_venv(filename):
|
|||||||
import ujson
|
import ujson
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("You need to run %s inside a Zulip dev environment." % (filename,))
|
print("You need to run %s inside a Zulip dev environment." % (filename,))
|
||||||
|
user_id = os.getuid()
|
||||||
|
user_name = pwd.getpwuid(user_id).pw_name
|
||||||
|
if user_name != 'vagrant' and user_name != 'zulipdev':
|
||||||
print("If you are using Vagrant, you can `vagrant ssh` to enter the Vagrant guest.")
|
print("If you are using Vagrant, you can `vagrant ssh` to enter the Vagrant guest.")
|
||||||
|
else:
|
||||||
|
print("You can `source /srv/zulip-venv/bin/activate` to enter the Zulip development environment.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|||||||
@@ -10,14 +10,12 @@ from contextlib import contextmanager
|
|||||||
if False:
|
if False:
|
||||||
from typing import (Any, Iterator)
|
from typing import (Any, Iterator)
|
||||||
|
|
||||||
try:
|
# Verify the Zulip venv is available.
|
||||||
import django
|
from tools.lib import sanity_check
|
||||||
import requests
|
sanity_check.check_venv(__file__)
|
||||||
except ImportError as e:
|
|
||||||
print("ImportError: {}".format(e))
|
import django
|
||||||
print("You need to run the Zulip tests inside a Zulip dev environment.")
|
import requests
|
||||||
print("If you are using Vagrant, you can `vagrant ssh` to enter the Vagrant guest.")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
TOOLS_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
TOOLS_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
if TOOLS_DIR not in sys.path:
|
if TOOLS_DIR not in sys.path:
|
||||||
|
|||||||
Reference in New Issue
Block a user