Bug 47302 - Add pyhook after import has finished
Add pyhook after import has finished
Status: CLOSED FIXED
Product: UCS@school
Classification: Unclassified
Component: Import scripts
UCS@school 4.3
Other Linux
: P5 normal (vote)
: UCS@school 4.3 v5
Assigned To: Sönke Schwardt-Krummrich
Daniel Tröder
:
Depends on:
Blocks: 47591
  Show dependency treegraph
 
Reported: 2018-07-04 14:37 CEST by Sönke Schwardt-Krummrich
Modified: 2018-09-11 11:34 CEST (History)
1 user (show)

See Also:
What kind of report is it?: Feature Request
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?: Yes
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sönke Schwardt-Krummrich univentionstaff 2018-07-04 14:37:08 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.
Comment 1 Sönke Schwardt-Krummrich univentionstaff 2018-07-12 15:13:30 CEST
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
Comment 2 Daniel Tröder univentionstaff 2018-07-29 08:59:53 CEST
* 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)
Comment 3 Daniel Tröder univentionstaff 2018-08-15 10:48:15 CEST
*** Bug 47591 has been marked as a duplicate of this bug. ***
Comment 4 Daniel Tröder univentionstaff 2018-08-20 17:08:26 CEST
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)
Comment 5 Daniel Tröder univentionstaff 2018-08-20 17:58:42 CEST
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)
Comment 6 Daniel Tröder univentionstaff 2018-08-20 17:59:12 CEST
Everything else was already verified.
Comment 7 Sönke Schwardt-Krummrich univentionstaff 2018-09-11 11:34:16 CEST
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.