Commit eaa4b3ef by Julian Arni

Pep8 and pylint fixes

parent d991595e
......@@ -2,12 +2,7 @@
Unit tests for the asset upload endpoint.
"""
import os
import json
import shutil
import tarfile
import tempfile
from subprocess import call
from datetime import datetime
from io import BytesIO
from pytz import UTC
......
......@@ -38,8 +38,6 @@ from util.json_request import JsonResponse
__all__ = ['asset_index', 'upload_asset']
MAX_UP_LENGTH = 20000352 # Max chunk size
# Regex to capture Content-Range header ranges.
CONTENT_RE = re.compile(r"(?P<start>\d{1,11})-(?P<stop>\d{1,11})/(?P<end>\d{1,11})")
......
......@@ -63,7 +63,7 @@ def import_course(request, org, course, name):
filename = request.FILES['course-data'].name
if not filename.endswith('.tar.gz'):
return JsonResponse(
{ 'ErrMsg': 'We only support uploading a .tar.gz file.' },
{'ErrMsg': 'We only support uploading a .tar.gz file.'},
status=415
)
temp_filepath = course_dir / filename
......@@ -96,11 +96,10 @@ def import_course(request, org, course, name):
content_range['start']
)
return JsonResponse(
{ 'ErrMsg': 'File upload corrupted. Please try again' },
{'ErrMsg': 'File upload corrupted. Please try again'},
status=409
)
with open(temp_filepath, mode) as temp_file:
for chunk in request.FILES['course-data'].chunks():
temp_file.write(chunk)
......@@ -167,7 +166,7 @@ def import_course(request, org, course, name):
if not dirpath:
return JsonResponse(
{'ErrMsg': 'Could not find the course.xml file in the package.' },
{'ErrMsg': 'Could not find the course.xml file in the package.'},
status=415
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment