Reputation: 8495
I am running the following function in python where a user is prompted for a password and the an os.system command is run with the password as an argument :
password = raw_input("Please enter keystore password\n")
gradle_command = "./gradlew assemble" + flavor_name + "release -Pprop=\"['" + password + "']\""
try:
os.chdir("../")
os.system(gradle_command)
except OSError:
sys.exit("Error building apk,")
The problem is that the except never gets called. If the user types in the wrong password the gradle command executes and prints BUILD FAILED.
What i want to know is how i can register that the build has failed to exit the script accordingly. is there a way i can grab the BUILD_FAILED printed value?
Thanks in advance.
Upvotes: 1
Views: 66
Reputation: 8495
Figured it out. A failed gradle execution will return a non zero number so i can do the following:
password = raw_input("Please enter keystore password\n")
gradle_command = "./gradlew assemble" + flavor_name + "release -Pprop=\"['" + password + "']\""
if os.system(gradle_command) is not 0:
sys.exit("Error building apk")
Upvotes: 1