Skip to content

Instantly share code, notes, and snippets.

@shauvik
Created August 25, 2014 01:30
Show Gist options
  • Save shauvik/fbce07b760b0b44620d8 to your computer and use it in GitHub Desktop.
Save shauvik/fbce07b760b0b44620d8 to your computer and use it in GitHub Desktop.
Shutdown all Android Emulators.
rm -rf /home/m3user/Desktop/dyno-droid-fse13/apps/*;
rm -rf /home/m3user/Desktop/dyno-droid-fse13/workingDir/*;
rm -rf ~/.android/avd/*;
rm -rf ~/.android/modem-nv-ram*;
python /home/m3user/Desktop/dyno-droid-fse13/shutdown_emu.py
#!/usr/bin/python
# Originally written by Aravind for Dynodroid
import shlex, subprocess,os
import sys
def checkProc(command):
print "Trying to Run Command:"+command
p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
if(p.returncode!=0):
print "\nERROR: Problem occured while trying to run command:"+command
print err
sys.exit(-1)
else:
print "Command output:"
print out
def shutdownAllEmus(command):
print "Trying to Run Command:"+command
p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
i=0
for line in p.stdout:
i += 1
if i > 1 and len(line.split()) > 1 :
checkProc('adb -s '+line.split()[0] + ' emu kill')
def argsValid(argv):
if len(argv) > 2:
if argv[1] != '-j' and argv[1] != '-s' :
return 0
if not os.path.isfile(argv[2]):
print 'Provided apk file:'+sys.argv[1]+' doesn\'t exists'
return 0
return 1
else:
return 0
shutdownAllEmus('adb devices')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment