Created
January 21, 2017 23:17
-
-
Save timrijckaert/e4f448520917e25341a6325304dd6f87 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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