Files
zulip/tools/lib/sanity_check.py
sinwar 4296d608ab 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.
2017-04-05 16:51:23 -07:00

21 lines
667 B
Python

#!/usr/bin/env python
from __future__ import print_function
import os
import pwd
import sys
def check_venv(filename):
# type: (str) -> None
try:
import ujson
except ImportError:
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.")
else:
print("You can `source /srv/zulip-venv/bin/activate` to enter the Zulip development environment.")
sys.exit(1)