# -*- coding: utf-8 -*-
from setuphelpers import *
import bs4 as BeautifulSoup




def install():
    # Declaring local variables
    bin_name = glob.glob("*Intel-Driver-and-Support-Assistant-Installer*.exe")[0]

    # Uninstalling the software on forced install
    for uninstall in installed_softwares("Intel Driver & Support Assistant"):
        if force:
            for uninstall in installed_softwares(name="Intel® Driver & Support Assistant"):
                print("Uninstalling: %s" % uninstall["name"])
                run(uninstall_cmd(uninstall["key"]))
            break

    # Installing the software
    print("Installing: %s" % bin_name)
    install_exe_if_needed(
        bin_name,
        silentflags="-s -norestart",
        # key=app_uninstallkey,
        min_version=control.get_software_version(),
        keywords="Intel Driver & Support Assistant",
    )

    # Disabling auto-update check and telemetry and autorun
    registry_set(HKEY_LOCAL_MACHINE, r"SOFTWARE\Intel\Driver and Support Assistant\Settings", "NotificationFrequency", "0")
    registry_set(HKEY_LOCAL_MACHINE, r"SOFTWARE\Intel\SUR\ICIP", "Consent", 0)
    registry_delete(HKEY_LOCAL_MACHINE, r"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run", "Intel Driver & Support Assistant")


def uninstall():
    # Uninstalling the software
    for uninstall in installed_softwares(name="Intel® Driver & Support Assistant"):
        print("Uninstalling: %s" % uninstall["name"])
        run(uninstall_cmd(uninstall["key"]))