(cfg_dir, cli_version)
Check if the CLI has updates available via pip

    Args:
        cfg_dir     : Directory where the .update is located/created
        cli_version : Current version of the CLI
Check if the CLI has updates available via pip
Check if the CLI has updates available via pip
def _check_pip_updates(cfg_dir, cli_version):
    """Check if the CLI has updates available via pip

    Args:
        cfg_dir     : Directory where the .update is located/created
        cli_version : Current version of the CLI

    """
    logger.debug("Checking blocksat-cli updates")

    # Save the new pip verification timestamp on the cache file
    update_cache = UpdateCache(cfg_dir)
    update_cache.save()

    # Is blocksat-cli installed?
    res = subprocess.run(["pip3", "show", "blocksat-cli"],
                         stdout=subprocess.DEVNULL,
                         stderr=subprocess.DEVNULL)
    found = (res.returncode == 0)

    # If the CLI was not installed via pip, don't check updates
    if (not found):
        logger.debug("Could not find blocksat-cli installed via pip3")
        return

    # Is the CLI outdated?
    try:
        outdated_list = json.loads(
            subprocess.check_output(
                ["pip3", "list", "--outdated", "--format", "json"],
                stderr=subprocess.DEVNULL).decode())
    except subprocess.CalledProcessError:
        # Don't break if the command fails. It could be a problem on pip. For
        # example, there is a bug in which pip throws a TypeError on the "list
        # --outdated" command saying: '>' not supported between instances of
        # 'Version' and 'Version'
        logger.warning("Failed to check blocksat-cli updates.")
        return

    cli_outdated = False
    for package in outdated_list:
        if (package['name'] == "blocksat-cli"):
            cli_outdated = True
            # Save the available update on the cache file
            update_cache.save((package['version'], package['latest_version']))
            logger.debug("Update available for blocksat-cli")

    if (not cli_outdated):
        logger.debug("blocksat-cli is up-to-date")
        # Clear a potential update flag on the cache file
        update_cache.save()
def _check_pip_updates ( cfg_dir , cli_version ) : logger . debug ( "Checking blocksat-cli updates" ) # Save the new pip verification timestamp on the cache file update_cache = UpdateCache ( cfg_dir ) update_cache . save ( ) # Is blocksat-cli installed? res = subprocess . run ( [ "pip3" , "show" , "blocksat-cli" ] , stdout = subprocess . DEVNULL , stderr = subprocess . DEVNULL ) found = ( res . returncode == 0 ) # If the CLI was not installed via pip, don't check updates if ( not found ) : logger . debug ( "Could not find blocksat-cli installed via pip3" ) return # Is the CLI outdated? try : outdated_list = json . loads ( subprocess . check_output ( [ "pip3" , "list" , "--outdated" , "--format" , "json" ] , stderr = subprocess . DEVNULL ) . decode ( ) ) except subprocess . CalledProcessError : # Don't break if the command fails. It could be a problem on pip. For # example, there is a bug in which pip throws a TypeError on the "list # --outdated" command saying: '>' not supported between instances of # 'Version' and 'Version' logger . warning ( "Failed to check blocksat-cli updates." ) return cli_outdated = False for package in outdated_list : if ( package [ 'name' ] == "blocksat-cli" ) : cli_outdated = True # Save the available update on the cache file update_cache . save ( ( package [ 'version' ] , package [ 'latest_version' ] ) ) logger . debug ( "Update available for blocksat-cli" ) if ( not cli_outdated ) : logger . debug ( "blocksat-cli is up-to-date" ) # Clear a potential update flag on the cache file update_cache . save ( )