Univention Bugzilla – Bug 47591
Send mails in case of errors
Last modified: 2023-06-23 13:15:50 CEST
Based on customer feedback: It should be possible for the UCS@school user import to send an email that lists all errors that occured during the last import run. This would be helpful in scenarios where the import is automated (via cronjob, e.g.).
*** This bug has been marked as a duplicate of bug 47302 ***
I'm reopening the bug because the requirements are much higher than what was done with Bug 47302: 1) some tracebacks/exceptions are not caught by the importer and therefore land directly on the command line 2) Tracebacks in hooks are usually not counted as errors and therefore do not appear in the result hook.
→ count errors in hooks + pyhooks → catch "Exception" and reraise as UcsSchoolImportFatalError → add example ResultPyHook that sends an email (UCRV address) in case of exit != 0 Btw: you can achieve that already by creating a cronjob: /usr/share/ucs-school-import/scripts/ucs-school-user-import args args > /tmp/import.log 2>&1 || uuencode /tmp/import.log | mail -s "import eror" admin@example.com
Postponed until prioritized.
(In reply to Daniel Tröder from comment #3) > → add example ResultPyHook that sends an email (UCRV address) in case of > exit != 0 That's not really possible, as the result hook runs before sys.exit :D Anyway - an example result hook, generating an email message, has been added to the ucs-school-import package: /usr/share/doc/ucs-school-import/result_hook_example.py
(In reply to Daniel Tröder from comment #5) > (In reply to Daniel Tröder from comment #3) > > → add example ResultPyHook that sends an email (UCRV address) in case of > > exit != 0 > That's not really possible, as the result hook runs before sys.exit :D What about using a with-statement and a context manager (→ that calls the resultPyHook)?
That is not necessary. The result hook has all the data to decide if the import was successful or not (len(errors)>0). The only errors that are not in 'errors' are unhandled exceptions, but that can easily be fixed.
This issue has been filed against UCS 4.3. UCS 4.3 is out of maintenance and UCS components may have vastly changed in later releases. Thus, this issue is now being closed. If this issue still occurs in newer UCS versions, please use "Clone this bug" or reopen this issue. In this case please provide detailed information on how this issue is affecting you.