Univention Bugzilla – Bug 47302
Add pyhook after import has finished
Last modified: 2018-09-11 11:34:16 CEST
A result hook is required for the importer that gives the ability to process the results and e.g. automatically send mails to the customer in case of an error during import.
The MassImport now scans /usr/share/ucs-school-import/pyhooks/ for pyhooks that are derived from the class ResultPyHook. The hook method "user_result" is called directly after import has finished and the summary has been sent to the log. Also the signature of ImportPyHook is slightly changed. The first argument "lo" is now optional. If not passed, getAdminConnection() is called. The new object type UserImportData is passed to user_result() that contains several variables/values of the user importer: - config - dry_run - errors - added_users - modified_users - deleted_users A debug message in ucs-school-lib has also been changed. Since this is only a very minor change, the package has not been rebuilt. ucs-school-import (16.0.2-24) 42e278f2c94d | Bug #47302: add new result hook that is run after import has finished ucs-school-lib (11.0.1-16) 36329fb78a60 | Bug #47302: give more detailed debug output
* OK: adding a LDAP connection object by default to ImportPyHook * OK: use of data object (UserImportData) for a consistent API in case of future import type additions * Note: inconsistent use of docstrings and mypy annotations (we'll have to go through the entire code and fix them all some day) * Reopen: - remove empty __init__() in ResultPyHook - add example ResultPyHook to usr/share/doc/ucs-school-import/ - add simple test to ucs-test-ucsschool (see 236_import_user_check_skip_count_exception for a recent pyhook-test example)
*** Bug 47591 has been marked as a duplicate of this bug. ***
A ucs-test was added (241_import_user_result_pyhook) and the empty function removed. [4.3] 9ee482def Bug #47302: add test for ResultPyHook [4.3] 53f54f500 Bug #47302: remove empty function [4.3] b94878f1d Bug #47302: add type hints - comment-only changes [4.3] b95564acd Bug #47302: rename pyhook test file to not end in .py [4.3] 9a3fee746 Bug #47302: changelog [4.3] 6ec36ca34 Bug #47302: advisory update ucs-school-import (16.0.2-37) ucs-test-ucsschool (5.0.2-84)
I added a useful example result hook. [4.3] f07ad9ed8 Bug #47302: add example result hook [4.3] 941ff37b1 Bug #47302: advisory update ucs-school-import (16.0.2-38)
Everything else was already verified.
UCS@school 4.3 v5 has been released. https://docs.software-univention.de/changelog-ucsschool-4.3v5-de.html If this error occurs again, please clone this bug.