Bug 56998 - Simple UDM API: SambaLogonHoursPropertyEncoder raises TypeError: tuple indicies must be integers or slices, not float
Simple UDM API: SambaLogonHoursPropertyEncoder raises TypeError: tuple indici...
Status: VERIFIED DUPLICATE of bug 28496
Product: UCS
Classification: Unclassified
Component: UDM (Generic)
UCS 5.0
Other Linux
: P5 normal (vote)
: ---
Assigned To: UMC maintainers
UMC maintainers
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2024-01-22 12:49 CET by Christina Scheinig
Modified: 2024-03-01 09:45 CET (History)
1 user (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 3: Simply Wrong: The implementation doesn't match the docu
Who will be affected by this bug?: 1: Will affect a very few installed domains
How will those affected feel about the bug?: 3: A User would likely not purchase the product
User Pain: 0.051
Enterprise Customer affected?: Yes
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number: 2024012221000355
Bug group (optional):
Max CVSS v3 score:
scheinig: Patch_Available+


Attachments
Traceback from customer (37.52 KB, image/png)
2024-01-22 12:49 CET, Christina Scheinig
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christina Scheinig univentionstaff 2024-01-22 12:49:31 CET
Created attachment 11178 [details]
Traceback from customer

The customer gets the attached traceback adjusting his scripts to python3 using our libaries.

In python3 the division changed. float / int now always returns float. 

A patch from Florian is this:


-----------------------------------------
diff --git management/univention-directory-manager-modules/modules/univention/udm/encoders.py management/univention-directory-manager-modules/modules/univention/udm/encoders.py
index d2199626471..e1b29109783 100644
--- management/univention-directory-manager-modules/modules/univention/udm/encoders.py
+++ management/univention-directory-manager-modules/modules/univention/udm/encoders.py
@@ -220,7 +220,7 @@ class SambaLogonHoursPropertyEncoder(BaseEncoder):
     @classmethod
     def decode(cls, value=None):
         if value:
-            return ['{} {}-{}'.format(cls._weekdays[v / 24], v % 24, v % 24 + 1) for v in value]
+            return ['{} {}-{}'.format(cls._weekdays[v // 24], v % 24, v % 24 + 1) for v in value]
         else:
             return value
Comment 1 Christina Scheinig univentionstaff 2024-01-22 13:28:02 CET
  File "get_users_without_group.py", line 8, in get_all_users
    return [user.position for user in ucs_user]
  File "get_users_without_group.py", line 8, in <listcomp>
    return [user.position for user in ucs_user]
  File "/usr/lib/python3/dist-packages/univention/udm/modules/generic.py", line 593, in search
    yield self.get(dn)
  File "/usr/lib/python3/dist-packages/univention/udm/modules/generic.py", line 557, in get
    return self._load_obj(dn)
  File "/usr/lib/python3/dist-packages/univention/udm/modules/generic.py", line 748, in _load_obj
    obj._copy_from_udm_obj()
  File "/usr/lib/python3/dist-packages/univention/udm/modules/generic.py", line 307, in _copy_from_udm_obj
    val = encoder.decode(v)
  File "/usr/lib/python3/dist-packages/univention/udm/encoders.py", line 223, in decode
    return ['{} {}-{}'.format(cls._weekdays[v / 24], v % 24, v % 24 + 1) for v in value]
  File "/usr/lib/python3/dist-packages/univention/udm/encoders.py", line 223, in <listcomp>
    return ['{} {}-{}'.format(cls._weekdays[v / 24], v % 24, v % 24 + 1) for v in value]
Comment 2 Florian Best univentionstaff 2024-02-06 10:30:23 CET
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/univention/udm/modules/generic.py", line 593, in search
    yield self.get(dn)
  File "/usr/lib/python3/dist-packages/univention/udm/modules/generic.py", line 557, in get
    return self._load_obj(dn)
  File "/usr/lib/python3/dist-packages/univention/udm/modules/generic.py", line 748, in _load_obj
    obj._copy_from_udm_obj()
  File "/usr/lib/python3/dist-packages/univention/udm/modules/generic.py", line 307, in _copy_from_udm_obj
    val = encoder.decode(v)
  File "/usr/lib/python3/dist-packages/univention/udm/encoders.py", line 223, in decode
    return ['{} {}-{}'.format(cls._weekdays[v / 24], v % 24, v % 24 + 1) for v in value]
  File "/usr/lib/python3/dist-packages/univention/udm/encoders.py", line 223, in <listcomp>
    return ['{} {}-{}'.format(cls._weekdays[v / 24], v % 24, v % 24 + 1) for v in value]
TypeError: tuple indicies must be integers or slices, not float
Comment 3 Florian Best univentionstaff 2024-02-28 21:18:04 CET

*** This bug has been marked as a duplicate of bug 28496 ***