

def _main(environ, argv):
    'Logic for main(), with less direct system interaction.\n\n    Routines called here raise InvalidArgument with messages that\n    should be delivered on stderr, to be caught by main.\n    '
    options = get_options(argv)
    if options.version:
        return handle_version()
    vexrc = get_vexrc(options, environ)
    if options.shell_to_configure:
        return handle_shell_config(options.shell_to_configure, vexrc, environ)
    if (options.list is not None):
        return handle_list(vexrc.get_ve_base(environ), options.list)
    cwd = get_cwd(options)
    ve_base = vexrc.get_ve_base(environ)
    ve_name = get_virtualenv_name(options)
    command = get_command(options, vexrc, environ)
    if options.make:
        if options.path:
            make_path = os.path.abspath(options.path)
        else:
            make_path = os.path.abspath(os.path.join(ve_base, ve_name))
        handle_make(environ, options, make_path)
        ve_path = make_path
    elif options.path:
        ve_path = os.path.abspath(options.path)
        if ((not os.path.exists(ve_path)) or (not os.path.isdir(ve_path))):
            raise exceptions.InvalidVirtualenv('argument for --path is not a directory')
    else:
        try:
            ve_path = get_virtualenv_path(ve_base, ve_name)
        except exceptions.NoVirtualenvName:
            options.print_help()
            raise
    env = get_environ(environ, ve_name['env'], ve_path)
    returncode = run(command, env=env, cwd=cwd)
    if options.remove:
        handle_remove(ve_path)
    if (returncode is None):
        raise exceptions.InvalidCommand('command not found: {0!r}'.format(command[0]))
    return returncode

dataset/ETHPy150Open sashahart/vex/vex/main.py _main/VarMisuse@292/454 `vexrc`->`ve_name`