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

uninstallkey = []

def install():
    print('Suppression des anciennes versions ou de la 2017')

    if os.path.isfile(r'C:\Program Files\Unity\Editor\Uninstall.exe'):
        run(r'"C:\Program Files\Unity\Editor\Uninstall.exe" /S')
        remove_tree(r'C:\Program Files\Unity')
    else:
        print('Unity non installe')

    if os.path.isfile(r'C:\Program Files\Unity2017\Editor\Uninstall.exe'):
        run(r'"C:\Program Files\Unity2017\Editor\Uninstall.exe" /S')
        remove_tree(r'C:\Program Files\Unity2017')
    else:
        print('2017 non installe')

    print('installation de unity')
    run(r'"UnitySetup64.exe" -UI=reduced /D=C:\Program Files\Unity2017',timeout=300)
    print('installation du composant IOS')
    run(r'"UnitySetup-ios.exe"/S /D=C:\Program Files\Unity2017',timeout=300)
    print('installation du composant Android')
    run(r'"Unity-android.exe"/S /D=C:\Program Files\Unity2017',timeout=300)
    print('installation du composant WebGL')
    run(r'"Unity-webgl.exe"/S /D=C:\Program Files\Unity2017',timeout=300)
    print('installation du composant TVOS')
    run(r'"UnitySetup-tvos.exe"/S /D=C:\Program Files\Unity2017',timeout=300)
    print('installation du composant Vuforia')
    run(r'"UnitySetup-vuforia.exe"/S /D=C:\Program Files\Unity2017',timeout=300)
    print('installation du composant UWP')
    run(r'"UnitySetup-uwp.exe"/S /D=C:\Program Files\Unity2017',timeout=300)
    print('installation du composant Standard Assets')
    run(r'"UnityStandardAssetsSetup.exe"/S /D=C:\Program Files\Unity2017',timeout=300)
    print('installation de la documentation')
    run(r'"UnityDocumentationSetup.exe"/S /D=C:\Program Files\Unity2017',timeout=300)
    print('configuration du firewall')
    run(r'"script.bat"')

def uninstall():
    print('suppression de unity')
    run(r'"C:\Program Files\Unity2017\Editor\Uninstall.exe" /S')