happysundar
2/27/2014 - 8:45 PM

check python version, virtual env presence

check python version, virtual env presence

def check_env():
    (py_major, py_minor, py_patchlevel) = platform.python_version_tuple()
    if py_major != '2' and py_minor != '7':
        exit("This script should be run in python version 2.7.X. Current version of python is %s" % platform.python_version())
    if not hasattr(sys, 'real_prefix'):
        exit("This script should be run within a virtualevn. Have you run the 'workon <virtual_env_name>' command?")