Exemplo n.º 1
0
def install_importer():
    """
    If in a virtualenv then load spec files to decide which
    modules can be imported from system site-packages and
    install path hook.
    """
    logging.debug('install_importer')
    if not in_venv():
        logging.debug('No virtualenv active py:[%s]', sys.executable)
        return False

    if disable_vext:
        logging.debug('Vext disabled by environment variable')
        return False

    if GatekeeperFinder.PATH_TRIGGER not in sys.path:
        try:
            load_specs()
            sys.path.append(GatekeeperFinder.PATH_TRIGGER)
            sys.path_hooks.append(GatekeeperFinder)
        except Exception as e:
            """
            Dont kill other programmes because of a vext error
            """
            logger.info(str(e))
            if logger.getEffectiveLevel() == logging.DEBUG:
                raise

        logging.debug("importer installed")
        return True
Exemplo n.º 2
0
def install_importer():
    """
    If in a virtualenv then load spec files to decide which
    modules can be imported from system site-packages and
    install path hook.
    """
    logging.debug('install_importer')
    if not in_venv():
        logging.debug('No virtualenv active py:[%s]', sys.executable)
        return False

    if disable_vext:
        logging.debug('Vext disabled by environment variable')
        return False

    if GatekeeperFinder.PATH_TRIGGER not in sys.path:
        try:
            load_specs()
            sys.path.append(GatekeeperFinder.PATH_TRIGGER)
            sys.path_hooks.append(GatekeeperFinder)
        except Exception as e:
            """
            Dont kill other programmes because of a vext error
            """
            logger.info(str(e))
            if logger.getEffectiveLevel() == logging.DEBUG:
                raise

        logging.debug("importer installed")
        return True
def do_status():
    from vext.gatekeeper import GatekeeperFinder

    if GatekeeperFinder.PATH_TRIGGER in sys.path:
        enabled_msg = 'enabled'
    else:
        enabled_msg = 'disabled'

    if in_venv():
        print('Running in virtualenv [%s]' % enabled_msg)
    else:
        print('Not running in virtualenv [%s]' % enabled_msg)
Exemplo n.º 4
0
    def test_invenv(self):
        # Stub test, checks no exceptions are thrown.

        # TODO, fake running inside and outside an virtualenv and actually check the return value
        in_venv()
 def run():
     if not in_venv():
         print("Must run inside virtualenv to %s vext." % f.__name__)
         sys.exit(1)
     else:
         f()