Here, we demonstrate submitting a job through the Python API that uses an email callback.
Warning |
---|
Do not use sys.exit() to return from the script, it will kill the supervisor thread that's running the callback process. |
Note |
---|
Note: supervisor_language_flags must contain "mail" or this callback will silently fail. |
Code Block |
---|
title | Mail callback example |
---|
linenumbers | true |
---|
language | python |
---|
|
import qb
def main():
# Set basic job properties
job = {}
job['name'] = 'cmdline with email callback'
job['prototype'] = 'cmdline'
# Set the package properties
job['package'] = {}
job['package']['cmdline'] = 'set'
# Create the email callback and set the address to send it to
# NOTE: Make sure that the Qube Supervisor has the email settings configured
job['mailaddress'] = 'yourname@your.address.com'
job['callbacks'] = [{'triggers':'done-job-self', 'language':'mail'}]
# Submit
listOfSubmittedJobs = qb.submit([job])
# Report on submit results
for job in listOfSubmittedJobs:
print job['id']
if __name__ == "__main__":
main()
sys.exit(0) |
Note |
---|
Note: supervisor_language_flags must contain "mail" or this callback will silently fail. |
Tip |
---|
See the mail_* parameters from Configuration Parameter Reference for how to both setup mail and adjust the various mail templates. |