First of all, I don't know what's the best way to get the functionality I would like to archive in the end.
My code will do the following:
@celery.task
def updateServerByID(sevrerID):
#run update task
os.system("samplecommadn to update server by id...")
#check if the output of the console contains "Success!", if yes, end job by using "return" statement
#return
These are the two ways I think of getting the code running:
- Redirecting output of console command to a file (using python to "monitor" this file for changes and read the files content each time it's changed
- Check the output of the console command for "Success!"
All in all I think way 2 would be the most efficient, but how to read the whole console output in python? Is there any way to prevent the celery task itself from printing this content?