Hallo!
Ich habe gerade versucht das “Subclassing” Beispiel aus dem “UCS@school - Handbuch Import-Schnittstelle 4.4 (Kapitel 8.3)” zum Laufen zu bekommen. Leider funktioniert das nicht und ich bekomme die folgenden Fehler. Vielleicht kann hier jemand helfen?
- Fehler beim beschriebenen Test mit
# python
>>> from usernames_with_zeros import MyUsernameHandler
>>> print MyUsernameHandler(15).format_username("Anton[ALWAYSCOUNTER]")
Fehler:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/pymodules/python2.7/ucsschool/importer/utils/username_handler.py", line 392, in format_username
return self.format_name(name)
File "/usr/lib/pymodules/python2.7/ucsschool/importer/utils/username_handler.py", line 370, in format_name
without_pattern = self.remove_bad_chars(without_pattern)
File "/usr/lib/pymodules/python2.7/ucsschool/importer/utils/username_handler.py", line 316, in remove_bad_chars
if not self.allowed_chars:
File "/usr/lib/pymodules/python2.7/ucsschool/importer/utils/username_handler.py", line 294, in allowed_chars
return string.ascii_letters + string.digits + str(self.config["username"]["allowed_special_chars"])
File "/usr/lib/pymodules/python2.7/ucsschool/importer/utils/username_handler.py", line 284, in <lambda>
self.config = lazy_object_proxy.Proxy(lambda: Configuration())
File "/usr/lib/pymodules/python2.7/ucsschool/importer/configuration.py", line 164, in __new__
cls._instance = cls.__SingleConf(filenames)
File "/usr/lib/pymodules/python2.7/ucsschool/importer/configuration.py", line 144, in __init__
raise InitialisationError("Configuration not yet loaded.")
ucsschool.importer.exceptions.InitialisationError: Configuration not yet loaded.
Muss hier noch zusätzlich die Konfiguration geladen werden und dies fehlt nur in der Dokumentation?
- Bei Aufruf der Import-Script:
/usr/share/ucs-school-import/scripts/ucs-school-user-import -n -v -u student -i /var/tmp/export.csv
Fehler:
2019-04-23 14:56:28 INFO pyhooks_loader.get_hook_classes:110 Searching for hooks of type 'FormatPyHook' in: /usr/share/ucs-school-import/pyhooks...
2019-04-23 14:56:28 INFO pyhooks_loader.get_hook_classes:125 Found hook classes:
2019-04-23 14:56:28 INFO pyhooks_loader.get_hook_objects:163 Loaded hooks: {}.
2019-04-23 14:56:28 DEBUG username_handler.__init__:286 MyUsernameHandler(max_length=15, dry_run=True) storage_backend='MemoryStorageBackend'
2019-04-23 14:56:28 ERROR user_import.create_and_modify_users:212 Entry #0: Username handler transformed '' to empty username.
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.7/ucsschool/importer/mass_import/user_import.py", line 149, in create_and_modify_users
user = self.determine_add_modify_action(imported_user)
File "/usr/lib/pymodules/python2.7/ucsschool/importer/mass_import/user_import.py", line 270, in determine_add_modify_action
return self.prepare_imported_user(imported_user, None)
File "/usr/lib/pymodules/python2.7/ucsschool/importer/mass_import/user_import.py", line 249, in prepare_imported_user
imported_user.prepare_all(new_user=not old_user)
File "/usr/lib/pymodules/python2.7/ucsschool/importer/models/import_user.py", line 516, in prepare_all
self.prepare_attributes(new_user)
File "/usr/lib/pymodules/python2.7/ucsschool/importer/models/import_user.py", line 530, in prepare_attributes
self.make_username()
File "/usr/lib/pymodules/python2.7/ucsschool/importer/models/import_user.py", line 850, in make_username
self.name), self.username_scheme, self.to_dict())
EmptyFormatResultError: Username handler transformed '' to empty username.
Hier hatte ich gehofft, das Problem mit der Konfiguration zu umgehen, indem ich das über das Import-Script direkt teste, aber hier scheint das Problem im Beispielcode zu liegen, wobei der Code für mich schlüssig aussieht. Habe am Code auch noch nichts verändert…