Beispiel #1
0
def pull(all_file, targetDir):
    if not os.path.exists("wk"):
        os.mkdir("wk")

    shell_cmd = "adb shell"
    cd_cmd = "cd %s" % (targetDir)
    exit_cmd = "exit"
    child_proc = syos.SelfProcess(shell_cmd, None)
    child_proc.write(cd_cmd)
    child_proc.write('\n')
    time.sleep(0.05)
    count = 0
    for f in all_file:
        #if not f.startswith("txz_"):
        #continue
        oldName = f.replace("\r\n", "")
        print oldName
        #continue

        count += 1
        newName = "new_%d.pcm" % (count)
        cp_cmd = "cp %s %s" % (oldName, newName)
        child_proc.write(cp_cmd)
        child_proc.write('\n')
        time.sleep(0.05)
        pullFile("%s/%s" % (targetDir, newName), code.gbk(oldName))
    time.sleep(0.1)
    rm_tmp_cmd = "rm new*"
    child_proc.write(rm_tmp_cmd)
    child_proc.write('\n')
    time.sleep(0.1)

    child_proc.write(exit_cmd)
    child_proc.write('\n')
    child_proc.wait()
Beispiel #2
0
def sendBroadcast(strBroadcast):
    cmd = "adb shell"
    proc_cmd = strBroadcast
    #proc_cmd = code.utf8(proc_cmd)
    proc = syos.SelfProcess(cmd, None)
    proc.disable_print()
    proc.write("%s%s" % (proc_cmd, "\n"))
    proc.write("%s%s" % ('exit', "\n"))
    proc.wait()
Beispiel #3
0
def play(strInput):
    item = 1
    cmd = "adb shell"
    proc_cmd = 'am broadcast -a com.txznet.alldemo.intent.action.cmd --es cmd %s --es text_args "%s"'%(func[item]["cmd"],strInput)
    proc_cmd = code.utf8(proc_cmd)
    proc = syos.SelfProcess(cmd, None)
    proc.disable_print()
    proc.write("%s%s"%(proc_cmd, "\n"))
    proc.write("%s%s"%('exit', "\n"))
    #time.sleep(1)
    #proc.terminate()
    proc.wait()
Beispiel #4
0
class workThread(threading.Thread):
    def __init__(self):
        threading.Thread.__init__(self)

    def run(self):
        child_proc = None
        while True:
            prompt = '>'
            if child_proc != None and child_proc.isAlive():
                prompt = ""
            try:
                pass
                strInput = raw_input(prompt)  #不包含换行符Ctrl+C会抛异常
            except Exception, e:
                print_t(str(e))
                continue

            if child_proc != None and child_proc.isAlive():
                try:
                    strInput = strInput.decode('gbk').encode(
                        'utf8')  #输入可能是utf8编码
                except Exception, e:
                    pass
                child_proc.write(strInput)
                child_proc.write('\n')
                if strInput == 'exit':
                    child_proc.wait()
                continue
            if strInput == "exit":
                break
            if strInput == "":
                continue
            if pre_process(strInput):
                continue
            try:
                child_proc = syos.SelfProcess(strInput, None)
                #proc.wait()
            except Exception, e:
                pass
                print_t(str(e))
Beispiel #5
0
        print repr(e)

    if strInput == 'exit':
        break
    item = -1
    try:
        item = int(strInput)
    except Exception,e:
        continue
    if not (item >= 0 and item < len(func)):
        continue
    while True:
        try:
            strInput = raw_input(code.gbk(func[item]["prompt"]))
        except Exception, e:
            print repr(e)

        if strInput == 'exit':
            break
        cmd = "adb shell"
        proc_cmd = 'am broadcast -a com.txznet.alldemo.intent.action.cmd --es cmd %s --es text_args "%s"'%(func[item]["cmd"],strInput)
        proc_cmd = code.utf8(proc_cmd)
        proc = syos.SelfProcess(cmd, None)
        proc.disable_print()
        proc.write("%s%s"%(proc_cmd, "\n"))
        proc.write("%s%s"%('exit', "\n"))
        #time.sleep(1)
        #proc.terminate()
        proc.wait()