Running Android emulator from Python-Django

def start_test(request):
    os.system('echo Starting emulator...')
    os.system('./android-sdk-linux_x86/tools/emulator -avd testavd &')
    return HttpResponse("OK")

Here is the barebone code of what I'm trying to do.
When this code is executed, the server stops responding when the emulator starts. Any help appreciated.
I am using django development server. Here is the server output:

Django version 1.1.1, using settings 'Cloust.settings'
Development server is running at http://0.0.0.0:8000/
Quit the server with CONTROL-C.
Starting emulator...
[21/Apr/2011 02:00:06] "GET /start_test/a.apk/ HTTP/1.1" 200 5
emulator: warning: opening audio output failed

emulator: emulator window was out of view and was recentred
+5
source share
5 answers

I still do not understand how to solve this problem correctly, but using subprocess.Popen allows me to execute commands on the emulator:

print 'Starting emulator...'
subprocess.Popen(['emulator', '-avd', 'testavd'])
os.system('adb wait-for-device')
os.system('Perform whatever adb commands you need')

It is worth noting that this uses the django development server, which was launched using sudo, so obviously this is far from ideal.

0
source

, ?

.

import subprocess
thread = threading.Thread(target=subprocess.popen(['./android-sdk-linux_x86/tools/emulator', '-avd', 'testavd', '&'])
thread.start()
+2

, django, , , - . Threading , .

http://code.google.com/p/django-tasks/

+1

ADB , , .
:

adb shell

su 

cp /data/local/x /data/local/y

exit

adb pull /data/local/y

, python popen os-system? ..

print 'Starting emulator...'
subprocess.Popen(['emulator', '-avd', 'testavd'])
os.system('adb wait-for-device')
os.system('Perform whatever adb commands you need')
0

, (, ).

I wanted the emulator to open before starting automation testing, and for some resonating apium, it cannot do this. in my case, I needed to add the full path to the emulator.

check_output(["/Users/{USER_NAME}/Library/Android/sdk/tools/emulator", "-avd", "Pixel_API_26"])

Hope this helps someone until appium fixes this problem.

0
source

All Articles