2012-10-03 2 views
1

테스트 자동화를위한 스크립트 작성 : Android 장치의 내부 메모리를 채우십시오. 이 스크립트는 파이썬으로 작성되었으며 monkeyrunner를 사용하여 장치에 연결하고 명령을 실행합니다.
이렇게하려면 더미 파일을 만들어야합니다. 이 명령을 사용하면 :monkeyrunner 스크립트를 통해 android에서 dd를 사용하여 더미 파일 만들기

subprocess.call('adb shell dd if=/dev/zero of=/storage/sdcard0/dummy/dummy_file bs=1000000000 count=1', shell = True) 

작동합니다. 더미 파일이 생성됩니다. 그러나 다음을 사용하고 싶습니다 :

device.shell('dd if=/dev/zero of=/storage/sdcard0/dummy/dummy_file bs=1000000000 count=1') 

같은 것을해야합니다. 그러나 후자는 작업이 생성되지 않습니다이 오류가 발생하는 이유

Importing modules 
Waiting for connection 
121003 16:54:32.383:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] Error executing command: dd if=/dev/zero of=/storage/sdcard0/dummy/dummy2 bs=1000000000 count=1 
121003 16:54:32.383:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice]com.android.ddmlib.ShellCommandUnresponsiveException 
121003 16:54:32.383:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:408) 
121003 16:54:32.383:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.ddmlib.Device.executeShellCommand(Device.java:453) 
121003 16:54:32.383:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.chimpchat.adb.AdbChimpDevice.shell(AdbChimpDevice.java:269) 
121003 16:54:32.383:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.monkeyrunner.MonkeyDevice.shell(MonkeyDevice.java:217) 
121003 16:54:32.383:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
121003 16:54:32.383:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
121003 16:54:32.383:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
121003 16:54:32.383:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at java.lang.reflect.Method.invoke(Method.java:597) 
121003 16:54:32.383:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:175) 
121003 16:54:32.383:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyObject.__call__(PyObject.java:355) 
121003 16:54:32.383:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyMethod.__call__(PyMethod.java:215) 
121003 16:54:32.383:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyMethod.instancemethod___call__(PyMethod.java:221) 
121003 16:54:32.383:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyMethod.__call__(PyMethod.java:206) 
121003 16:54:32.383:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyObject.__call__(PyObject.java:397) 
121003 16:54:32.383:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyObject.__call__(PyObject.java:401) 
121003 16:54:32.383:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.pycode._pyx0.f$0(/home/gabriel/android/git/androidqa/prebuilt/monkeyrunner/InternalStorage/int_storage_fill.py:57) 
121003 16:54:32.383:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.pycode._pyx0.call_function(/home/gabriel/android/git/androidqa/prebuilt/monkeyrunner/InternalStorage/int_storage_fill.py) 
121003 16:54:32.383:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyTableCode.call(PyTableCode.java:165) 
121003 16:54:32.383:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyCode.call(PyCode.java:18) 
121003 16:54:32.383:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.Py.runCode(Py.java:1197) 
121003 16:54:32.383:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.__builtin__.execfile_flags(__builtin__.java:538) 
121003 16:54:32.383:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:156) 
121003 16:54:32.383:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.monkeyrunner.ScriptRunner.run(ScriptRunner.java:116) 
121003 16:54:32.383:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.monkeyrunner.MonkeyRunnerStarter.run(MonkeyRunnerStarter.java:77) 
121003 16:54:32.383:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.monkeyrunner.MonkeyRunnerStarter.main(MonkeyRunnerStarter.java:189) 

아무도 알고 있나요?

답변

1

AdbChimpDevice은 셸 명령이 일정 시간 내에 완료되지 않고 dd 명령이이 제한을 초과하는 경우 TimeoutException을 생성합니다. subprocess 대안을 고수해야합니다.

기본 시간 초과는 5 초입니다.

+0

큰 파일을 쓰는데 9 초에서 40 초가 걸립니다. (1 GB) –

+1

셸 명령을 완료 할 수있는 시간을 늘릴 수있는 방법이 있습니까? –