msticpy/nbtools/azure_ml_tools.py
def _check_nb_check_ver():
    """Check the version of nb_check and optionally update."""
    nb_check_path = "utils/nb_check.py"
    gh_file = ""
    curr_file = ""
    try:
        # Bandit warning - fixed https URL
        with request.urlopen(NB_CHECK_URI) as gh_fh:  # nosec
            gh_file = gh_fh.read().decode("utf-8")
    except Exception:
        _disp_html(f"Warning could not check version of {NB_CHECK_URI}")
        return True
    nbc_path = get_aml_user_folder().joinpath(nb_check_path)
    if nbc_path.is_file():
        try:
            curr_file = nbc_path.read_text()
        except Exception:
            _disp_html(f"Warning could not check version local {nb_check_path}")

    if _get_file_ver(gh_file) == _get_file_ver(curr_file):
        return True

    _disp_html("Updating local {nb_check_path}...")
    bk_up = get_aml_user_folder().joinpath(f"{nb_check_path}._save_")
    if bk_up.is_file():
        bk_up.unlink()
    nbc_path.replace(bk_up)
    try:
        with open(nbc_path, "w") as repl_fh:
            repl_fh.write(gh_file)
    except Exception:
        bk_up.replace(nbc_path)

    _disp_html(
        "<h4><font color='orange'>"
        f"Important: The version of {nb_check_path} has been updated.<br>"
        "Please re-run this cell to run the new version."
        "</font></h4>"
    )
    return False
Check the version of nb_check and optionally update.
Check the version of nb_check and optionally update.
Check the version of nb_check and optionally update .
def _check_nb_check_ver():
    nb_check_path = "utils/nb_check.py"
    gh_file = ""
    curr_file = ""
    try:
        with request.urlopen(NB_CHECK_URI) as gh_fh:  
            gh_file = gh_fh.read().decode("utf-8")
    except Exception:
        _disp_html(f"Warning could not check version of {NB_CHECK_URI}")
        return True
    nbc_path = get_aml_user_folder().joinpath(nb_check_path)
    if nbc_path.is_file():
        try:
            curr_file = nbc_path.read_text()
        except Exception:
            _disp_html(f"Warning could not check version local {nb_check_path}")
    if _get_file_ver(gh_file) == _get_file_ver(curr_file):
        return True
    _disp_html("Updating local {nb_check_path}...")
    bk_up = get_aml_user_folder().joinpath(f"{nb_check_path}._save_")
    if bk_up.is_file():
        bk_up.unlink()
    nbc_path.replace(bk_up)
    try:
        with open(nbc_path, "w") as repl_fh:
            repl_fh.write(gh_file)
    except Exception:
        bk_up.replace(nbc_path)
    _disp_html(
        "<h4><font color='orange'>"
        f"Important: The version of {nb_check_path} has been updated.<br>"
        "Please re-run this cell to run the new version."
        "</font></h4>"
    )
    return False
def _check_nb_check_ver ( ) : nb_check_path = "utils/nb_check.py" gh_file = "" curr_file = "" try : with request . urlopen ( NB_CHECK_URI ) as gh_fh : gh_file = gh_fh . read ( ) . decode ( "utf-8" ) except Exception : _disp_html ( f"Warning could not check version of {NB_CHECK_URI}" ) return True nbc_path = get_aml_user_folder ( ) . joinpath ( nb_check_path ) if nbc_path . is_file ( ) : try : curr_file = nbc_path . read_text ( ) except Exception : _disp_html ( f"Warning could not check version local {nb_check_path}" ) if _get_file_ver ( gh_file ) == _get_file_ver ( curr_file ) : return True _disp_html ( "Updating local {nb_check_path}..." ) bk_up = get_aml_user_folder ( ) . joinpath ( f"{nb_check_path}._save_" ) if bk_up . is_file ( ) : bk_up . unlink ( ) nbc_path . replace ( bk_up ) try : with open ( nbc_path , "w" ) as repl_fh : repl_fh . write ( gh_file ) except Exception : bk_up . replace ( nbc_path ) _disp_html ( "<h4><font color='orange'>" f"Important: The version of {nb_check_path} has been updated.<br>" "Please re-run this cell to run the new version." "</font></h4>" ) return False
Check the version of nb_check and optionally update.
Check the version of nb_check and optionally update .
"""Check the version of nb_check and optionally update.""" # Bandit warning - fixed https URL # nosec