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.
source
share