python 3 fixes
removed pdb statement quality fixes quality fixes test fixes quality fixes python 3 fixes removed pdb statement quality fixes quality fixes test fixes quality fixes
This commit is contained in:
@@ -3,6 +3,7 @@ Computes the data to display on the Instructor Dashboard
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import decimal
|
||||
import json
|
||||
|
||||
from django.db.models import Count
|
||||
@@ -534,7 +535,7 @@ def get_students_problem_grades(request, csv=False):
|
||||
for student in students:
|
||||
percent = 0
|
||||
if student['max_grade'] > 0:
|
||||
percent = round(student['grade'] * 100 / student['max_grade'])
|
||||
percent = round(decimal.Decimal(student['grade'] * 100 / student['max_grade']), 1)
|
||||
results.append([student['student__profile__name'], student['student__username'], student['grade'], percent])
|
||||
|
||||
response = create_csv_response(filename, header, results)
|
||||
@@ -599,5 +600,5 @@ def sanitize_filename(filename):
|
||||
"""
|
||||
filename = filename.replace(" ", "_")
|
||||
filename = filename.encode('utf-8')
|
||||
filename = filename[0:25] + '.csv'
|
||||
filename = filename[0:25].decode('utf-8') + '.csv'
|
||||
return filename
|
||||
|
||||
@@ -230,7 +230,7 @@ def add_repo(repo, rdir_in, branch=None):
|
||||
|
||||
cwd = os.path.abspath(cwd)
|
||||
try:
|
||||
ret_git = cmd_log(cmd, cwd=cwd)
|
||||
ret_git = cmd_log(cmd, cwd=cwd).decode('utf-8')
|
||||
except subprocess.CalledProcessError as ex:
|
||||
log.exception(u'Error running git pull: %r', ex.output)
|
||||
raise GitImportErrorCannotPull()
|
||||
@@ -246,7 +246,7 @@ def add_repo(repo, rdir_in, branch=None):
|
||||
log.exception(u'Unable to get git log: %r', ex.output)
|
||||
raise GitImportErrorBadRepo()
|
||||
|
||||
ret_git += u'\nCommit ID: {0}'.format(commit_id)
|
||||
ret_git += u'\nCommit ID: {0}'.format(commit_id.decode('utf-8'))
|
||||
|
||||
# get branch
|
||||
cmd = ['git', 'symbolic-ref', '--short', 'HEAD', ]
|
||||
|
||||
@@ -261,7 +261,7 @@ class Courses(SysadminDashboardView):
|
||||
cmd = ['git', 'log', '-1',
|
||||
u'--format=format:{ "commit": "%H", "author": "%an %ae", "date": "%ad"}', ]
|
||||
try:
|
||||
output_json = json.loads(subprocess.check_output(cmd, cwd=gdir))
|
||||
output_json = json.loads(subprocess.check_output(cmd, cwd=gdir).decode('utf-8'))
|
||||
info = [output_json['commit'],
|
||||
output_json['date'],
|
||||
output_json['author'], ]
|
||||
|
||||
@@ -212,14 +212,13 @@ class TestSysAdminMongoCourseImport(SysadminBaseTestCase):
|
||||
response = self.client.get(reverse('gitlogs'))
|
||||
|
||||
# Check that our earlier import has a log with a link to details
|
||||
self.assertIn('/gitlogs/course-v1:MITx+edx4edx+edx4edx', response.content)
|
||||
self.assertIn('/gitlogs/course-v1:MITx+edx4edx+edx4edx', response.content.decode('utf-8'))
|
||||
|
||||
response = self.client.get(
|
||||
reverse('gitlogs_detail', kwargs={
|
||||
'course_id': 'course-v1:MITx+edx4edx+edx4edx'}))
|
||||
|
||||
self.assertIn('======> IMPORTING course',
|
||||
response.content)
|
||||
self.assertIn('======> IMPORTING course', response.content.decode('utf-8'))
|
||||
|
||||
self._rm_edx4edx()
|
||||
|
||||
@@ -285,10 +284,7 @@ class TestSysAdminMongoCourseImport(SysadminBaseTestCase):
|
||||
'course_id': 'course-v1:MITx+edx4edx+edx4edx'
|
||||
})
|
||||
)
|
||||
self.assertIn(
|
||||
'No git import logs have been recorded for this course.',
|
||||
response.content
|
||||
)
|
||||
self.assertIn('No git import logs have been recorded for this course.', response.content.decode('utf-8'))
|
||||
|
||||
self._rm_edx4edx()
|
||||
|
||||
@@ -362,7 +358,6 @@ class TestSysAdminMongoCourseImport(SysadminBaseTestCase):
|
||||
reverse('gitlogs_detail', kwargs={
|
||||
'course_id': 'course-v1:MITx+edx4edx+edx4edx'
|
||||
}))
|
||||
self.assertIn('======> IMPORTING course',
|
||||
response.content)
|
||||
self.assertIn('======> IMPORTING course', response.content.decode('utf-8'))
|
||||
|
||||
self._rm_edx4edx()
|
||||
|
||||
Reference in New Issue
Block a user