from __future__ import print_function
import time
import os

if __name__ == '__main__':
    import argparse

    cmdlineopt = argparse.ArgumentParser( description='intall and copy the task file ')
    cmdlineopt.add_argument('-i', action="store_true", dest="installapk", default=False, help='install apk tool')

    cmdlineargs = cmdlineopt.parse_args()

    if cmdlineargs.installapk == True :
        os.system("adb install com.hipipal.qpy3_11_www.APKdler.com_.apk")
        print ("run the akpk for 10 seconds")
        time.sleep(10)


    for namedev in os.popen("adb devices") :
        namedev = namedev.strip()
        if len(namedev) == 0 :
            continue
        nameid = namedev.split()[0]
        if  not "LGD" in nameid:
            continue
        print (nameid)

        os.system("adb -s %s push emmcmain.py /sdcard/com.hipipal.qpyplus/scripts3/"%nameid)
        os.system("adb -s %s push emmctest.py /sdcard/com.hipipal.qpyplus/scripts3/"%nameid)
        os.system("adb -s %s push emmcfunc.py /sdcard/com.hipipal.qpyplus/scripts3/"%nameid)

        time.sleep(1)
