Univention Bugzilla – Bug 52609
Migrate ucs-school-import to Python 3
Last modified: 2021-11-29 17:20:31 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.
https://git.knut.univention.de/univention/ucsschool/-/merge_requests/12
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'
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
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
I will overtake this bug.
In ucs-school-import/modules/ucsschool/importer/utils/logging.py we should remove: get_logger() move_our_handlers_to_lib_logger()
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
This has already been QA'd -> verify
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.