Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
APK_NAME = "test-butler-app-1.2.0.apk"
def install_test_butler(device_id):
is_emulator = device_id.startswith("emulator")
if is_emulator:
install_cmd = "adb -s %s install -r %s" % (device_id, APK_NAME)
subprocess.Popen(install_cmd, shell=True, stdout=subprocess.PIPE).stdout.read()
print "TestButler was installed on device with id: %s" % device_id
def check_existence_file(file_to_check):
return os.path.isfile("./" + file_to_check)
def main():
output = subprocess.Popen("adb devices", shell=True, stdout=subprocess.PIPE).stdout.read()
output_splitted = output.split("\n")
for index, line in enumerate(output_splitted):
# Ignore the first line since it only contains 'List of devices'
if index > 0 and line != "":
install_test_butler(line.split("\t")[0])
if __name__ == "__main__":
is_test_butler_apk_file_available = check_existence_file(APK_NAME)
if is_test_butler_apk_file_available:
main()
sys.exit(0)
else:
print "The file %s is not available on the path" % APK_NAME
sys.exit(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment