Bug 52609 - Migrate ucs-school-import to Python 3
Migrate ucs-school-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
Tobias Wenzel
https://git.knut.univention.de/univen...
: interim-1
Depends on: 52640
Blocks: 52578 53451
  Show dependency treegraph
 
Reported: 2021-01-12 15:14 CET by Florian Best
Modified: 2021-11-29 17:20 CET (History)
2 users (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:14:04 CET
The package ucs-school-import needs to be migrated to Python 3.

See: https://hutten.knut.univention.de/mediawiki/index.php/Python_3_Migration

As the package is using python-samba, which is not available for Python 2 anymore, the package/scripts needs to be migrated to UCS@school 5.0.
Comment 3 Florian Best univentionstaff 2021-06-16 00:01:14 CEST
Traceback (most recent call last):
  File "/usr/share/ucs-school-import/scripts/import_computer", line 3858, in <module>
    import_computer()
  File "/usr/share/ucs-school-import/scripts/import_computer", line 2784, in import_computer
    print("WARNING: no netmask specified for ip address %s using %s" % (ip.ip, ip.netmask))
AttributeError: 'IPv4Network' object has no attribute 'ip'
Comment 4 Florian Best univentionstaff 2021-06-17 13:16:08 CEST
Currently missing python2 references:

35ucs-school-import.inst:               python /usr/share/ucs-school-import/scripts/migrate_ucsschool_roles --modify --all-objects || die
modules/ucsschool/http_api/import_api/models.py:# python -m ucsschool.http_api.manage makemigrations
modules/ucsschool/http_api/import_api/models.py:# python -m ucsschool.http_api.manage migrate
modules/ucsschool/importer/legacy/legacy_user_import_cmdline.py:#!/usr/bin/python2.7
modules/ucsschool/importer/reader/csv_reader.py:    Blatantly copied from docs.python.org/2/library/csv.html
usr/lib/univention-directory-listener/system/school_creation_http_api_update.py:                ["/usr/bin/python2.7", "-m", "ucsschool.http_api.manage", "updateschools", "-a"],
usr/lib/univention-directory-listener/system/school_creation_http_api_update.py:                ["/usr/bin/python2.7", "-m", "ucsschool.http_api.manage", "updateschools", "--ou", name],
usr/share/doc/ucs-school-import-http-api/source/calling-http-api.rst:        https://$(hostname -f)/api/v1/ | python -m json.tool
usr/share/doc/ucs-school-import-http-api/source/calling-http-api.rst:        https://$(hostname -f)/api/v1/schools/ | python -m json.tool
usr/share/doc/ucs-school-import-http-api/source/calling-http-api.rst:        https://$(hostname -f)/api/v1/schools/$OU/ | python -m json.tool
usr/share/doc/ucs-school-import-http-api/source/calling-http-api.rst:        https://$(hostname -f)/api/v1/imports/users/ | python -m json.tool
usr/share/doc/ucs-school-import-http-api/source/conf.py:    "python": ("https://docs.python.org/2.7/", ("/usr/share/doc/python2.7/html/objects.inv", None)),
usr/share/doc/ucs-school-import-http-api/source/import-permissions.rst: $ python -c 'ou = "SchuleEins"; username = "myteacher" \
usr/share/doc/ucs-school-import-http-api/source/overview.rst:.. [#django_config] Djangos configuration file is ``/usr/lib/python2.7/dist-packages/ucsschool/http_api/app/settings.py``. But to handle configuration files the Debian way, that 
usr/share/doc/ucs-school-import-http-api/source/overview.rst:.. [#django_routes] Requests are routed according to ``/usr/lib/python2.7/dist-packages/ucsschool/http_api/app/urls.py``.
usr/share/doc/ucs-school-import-http-api/source/test-components.rst:    $ python -m ucsschool.http_api.manage shell -c \
usr/share/doc/ucs-school-import-http-api/source/test-components.rst:        https://$(hostname -f)/api/v1/schools/ | python -m json.tool
usr/share/doc/ucs-school-import/subclassing_example.py:#    /usr/lib/python2.7/dist-packages/ucsschool/importer/default_user_import_factory.py
usr/share/doc/ucs-school-import/subclassing_example.py:# mkdir -p /usr/local/lib/python2.7/dist-packages
usr/share/doc/ucs-school-import/subclassing_example.py:# cp /usr/share/doc/ucs-school-import/subclassing_example.py /usr/local/lib/python2.7/dist-packages
usr/share/doc/ucs-school-import/subclassing_example.py:# python -c 'from subclassing_example import MyUserImport'
usr/share/doc/ucs-school-import/subclassing_example.py:# python -c 'MYCFG="/var/lib/ucs-school-import/configs/myconfig.json"; import json; cnf=json.load(open(MYCFG, "rb")); cnf["classes"]=cnf.get("classes", {}); cnf["classes"]["user_import
Comment 5 Florian Best univentionstaff 2021-06-19 01:09:30 CEST
The listener ucs-school-import/usr/lib/univention-directory-listener/system/school_creation_http_api_update.py needs to be migrated to Python 3.

It currently logs errors in /var/log/univention/listener.log:
16.06.21 13:46:04.353  LISTENER    ( WARN    ) : initializing module http_api_school_listener
16.06.21 13:46:04.353  LISTENER    ( PROCESS ) : http_api_school_listener: Syncing all schools in http api
16.06.21 13:46:06.472  LISTENER    ( PROCESS ) : http_api_school_listener: http_api says: (1, b'', b"Unknown command: 'updateschools'\nType 'manage.py help' for usage.\n")                                                                   
16.06.21 13:46:06.528  LISTENER    ( PROCESS ) : http_api_school_listener: Update school b'School1' in http api
16.06.21 13:46:07.694  LISTENER    ( PROCESS ) : http_api_school_listener: http_api says: (1, b'', b"Unknown command: 'updateschools'\nType 'manage.py help' for usage.\n")                                                                   
16.06.21 13:46:07.695  LISTENER    ( PROCESS ) : http_api_school_listener: Update school b'School2' in http api
16.06.21 13:46:08.629  LISTENER    ( PROCESS ) : http_api_school_listener: http_api says: (1, b'', b"Unknown command: 'updateschools'\nType 'manage.py help' for usage.\n")                                                                   
16.06.21 13:46:08.631  LISTENER    ( PROCESS ) : http_api_school_listener: Update school b'oldschool' in http api
16.06.21 13:46:09.540  LISTENER    ( PROCESS ) : http_api_school_listener: http_api says: (1, b'', b"Unknown command: 'updateschools'\nType 'manage.py help' for usage.\n")                                                                   
16.06.21 13:46:09.541  LISTENER    ( PROCESS ) : http_api_school_listener: Update school b'DEMOSCHOOL' in http api
16.06.21 13:46:10.483  LISTENER    ( PROCESS ) : http_api_school_listener: http_api says: (1, b'', b"Unknown command: 'updateschools'\nType 'manage.py help' for usage.\n")                                                                   
16.06.21 13:46:10.484  LISTENER    ( WARN    ) : finished initializing module http_api_school_listener with rv=0
Comment 6 Florian Best univentionstaff 2021-07-13 16:17:49 CEST
I will overtake this bug.
Comment 7 Florian Best univentionstaff 2021-07-14 04:52:37 CEST
In ucs-school-import/modules/ucsschool/importer/utils/logging.py we should remove:
get_logger()
move_our_handlers_to_lib_logger()
Comment 8 Florian Best univentionstaff 2021-09-06 10:59:42 CEST
All packages of UCS@school Import has been migrated to Python 3.
The package django-pam generated from pip with stdeb has been added to the git repository and build from there.

ucs-school-import (18.0.1)
25e88b5e36f6 | Bug #52609: [ucs-school-import] fix missing dependency to python-attr
9e810048ab1a | Bug #52609: [ucs-school-import] migrate to Python 3

django-pam (2.0.1)
dc1ca2fbd8ba | Bug #52609: source package automatically created by stdeb 0.8.5
Comment 9 Tobias Wenzel univentionstaff 2021-10-18 15:44:08 CEST
This has already been QA'd
-> verify
Comment 10 Jürn Brodersen univentionstaff 2021-11-29 17:20:31 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.