Bug 52636 - Migrate ucs-school-umc-import to Python 3
Migrate ucs-school-umc-import to Python 3
Status: CLOSED FIXED
Product: UCS@school
Classification: Unclassified
Component: General
UCS@school 5.0
Other Linux
: P5 normal (vote)
: UCS@school 5.0 v1
Assigned To: Florian Best
Julia Bremer
: interim-5
Depends on:
Blocks: 52578
  Show dependency treegraph
 
Reported: 2021-01-12 15:24 CET by Florian Best
Modified: 2021-11-29 17:20 CET (History)
1 user (show)

See Also:
What kind of report is it?: Development Internal
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?:
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 Florian Best univentionstaff 2021-01-12 15:24:54 CET
The package ucs-school-umc-import needs to be migrated to Python 3.

See: https://hutten.knut.univention.de/mediawiki/index.php/Python_3_Migration
Comment 1 Florian Best univentionstaff 2021-06-30 16:48:05 CEST
Migrated the UMC module to Python 3. It's not yet usable as python3-ucsschool-importer-http-api-client still has errors.

ucs-school-umc-import (3.0.2)
8e3716df201b | Bug #52636: migrate ucs-school-umc-import to Python 3
Comment 3 Julia Bremer univentionstaff 2021-08-23 21:18:11 CEST
I haven't found out why, but I used an import csv and uploaded it to the UMC module.
In UCS4, I get shown a progress bar and then an error (invalid import file) immediatly.

In UCS5, I don't get any progress bar and no error until it runs into a timeout. 
"A time out occurred during examining the data."

In the Network viewer I can see, that
univention/command/schoolimport/dry-run/progress is called until timeout.
I haven't found any helpful logs yet, but I'll investigate.
Comment 4 Florian Best univentionstaff 2021-08-24 23:32:38 CEST
Since Bug #47114 the error handling of the module is broken: wrong tracebacks are re-raised.

e.g.
Traceback (most recent call last):
  File "%PY2.7%/univention/management/console/base.py", line 344, in __error_handling
    six.reraise(etype, exc, etraceback)
  File "%PY2.7%/univention/management/console/base.py", line 247, in execute
    function.__func__(self, request, *args, **kwargs)
  File "%PY2.7%/univention/management/console/modules/decorators.py", line 643, in _decorated
    return function(self, request, *args, **kwargs)
  File "%PY2.7%/univention/management/console/modules/decorators.py", line 321, in _response
    result = _multi_response(self, request)
  File "%PY2.7%/univention/management/console/modules/decorators.py", line 181, in _response
    return function(self, request)
  File "%PY2.7%/univention/management/console/modules/decorators.py", line 443, in _response
    return list(function(self, iterator, *nones))
  File "%PY2.7%/univention/management/console/modules/decorators.py", line 289, in _fake_func
    yield function(self, *args)
  File "%PY2.7%/univention/management/console/modules/schoolimport/__init__.py", line 248, in poll_dry_run
    return progress.poll()
  File "%PY2.7%/univention/management/console/modules/mixins.py", line 102, in poll
    six.reraise(*self.exc_info)
  File "<string>", line 3, in reraise
TypeError: string indices must be integers

instead of:

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/notifier/threads.py", line 80, in _run
    result = self._function()
  File "/usr/lib/python2.7/dist-packages/notifier/__init__.py", line 105, in __call__
    return self._function(*tmp, **self._kwargs)
  File "/usr/lib/python2.7/dist-packages/univention/management/console/modules/schoolimport/__init__.py", line 195, in _dry_run                                                                                                               
    message = "%s\n%s" % (message, job.result.result["description"])
TypeError: string indices must be integers

Also the UMC error handling/displaying (e.g. for UMC_Error) doesn't work anymore.
but at least I am getting the above traceback and no hanging progress bar.
I would need your input data to reproduce this.
Comment 5 Florian Best univentionstaff 2021-08-25 00:26:48 CEST
The traceback above is caused by an error in the import HTTP API.
it returns a string instead of a dict in .result for URI `curl -k  https://demo_admin:univention@localhost/api/v1/imports/users/33/  | python -m json.tool`:

{
    "date_created": "2021-08-25T00:14:37.715908+02:00",
    "dryrun": true,
    "id": 33,
    "log_file": "https://localhost/api/v1/imports/users/33/logfile/",
    "password_file": "https://localhost/api/v1/imports/users/33/passwords/",
    "principal": "demo_admin",
    "result": {
        "date_done": "2021-08-25T00:14:37.944612+02:00",
        "result": "{\"description\": \"UserImportJob #33 (dry run) ended with error.\\n\\nRead users from input data: 5\\nErrors: 2\\nEntry |   User    | Error description\\n-------------------------------------\\n    0 | <No name> | source_uid or record_uid are not set (source_uid='demoschool-staff' record_uid=None).\\n    0 | <No name> | More than 0 errors.\", \"percentage\": 100, \"done\": 0, \"total\": 0}",                                                               
        "status": "SUCCESS",
        "traceback": null
    },
    "school": "https://localhost/api/v1/schools/DEMOSCHOOL/",
    "status": "Aborted",
    "summary_file": "https://localhost/api/v1/imports/users/33/summary/",
    "url": "https://localhost/api/v1/imports/users/33/",
    "user_role": "staff"
}

So it doesn't belong to this bug.
Comment 6 Julia Bremer univentionstaff 2021-08-26 11:55:25 CEST
(In reply to Julia Bremer from comment #3)
> I haven't found out why, but I used an import csv and uploaded it to the UMC
> module.
> In UCS4, I get shown a progress bar and then an error (invalid import file)
> immediatly.
> 
> In UCS5, I don't get any progress bar and no error until it runs into a
> timeout. 
> "A time out occurred during examining the data."
> 
> In the Network viewer I can see, that
> univention/command/schoolimport/dry-run/progress is called until timeout.
> I haven't found any helpful logs yet, but I'll investigate.

This is due to issues with Bug #53451.
Comment 7 Florian Best univentionstaff 2021-08-26 15:52:14 CEST
(In reply to Julia Bremer from comment #6)
> This is due to issues with Bug #53451.
Yes, therefore RESOLVED again.
Comment 8 Julia Bremer univentionstaff 2021-08-27 10:37:44 CEST
With fixes in Bug #53451:

Graphical import with incorrect file: OK, Error is shown
Graphical import with correct import file: OK works

Verified
Comment 9 Jürn Brodersen univentionstaff 2021-11-29 17:20:24 CET
UCS@school 5.0 v1 has been released.

https://docs.software-univention.de/release-notes-ucsschool-5.0v1-de.html

If this error occurs again, please clone this bug.