Univention Bugzilla – Bug 52608
Migrate ucs-school-umc-exam to Python 3
Last modified: 2021-11-29 17:20:01 CET
The package ucs-school-umc-exam 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.
Traceback (most recent call last): File "03_computerroom_endExam", line 47, in test_umc existing_rejects = get_s4_rejected() File "/usr/lib/python3/dist-packages/univention/testing/ucsschool/exam.py", line 48, in get_s4_rejected found = re.findall(r"DN:\s\w{2,4}=.*", out) File "/usr/lib/python3.7/re.py", line 223, in findall return _compile(pattern, flags).findall(string) TypeError: cannot use a string pattern on a bytes-like object
I will overtake this bug.
There is an API change in python-samba. getntacls() and setntacls() need an extra argument "session_info". Passing samba.auth.system_session() doesn't work. Currently I am getting: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/notifier/threads.py", line 80, in _run result = self._function() File "/usr/lib/python3/dist-packages/univention/management/console/modules/schoolexam/__init__.py", line 777, in _thread Instance.set_nt_acls_on_exam_folders(my.project.getRecipients()) File "/usr/lib/python3/dist-packages/univention/management/console/modules/schoolexam/__init__.py", line 257, in set_nt_acls_on_exam_folders deny_owner_change_permissions(root) File "/usr/lib/python3/dist-packages/univention/management/console/modules/schoolexam/__init__.py", line 124, in deny_owner_change_permissions dacl = getntacl(lp, filename, system_session(), direct_db_access=False) File "/usr/lib/python3/dist-packages/samba/ntacls.py", line 135, in getntacl service=service) RuntimeError: Session unix info not initialized
The error handling in the module is broken since Bug #51166 so that the progress bar never ends on an exception. This has been fixed here as well.
(In reply to Florian Best from comment #4) > There is an API change in python-samba. getntacls() and setntacls() need an > extra argument "session_info". > Passing samba.auth.system_session() doesn't work. Currently I am getting: Passing samba.auth_util.system_session_unix() causes: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/notifier/threads.py", line 80, in _run result = self._function() File "/usr/lib/python3/dist-packages/univention/management/console/modules/schoolexam/__init__.py", line 777, in _thread Instance.set_nt_acls_on_exam_folders(my.project.getRecipients()) File "/usr/lib/python3/dist-packages/univention/management/console/modules/schoolexam/__init__.py", line 257, in set_nt_acls_on_exam_folders deny_owner_change_permissions(root) File "/usr/lib/python3/dist-packages/univention/management/console/modules/schoolexam/__init__.py", line 124, in deny_owner_change_permissions dacl = getntacl(lp, filename, system_session_unix(), direct_db_access=False) File "/usr/lib/python3/dist-packages/samba/ntacls.py", line 135, in getntacl service=service) samba.NTSTATUSError: (3221225506, '{Access Denied} A process has requested access to an object but has not been granted those access rights.')
The exam module and the exam-master module have been migrated to Python 3. ucs-school-umc-exam (10.0.1) 76779b4fad1b | Bug #52608: [ucs-school-umc-exam] migrate to Python 3 * Fix error handling when starting and stopping exams: * Revert git:cc1a2118dd55e315489160b13d4db4983723be58 Bug #51166. → It let the UMC module process crash and the progress bar hangs forever. A thread finish callback must never raise an exception. * The new behavior aborts the progress bar correctly, so that the error message is shown in the eror page of the exam mode. * Additionally a traceback dialog pops up. * Additionally the traceback is logged into /var/log/univention/management-console-web-server.log. * Adjust to API change in python-samba (In reply to Florian Best from comment #6) > (In reply to Florian Best from comment #4) > > There is an API change in python-samba. getntacls() and setntacls() need an > > extra argument "session_info". > > Passing samba.auth.system_session() doesn't work. Currently I am getting: > > Passing samba.auth_util.system_session_unix() causes: > samba.NTSTATUSError: (3221225506, '{Access Denied} A process has requested > access to an object but has not been granted those access rights.') Calling the following prevents this: + s3conf = param.get_context() + s3conf.load(lp.configfile) → This is how get_local_domain_sid() from /usr/lib/python3/dist-packages/samba/netcmd/ntacl.py does it.
The following test cases are currently failing: 90_ucsschool.101_exam_prepare 90_ucsschool.101_exam_mode_home_directories_permissions 90_ucsschool.101_exam_mode_filename_problems.test_exam_mode_filename_problems 90_ucsschool.101_exam_mode
(In reply to Florian Best from comment #8) > The following test cases are currently failing: > > 90_ucsschool.101_exam_mode_filename_problems. > test_exam_mode_filename_problems → interim problem in Py3 migration of the test case. fixed. > 90_ucsschool.101_exam_prepare > 90_ucsschool.101_exam_mode looks like Bug #53579, already in 4.4 present. > 90_ucsschool.101_exam_mode_home_directories_permissions TODO: investigate the reason.
(In reply to Florian Best from comment #9) > (In reply to Florian Best from comment #8) > > The following test cases are currently failing: > > > > 90_ucsschool.101_exam_mode_filename_problems. > > test_exam_mode_filename_problems > → interim problem in Py3 migration of the test case. fixed. > > > 90_ucsschool.101_exam_prepare > > 90_ucsschool.101_exam_mode > looks like Bug #53579, already in 4.4 present. Fixed via Bug #53579 > > 90_ucsschool.101_exam_mode_home_directories_permissions > TODO: investigate the reason. This has to do with UCS 5.0 adjustments of univention-skel. I will open a new bug for this.
OK - is python3 OK - (simple) exam mode manual test OK - exam_mode tests (except 101_exam_mode_home_directories_permissions.py, as mentioned in comment #10)
(In reply to Felix Botner from comment #11) > OK - exam_mode tests (except 101_exam_mode_home_directories_permissions.py, > as mentioned in comment #10) → Bug #53640
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.