-1

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:

  1. 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
  2. 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?

sheikh
  • 1

1 Answers1

0

This do nothing to do with celery, it does the matter that how to get output of get output of os.system.
Just get output in celery.task.updateServerByID following [python-how-to-get-stdout-after-running-os-system](Python: How to get stdout after running os.system?

Community
  • 1
  • 1
Cheney
  • 960
  • 8
  • 23
  • First of all thanks, but using this code, python won't wait until the command finished somehow... – sheikh May 09 '17 at 07:37