# -*- coding: utf-8 -*-
from setuphelpers import *


def install():
    # Declaring local variables
    package_version = control.get_software_version()
    bin_name = glob.glob("*dbeaver-ce-*.exe")[0]

    # Installing the software
    print("Installing: %s" % bin_name)
    install_exe_if_needed(
        bin_name,
        silentflags="/S /allusers",
        key="DBeaver",
        min_version=package_version,
    )

    # Adding Firewall Rules
    app_path = makepath(installed_softwares(uninstallkey="DBeaver")[0]["install_location"], "dbeaver.exe")
    remove_netfirewallrule("DBeaver")
    add_netfirewallrule("DBeaver", app_path)


def uninstall():
    # Removing Firewall Rules
    remove_netfirewallrule("DBeaver")