I am writing a script to automate a test: fill the internal memory of an Android device. The script is written in python and I am using monkeyrunner to connect to the device and issue commands.
I need to create dummy files to do this. If I use this command:
subprocess.call('adb shell dd if=/dev/zero of=/storage/sdcard0/dummy/dummy_file bs=1000000000 count=1', shell = True)
It works. The dummy file is created. But I would like to use the following:
device.shell('dd if=/dev/zero of=/storage/sdcard0/dummy/dummy_file bs=1000000000 count=1')
Which should do the same thing. But the latter does not work and generates this:
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)
Does anybody know why this error occurs?
AdbChimpDevice
generates a TimeoutException
if the shell command doesn't finish in a certain amount of time and your dd
command is exceeding this limit.
You should stick to the subprocess
alternative.
Default timeout is 5 secs.