delay loading of "magic" module to usage (#52687)
This avoids an issue with the uwsgi spooler failing to find library symbols. File "/usr/lib/python3/dist-packages/authentic2_cut/utils.py", line 3, in <module> import magic File "/usr/lib/python3.7/ctypes/__init__.py", line 374, in __getitem__ func = self._FuncPtr((name_or_ordinal, self)) AttributeError: /usr/bin/uwsgi: undefined symbol: magic_open
This commit is contained in:
parent
8720bc6c19
commit
a3407c7208
|
@ -1,7 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import magic
|
||||
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.contrib.auth import get_user_model
|
||||
from django_rbac.utils import get_ou_model, get_role_model, get_operation, get_permission_model
|
||||
|
@ -244,6 +242,8 @@ def update_roles():
|
|||
|
||||
|
||||
def mime_type_from_buffer(buf):
|
||||
import magic
|
||||
|
||||
if hasattr(magic, 'from_buffer'):
|
||||
return magic.from_buffer(buf, mime=True)
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue