def install_mongodb(mongodb_version=None, mongodb_edition=None, from_source=False,
                    build_threads=1,
                    build_tmp_dir=None,
                    include_only=None):

    if mongodb_version is None:
        mongodb_version = fetch_latest_stable_version()
        log_info("Installing latest stable MongoDB version '%s'..." %
                 mongodb_version)

    version_info = make_version_info(mongodb_version, mongodb_edition)
    mongo_installation = get_mongo_installation(version_info)
    mongodb_edition = version_info.edition

    if mongo_installation is not None: # no-op
        log_info("You already have MongoDB %s installed ('%s'). "
                 "Nothing to do." % (version_info, mongo_installation))
        return mongo_installation

    target_dir = get_install_target_dir(mongodb_version, mongodb_edition)
    if os.path.exists(target_dir):
        raise MongoctlException("Target directory '%s' already exists" %
                                target_dir)



    if mongodb_edition not in MongoDBEdition.ALL:
        raise MongoctlException("Unknown edition '%s'. Please select from %s" %
                                (mongodb_edition, MongoDBEdition.ALL))

    if from_source:
        install_from_source(mongodb_version, mongodb_edition,
                            build_threads=build_threads,
                            build_tmp_dir=build_tmp_dir)
        return

    bits = platform.architecture()[0].replace("bit", "")
    os_name = platform.system().lower()

    if os_name == 'darwin' and platform.mac_ver():
        os_name = "osx"

    mongodb_installs_dir = config.get_mongodb_installs_dir()
    if not mongodb_installs_dir:
        raise MongoctlException("No mongoDBInstallationsDirectory configured"
                                " in mongoctl.config")

    # ensure the mongo installs dir
    ensure_dir(mongodb_installs_dir)

    platform_spec = get_validate_platform_spec(os_name, bits)

    log_verbose("INSTALL_MONGODB: OS='%s' , BITS='%s' , VERSION='%s', "
                "PLATFORM_SPEC='%s'" % (os_name, bits, version_info,
                                        platform_spec))





    # XXX LOOK OUT! Two processes installing same version simultaneously => BAD.
    # TODO: mutex to protect the following

    try:
        ## download the url
        archive_path = download_mongodb_binary(mongodb_version,
                                               mongodb_edition)
        archive_name = os.path.basename(archive_path)

        mongo_dir_name = extract_archive(archive_name)

        # apply include_only if specified
        if include_only:
            apply_include_only(mongo_dir_name, include_only)

        log_info("Deleting archive %s" % archive_name)
        os.remove(archive_name)
        target_dir_name = os.path.basename(target_dir)
        os.rename(mongo_dir_name, target_dir_name)

        # move target to mongodb install dir (Unless target is already there!
        # i.e current working dir == mongodb_installs_dir
        if os.getcwd() != mongodb_installs_dir:
            log_info(mongodb_installs_dir % "Moving extracted folder to %s")
            shutil.move(target_dir_name, mongodb_installs_dir)

        install_dir = os.path.join(mongodb_installs_dir, mongo_dir_name)
        # install validation
        validate_mongodb_install(target_dir)
        log_info("MongoDB %s installed successfully!" % version_info)
        return install_dir
    except Exception, e:
        log_exception(e)
        msg = "Failed to install MongoDB '%s'. Cause: %s" % (version_info, e)
        raise MongoctlException(msg)


###############################################################################
# install from source
###############################################################################
dataset/ETHPy150Open mongolab/mongoctl/mongoctl/commands/misc/install.py/install_mongodb/swapped operands of `%`