From cd16a26c9a0079d778e281cb3377b79cd7b3ca2c Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Tue, 3 Jan 2017 11:07:27 -0800 Subject: [PATCH] Add check_venv() to tools/diagnose script. --- tools/diagnose | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tools/diagnose b/tools/diagnose index 53a0faa003..08d6729d23 100755 --- a/tools/diagnose +++ b/tools/diagnose @@ -6,7 +6,7 @@ import platform import sys import subprocess -from typing import Callable +from typing import Callable, List TOOLS_DIR = os.path.dirname(__file__) ROOT_DIR = os.path.dirname(TOOLS_DIR) @@ -22,6 +22,11 @@ def run(check_func): if not rc: sys.exit(1) +def run_command(args): + # type: (List[str]) -> None + print(' '.join(args)) + subprocess.check_call(args) + @run def check_python_version(): # type: () -> bool @@ -80,3 +85,17 @@ def test_models(): print('Num users: ', UserProfile.objects.count()) return True +@run +def check_venv(): + # type: () -> bool + path = os.path.join(ROOT_DIR, 'scripts', 'lib', 'hash_reqs.py') + cache_dir = '/srv/zulip-venv-cache/' + for fn in ['py2_dev.txt', 'py3_dev.txt']: + requirements_file = os.path.join(ROOT_DIR, "requirements", fn) + output = subprocess.check_output([path, requirements_file], universal_newlines=True) + sha1sum = output.split()[0] + print(fn, 'venv sha: ', sha1sum) + if not os.path.exists(os.path.join(cache_dir, sha1sum)): + print('Your venv may be improperly installed!') + return False + return True