from shutil import which
import os, sys, platform


def install_adb_fastboot_windows():
    if which('adb') is None and which('fastboot') is None:
        print('ADB/Fastboot not found. Temporarily adding to PATH...')
        os.environ['PATH'] += ';'+os.getcwd()+'\\helpers\\platform-tools\\Windows'
        os.system('C:\\Windows\\System32\\PNPUTIL.exe -i -a ' + os.getcwd(),
                  + '\\helpers\\usb_driver\\android_winusb.inf')
    else:
        print('ADB/Fastboot are installed')


def install_adb_fastboot_linux():
    if which('adb') is None and which('fastboot') is None:
        print('ADB/Fastboot not found. Temporarily adding to PATH...')
        os.environ['PATH'] += ';'+os.getcwd()+'\\helpers\\platform-tools\\Linux'
    else:
        print('ADB/Fastboot are installed')

def main():
    if platform.system() == 'Linux':
        install_adb_fastboot_linux()
    elif platform.system() == 'Windows':
        install_adb_fastboot_windows()
    else:
        print('Unsupported OS')
        sys.exit()

if __name__ == '__main__':
    main()