Пример #1
0
def auto_upgrade():
    try:
        if is_conda_env():
            conda_upgrade()
        else:
            pip_upgrade()
    except Exception as e:
        floyd_logger.error(e)
Пример #2
0
def auto_upgrade():
    try:
        from floyd.cli.utils import is_conda_env
        if is_conda_env():
            conda_upgrade()
        else:
            pip_upgrade()
    except Exception as e:
        floyd_logger.error(e)
Пример #3
0
def check_cli_version():
    """
    Check if the current cli version satisfies the server requirements
    """
    should_exit = False
    server_version = VersionClient().get_cli_version()
    current_version = get_cli_version()

    if LooseVersion(current_version) < LooseVersion(
            server_version.min_version):
        print(
            "\nYour version of CLI (%s) is no longer compatible with server." %
            current_version)
        should_exit = True
    elif LooseVersion(current_version) < LooseVersion(
            server_version.latest_version):
        print("\nNew version of CLI (%s) is now available." %
              server_version.latest_version)
    else:
        return

    # new version is ready
    if should_exit and click.confirm(
            '\nDo you want to upgrade to version %s now?' %
            server_version.latest_version):
        auto_upgrade()
        sys.exit(0)
    else:
        msg_parts = []
        msg_parts.append("\nTo manually upgrade run:")
        msg_parts.append("    pip install -U floyd-cli")
        if is_conda_env():
            msg_parts.append("Or if you prefer to use conda:")
            msg_parts.append(
                "    conda install -y -c conda-forge -c floydhub floyd-cli")
        print("\n".join(msg_parts))
        print("")

    if should_exit:
        sys.exit(0)