misc: remove requirement on python-magic
Python package changed between python3 and python2 on Debian (python-magic is the pypi package python-magic, but python3-magic is the pypi package file-magic :/)
This commit is contained in:
parent
0a4fa6b6fe
commit
8dc42017ed
1
setup.py
1
setup.py
|
@ -107,7 +107,6 @@ setup(
|
||||||
install_requires=[
|
install_requires=[
|
||||||
'authentic2',
|
'authentic2',
|
||||||
'Pillow',
|
'Pillow',
|
||||||
'python-magic',
|
|
||||||
'sorl-thumbnail',
|
'sorl-thumbnail',
|
||||||
],
|
],
|
||||||
entry_points={
|
entry_points={
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
import magic
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from django.core.files.base import ContentFile
|
from django.core.files.base import ContentFile
|
||||||
|
@ -36,7 +35,7 @@ from django_filters.rest_framework import FilterSet
|
||||||
from authentic2_idp_oidc.utils import make_pairwise_reversible_sub
|
from authentic2_idp_oidc.utils import make_pairwise_reversible_sub
|
||||||
from authentic2 import api_views
|
from authentic2 import api_views
|
||||||
|
|
||||||
from . import models
|
from . import models, utils
|
||||||
|
|
||||||
|
|
||||||
class Base64ImageField(serializers.FileField):
|
class Base64ImageField(serializers.FileField):
|
||||||
|
@ -128,7 +127,7 @@ def validate_cut(self, request, uuid):
|
||||||
'max-size': max_size,
|
'max-size': max_size,
|
||||||
})
|
})
|
||||||
accepted_mime_types = _get_cut_validation_accepted_mime_types()
|
accepted_mime_types = _get_cut_validation_accepted_mime_types()
|
||||||
mime_type = magic.from_buffer(content.read(10000), mime=True)
|
mime_type = utils.mime_type_from_buffer(content.read(10000))
|
||||||
if mime_type not in accepted_mime_types:
|
if mime_type not in accepted_mime_types:
|
||||||
errors.append({
|
errors.append({
|
||||||
'code': 'justificatifs-bad-format',
|
'code': 'justificatifs-bad-format',
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import magic
|
||||||
|
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
from django_rbac.utils import get_ou_model, get_role_model, get_operation, get_permission_model
|
from django_rbac.utils import get_ou_model, get_role_model, get_operation, get_permission_model
|
||||||
|
@ -239,3 +241,10 @@ def update_roles():
|
||||||
handle_ou(ou_territoire, **vars())
|
handle_ou(ou_territoire, **vars())
|
||||||
for ou in OU.objects.exclude(slug__in=['usagers', 'territoire']):
|
for ou in OU.objects.exclude(slug__in=['usagers', 'territoire']):
|
||||||
handle_ou(**vars())
|
handle_ou(**vars())
|
||||||
|
|
||||||
|
|
||||||
|
def mime_type_from_buffer(buf):
|
||||||
|
if hasattr(magic, 'from_buffer'):
|
||||||
|
return magic.from_buffer(buf, mime=True)
|
||||||
|
else:
|
||||||
|
return magic.detect_from_content(buf).mime_type
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import magic
|
|
||||||
from contextlib import closing
|
from contextlib import closing
|
||||||
|
|
||||||
from django.utils.timezone import now
|
from django.utils.timezone import now
|
||||||
|
@ -34,7 +33,7 @@ from authentic2 import hooks
|
||||||
from authentic2.utils import redirect
|
from authentic2.utils import redirect
|
||||||
|
|
||||||
from .custom_settings import CORE_ATTRIBUTES
|
from .custom_settings import CORE_ATTRIBUTES
|
||||||
from . import models, forms, tables
|
from . import models, forms, tables, utils
|
||||||
|
|
||||||
|
|
||||||
class EditCoreView(EditProfile):
|
class EditCoreView(EditProfile):
|
||||||
|
@ -272,7 +271,7 @@ def validation_attachment(request, pk, filename):
|
||||||
raise PermissionDenied
|
raise PermissionDenied
|
||||||
attachment = models.ValidationRequestAttachment.objects.get(pk=pk)
|
attachment = models.ValidationRequestAttachment.objects.get(pk=pk)
|
||||||
attachment.image.open()
|
attachment.image.open()
|
||||||
mime_type = magic.from_buffer(attachment.image.read(10000), mime=True)
|
mime_type = utils.mime_type_from_buffer(attachment.image.read(10000))
|
||||||
attachment.image.open()
|
attachment.image.open()
|
||||||
return HttpResponse(attachment.image, content_type=mime_type)
|
return HttpResponse(attachment.image, content_type=mime_type)
|
||||||
|
|
||||||
|
|
2
tox.ini
2
tox.ini
|
@ -39,6 +39,8 @@ deps =
|
||||||
# dependency constraints for authentic
|
# dependency constraints for authentic
|
||||||
py2: django-appconf<1.0.4
|
py2: django-appconf<1.0.4
|
||||||
py2: django-filter<2
|
py2: django-filter<2
|
||||||
|
py2: python-magic
|
||||||
|
py3: file-magic
|
||||||
drf34: djangorestframework>=3.4,<3.4.1
|
drf34: djangorestframework>=3.4,<3.4.1
|
||||||
drf39: djangorestframework>=3.9.2,<3.10
|
drf39: djangorestframework>=3.9.2,<3.10
|
||||||
dj111: django<2.0
|
dj111: django<2.0
|
||||||
|
|
Loading…
Reference in New Issue