forked from kobotoolbox/kpi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug fixes for Celery 4.x and draft code to report e-mailing
- Loading branch information
1 parent
039fcc9
commit 4d1a868
Showing
7 changed files
with
44 additions
and
7 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
set -e | ||
source /etc/profile | ||
|
||
# Run the main Celery worker (will not process `sync_kobocat_xforms` jobs). | ||
cd "${KPI_SRC_DIR}" | ||
exec celery beat -A kobo --loglevel=info \ | ||
--logfile=${KPI_LOGS_DIR}/celery_beat.log \ | ||
--pidfile=/tmp/celery_beat.pid \ | ||
--scheduler django_celery_beat.schedulers:DatabaseScheduler |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,4 +45,31 @@ def retry_all_task(hook_logs): | |
hook_log.retry() | ||
time.sleep(0.2) | ||
|
||
return True | ||
return True | ||
|
||
|
||
@shared_task | ||
def failures_report(): | ||
""" | ||
Sends emails to owners' assets to report the submissions which failed | ||
to be sent to external endpoint by hooks | ||
:return: | ||
""" | ||
from django.utils import translation | ||
from django.core.mail import EmailMessage | ||
from django.template import Context, Template | ||
from django.template.loader import get_template | ||
|
||
#translation.activate('fr') | ||
template = get_template("reports/failures_email_body.txt") | ||
variables = {} | ||
text = template.render(Context(**variables)) | ||
|
||
msg = EmailMessage("Test", text, "[email protected]", [owner.email]) | ||
try: | ||
msg.send() | ||
except Exception as e: | ||
print("ERROR - {}".format(str(e))) | ||
return False | ||
|
||
return True |
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
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