Skip to content

Commit 9caa781

Browse files
committed
hub/views: remove Python 2 remnants and dead code
1 parent 4950060 commit 9caa781

1 file changed

Lines changed: 4 additions & 14 deletions

File tree

kobo/hub/views.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
1-
# -*- coding: utf-8 -*-
2-
1+
import json
32
import mimetypes
43
import os
5-
import six
6-
7-
try:
8-
import json
9-
except ImportError:
10-
import simplejson as json
114

125
import django.contrib.auth.views
136
from django.conf import settings
147
from django.contrib.auth import REDIRECT_FIELD_NAME, get_user_model
158
from django.core.exceptions import ImproperlyConfigured
169
from django.http import HttpResponse, HttpResponseNotFound, StreamingHttpResponse, HttpResponseForbidden
1710
from django.shortcuts import render, get_object_or_404
18-
from django.template import RequestContext
1911
from django.urls import reverse
2012
from django.views.generic import RedirectView
2113

@@ -225,17 +217,16 @@ def task_log_json(request, id, log_name):
225217
# check back soon
226218
next_poll = LOG_WATCHER_INTERVAL
227219

228-
if six.PY3:
229-
content = str(content, encoding="utf-8", errors="replace")
230220

231221
result = {
232222
"new_offset": offset + len(content),
233223
"task_finished": task.is_finished() and 1 or 0,
234224
"next_poll": next_poll,
235-
"content": content,
225+
"content": str(content, encoding="utf-8", errors="replace"),
236226
}
237227

238-
return HttpResponse(json.dumps(result), content_type="application/json")
228+
return HttpResponse(json.dumps(result).encode(),
229+
content_type="application/json")
239230

240231

241232
class LoginView(django.contrib.auth.views.LoginView):
@@ -247,7 +238,6 @@ class LogoutView(django.contrib.auth.views.LogoutView):
247238

248239

249240
def krb5login(request, redirect_field_name=REDIRECT_FIELD_NAME):
250-
#middleware = 'django.contrib.auth.middleware.RemoteUserMiddleware'
251241
middleware = 'kobo.django.auth.middleware.LimitedRemoteUserMiddleware'
252242
if middleware not in settings.MIDDLEWARE:
253243
raise ImproperlyConfigured("krb5login view requires '%s' middleware installed" % middleware)

0 commit comments

Comments
 (0)