import subprocess
import os


def install_path(path, type):
    cmd = """
    sshpass -p alpine pscp -l root -A -h ./ips.txt {0} /User/Downloads
    sshpass -p alpine pssh -l root -A -ih ./ips.txt "appinst /User/Downloads/playb-{1}.ipa"  
    """.format(path, type)
    subprocess.call(cmd, shell=True)
    
def install_all():
    for root, dirs, files in os.walk("/Users/mac/codes/ios/empty_topon/ipas/lux"):
        for file in files:
            full_path:str = os.path.join(root, file)
            if full_path.endswith("max.ipa"):
                install_path(full_path, "max")
            elif full_path.endswith("topon.ipa"):
                install_path(full_path, "topon")
                
                
install_all()
                