#!/usr/bin/python
#-*- coding: utf-8 -*-

from setuphelpers import *

def install():

    # Uninstalling older major versions of the software
    for to_uninstall in installed_softwares(uninstallkey="Citrix XenCenter"):
        if Version(to_uninstall["version"], 3) < Version(control.get_software_version(), 3) or force:
            print("Removing: %s (%s)" % (to_uninstall["name"], to_uninstall["version"]))
            killalltasks(ensure_list(control.impacted_process))
            run(uninstall_cmd(to_uninstall["key"]))
            wait_uninstallkey_absent(to_uninstall["key"])

    bin_name = glob.glob('XenCenter*.msi')[0]
    install_msi_if_needed(bin_name)
