From 69bbae30f9bd5bae6b72c4026ceeeeec38d7bddf Mon Sep 17 00:00:00 2001 From: keiichi-hikita Date: Thu, 16 Aug 2018 10:45:55 +0900 Subject: [PATCH] Stop using django-file-md5 Current qinling-dashboard uses django-file-md5 to calculate md5 of uploading file. But this library has no license terms, so it is better to stop using this. This commit remove those parts using above. Change-Id: Ibe79df0d9d2d583e773cef502e40d07fc3eaf6f8 Story: 2003456 Task:24716 --- qinling_dashboard/content/functions/forms.py | 4 ++-- .../test/tests/content/test_functions.py | 3 +-- qinling_dashboard/utils.py | 12 ++++++++++++ requirements.txt | 1 - 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/qinling_dashboard/content/functions/forms.py b/qinling_dashboard/content/functions/forms.py index 5b42484..8a3bf86 100644 --- a/qinling_dashboard/content/functions/forms.py +++ b/qinling_dashboard/content/functions/forms.py @@ -17,14 +17,14 @@ from django.urls import reverse from django.utils.translation import ugettext_lazy as _ -from django_file_md5 import calculate_md5 - from horizon import exceptions from horizon import forms from horizon import messages from qinling_dashboard import api +from qinling_dashboard.utils import calculate_md5 + from qinling_dashboard import validators diff --git a/qinling_dashboard/test/tests/content/test_functions.py b/qinling_dashboard/test/tests/content/test_functions.py index 126b5fe..102905f 100644 --- a/qinling_dashboard/test/tests/content/test_functions.py +++ b/qinling_dashboard/test/tests/content/test_functions.py @@ -14,8 +14,6 @@ import copy from django.core.files import uploadedfile -from django_file_md5 import calculate_md5 - from django.http import response from django.urls import reverse @@ -25,6 +23,7 @@ from django.utils.http import urlunquote from qinling_dashboard import api from qinling_dashboard.content.functions import forms as project_fm from qinling_dashboard.test import helpers as test +from qinling_dashboard.utils import calculate_md5 import mock diff --git a/qinling_dashboard/utils.py b/qinling_dashboard/utils.py index 5a70751..d5cfa0b 100644 --- a/qinling_dashboard/utils.py +++ b/qinling_dashboard/utils.py @@ -13,11 +13,23 @@ # This file is to be included for configuring application which relates # to orchestration(Heat) functions. +import hashlib import json from django.utils.translation import pgettext_lazy +def calculate_md5(target): + if not target: + return '' + + md5 = hashlib.md5() + for chunk in target.chunks(): + md5.update(chunk) + + return md5.hexdigest() + + def convert_raw_input_to_api_format(value): if value == '': return None diff --git a/requirements.txt b/requirements.txt index 8e12397..5c5d77d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,7 +8,6 @@ # # PBR should always appear first pbr!=2.1.0,>=2.0.0 # Apache-2.0 -django-file-md5>=1.0.2 python-qinlingclient>=1.1.0 # Apache-2.0 # This will be installed from git in OpenStack CI if the job setting