Merge pull request #17376 from edx/jmbowman/PLAT-1915
PLAT-1915 Stop using deprecated BaseException.message
This commit is contained in:
@@ -4,6 +4,7 @@ Tests specific to the CourseRerunState Model and Manager.
|
||||
|
||||
from django.test import TestCase
|
||||
from opaque_keys.edx.locations import CourseLocator
|
||||
from six import text_type
|
||||
|
||||
from course_action_state.managers import CourseRerunUIStateManager
|
||||
from course_action_state.models import CourseRerunState
|
||||
@@ -103,7 +104,7 @@ class TestCourseRerunStateManager(TestCase):
|
||||
)
|
||||
self.expected_rerun_state.pop('message')
|
||||
rerun = self.verify_rerun_state()
|
||||
self.assertIn(exception.message, rerun.message)
|
||||
self.assertIn(text_type(exception), rerun.message)
|
||||
|
||||
# dismiss ui and verify
|
||||
self.dismiss_ui_and_verify(rerun)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from django.test import TestCase
|
||||
from nose.plugins.attrib import attr
|
||||
from opaque_keys.edx.locator import CourseLocator
|
||||
from six import text_type
|
||||
|
||||
from django_comment_common.models import Role
|
||||
from models import CourseDiscussionSettings
|
||||
@@ -131,6 +132,6 @@ class CourseDiscussionSettingsTest(ModuleStoreTestCase):
|
||||
set_course_discussion_settings(self.course.id, **{field['name']: invalid_value})
|
||||
|
||||
self.assertEqual(
|
||||
value_error.exception.message,
|
||||
text_type(value_error.exception),
|
||||
exception_msg_template.format(field['name'], field['type'].__name__)
|
||||
)
|
||||
|
||||
@@ -6,6 +6,7 @@ import logging
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from six import text_type
|
||||
|
||||
from enrollment.errors import (
|
||||
CourseEnrollmentClosedError,
|
||||
@@ -125,14 +126,14 @@ def create_course_enrollment(username, course_id, mode, is_active):
|
||||
enrollment = CourseEnrollment.enroll(user, course_key, check_access=True)
|
||||
return _update_enrollment(enrollment, is_active=is_active, mode=mode)
|
||||
except NonExistentCourseError as err:
|
||||
raise CourseNotFoundError(err.message)
|
||||
raise CourseNotFoundError(text_type(err))
|
||||
except EnrollmentClosedError as err:
|
||||
raise CourseEnrollmentClosedError(err.message)
|
||||
raise CourseEnrollmentClosedError(text_type(err))
|
||||
except CourseFullError as err:
|
||||
raise CourseEnrollmentFullError(err.message)
|
||||
raise CourseEnrollmentFullError(text_type(err))
|
||||
except AlreadyEnrolledError as err:
|
||||
enrollment = get_course_enrollment(username, course_id)
|
||||
raise CourseEnrollmentExistsError(err.message, enrollment)
|
||||
raise CourseEnrollmentExistsError(text_type(err), enrollment)
|
||||
|
||||
|
||||
def update_course_enrollment(username, course_id, mode=None, is_active=None):
|
||||
|
||||
@@ -14,6 +14,7 @@ from rest_framework import status
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.throttling import UserRateThrottle
|
||||
from rest_framework.views import APIView
|
||||
from six import text_type
|
||||
|
||||
from course_modes.models import CourseMode
|
||||
from enrollment import api
|
||||
@@ -604,7 +605,7 @@ class EnrollmentListView(APIView, ApiKeyPermissionMixIn):
|
||||
except EnterpriseApiException as error:
|
||||
log.exception("An unexpected error occurred while creating the new EnterpriseCourseEnrollment "
|
||||
"for user [%s] in course run [%s]", username, course_id)
|
||||
raise CourseEnrollmentError(error.message)
|
||||
raise CourseEnrollmentError(text_type(error))
|
||||
kwargs = {
|
||||
'username': username,
|
||||
'course_id': unicode(course_id),
|
||||
|
||||
@@ -6,6 +6,7 @@ from django.core.management.base import BaseCommand, CommandError
|
||||
from django.db import transaction
|
||||
from opaque_keys import InvalidKeyError
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from six import text_type
|
||||
|
||||
from student.models import CourseEnrollment, User
|
||||
|
||||
@@ -135,4 +136,4 @@ class Command(BaseCommand):
|
||||
if len(error_users) > 0:
|
||||
logger.info('The following %i user(s) not saved:', len(error_users))
|
||||
for user, error in error_users:
|
||||
logger.info('user: [%s] reason: [%s] %s', user, type(error).__name__, error.message)
|
||||
logger.info('user: [%s] reason: [%s] %s', user, type(error).__name__, text_type(error))
|
||||
|
||||
@@ -5,6 +5,8 @@ from django.contrib.auth.models import User
|
||||
from django.utils import translation
|
||||
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from six import text_type
|
||||
|
||||
from student.forms import AccountCreationForm
|
||||
from student.models import CourseEnrollment, create_comments_service_user
|
||||
from student.views import _do_create_account, AccountValidationError
|
||||
@@ -81,7 +83,7 @@ class Command(TrackedCommand):
|
||||
reg.save()
|
||||
create_comments_service_user(user)
|
||||
except AccountValidationError as e:
|
||||
print(e.message)
|
||||
print(text_type(e))
|
||||
user = User.objects.get(email=options['email'])
|
||||
|
||||
if course:
|
||||
|
||||
@@ -3,6 +3,7 @@ import re
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.management.base import BaseCommand
|
||||
from six import text_type
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
@@ -40,6 +41,7 @@ class Command(BaseCommand):
|
||||
print('Modified {} sucessfully.'.format(user))
|
||||
|
||||
except Exception as err: # pylint: disable=broad-except
|
||||
print("Error modifying user with identifier {}: {}: {}".format(user, type(err).__name__, err.message))
|
||||
print("Error modifying user with identifier {}: {}: {}".format(user, type(err).__name__,
|
||||
text_type(err)))
|
||||
|
||||
print('Complete!')
|
||||
|
||||
@@ -3,6 +3,7 @@ from __future__ import print_function
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.management.base import BaseCommand
|
||||
from six import text_type
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
@@ -41,6 +42,7 @@ class Command(BaseCommand):
|
||||
print('Modified {} sucessfully.'.format(user))
|
||||
|
||||
except Exception as err: # pylint: disable=broad-except
|
||||
print("Error modifying user with identifier {}: {}: {}".format(user, type(err).__name__, err.message))
|
||||
print("Error modifying user with identifier {}: {}: {}".format(user, type(err).__name__,
|
||||
text_type(err)))
|
||||
|
||||
print('Complete!')
|
||||
|
||||
@@ -12,6 +12,7 @@ from django.http import HttpResponse
|
||||
from django.test import override_settings, TestCase, TransactionTestCase
|
||||
from django.test.client import RequestFactory
|
||||
from mock import Mock, patch
|
||||
from six import text_type
|
||||
|
||||
from edxmako.shortcuts import render_to_string
|
||||
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
|
||||
@@ -266,7 +267,7 @@ class EmailChangeRequestTests(EventTestMixin, CacheIsolationTestCase):
|
||||
try:
|
||||
validate_new_email(self.request.user, email)
|
||||
except ValueError as err:
|
||||
return err.message
|
||||
return text_type(err)
|
||||
|
||||
def do_email_change(self, user, email, activation_key=None):
|
||||
"""
|
||||
@@ -275,7 +276,7 @@ class EmailChangeRequestTests(EventTestMixin, CacheIsolationTestCase):
|
||||
try:
|
||||
do_email_change_request(user, email, activation_key)
|
||||
except ValueError as err:
|
||||
return err.message
|
||||
return text_type(err)
|
||||
|
||||
def assertFailedRequest(self, response_data, expected_error):
|
||||
"""
|
||||
|
||||
@@ -958,7 +958,7 @@ def create_account(request, post_override=None):
|
||||
try:
|
||||
user = create_account_with_params(request, post_override or request.POST)
|
||||
except AccountValidationError as exc:
|
||||
return JsonResponse({'success': False, 'value': exc.message, 'field': exc.field}, status=400)
|
||||
return JsonResponse({'success': False, 'value': text_type(exc), 'field': exc.field}, status=400)
|
||||
except ValidationError as exc:
|
||||
field, error_list = next(iteritems(exc.message_dict))
|
||||
return JsonResponse(
|
||||
|
||||
@@ -14,6 +14,7 @@ from oauthlib.oauth1.rfc5849.signature import (
|
||||
normalize_parameters,
|
||||
sign_hmac_sha1
|
||||
)
|
||||
from six import text_type
|
||||
from social_core.backends.base import BaseAuth
|
||||
from social_core.exceptions import AuthFailed
|
||||
from social_core.utils import sanitize_redirect
|
||||
@@ -185,7 +186,7 @@ class LTIAuthBackend(BaseAuth):
|
||||
if valid:
|
||||
return data
|
||||
except AttributeError as error:
|
||||
log.error("'{}' not found.".format(error.message))
|
||||
log.error("'{}' not found.".format(text_type(error)))
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -18,6 +18,7 @@ from django.utils import timezone
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from provider.oauth2.models import Client
|
||||
from provider.utils import long_token
|
||||
from six import text_type
|
||||
from social_core.backends.base import BaseAuth
|
||||
from social_core.backends.oauth import OAuthAuth
|
||||
from social_core.backends.saml import SAMLAuth
|
||||
@@ -60,7 +61,7 @@ def clean_json(value, of_type):
|
||||
try:
|
||||
value_python = json.loads(value)
|
||||
except ValueError as err:
|
||||
raise ValidationError("Invalid JSON: {}".format(err.message))
|
||||
raise ValidationError("Invalid JSON: {}".format(text_type(err)))
|
||||
if not isinstance(value_python, of_type):
|
||||
raise ValidationError("Expected a JSON {}".format(of_type))
|
||||
return json.dumps(value_python, indent=4)
|
||||
|
||||
@@ -10,6 +10,7 @@ from django.http import Http404
|
||||
from django.utils.functional import cached_property
|
||||
from django_countries import countries
|
||||
from onelogin.saml2.settings import OneLogin_Saml2_Settings
|
||||
from six import text_type
|
||||
from social_core.backends.saml import OID_EDU_PERSON_ENTITLEMENT, SAMLAuth, SAMLIdentityProvider
|
||||
from social_core.exceptions import AuthForbidden
|
||||
|
||||
@@ -337,7 +338,7 @@ class SapSuccessFactorsIdentityProvider(EdXSAMLIdentityProvider):
|
||||
url=transaction_data['endpoint_url'],
|
||||
company_id=transaction_data['company_id'],
|
||||
user_id=transaction_data['user_id'],
|
||||
err_msg=err.message,
|
||||
err_msg=text_type(err),
|
||||
sys_msg=sys_msg,
|
||||
headers=headers,
|
||||
token_data=token_data,
|
||||
|
||||
@@ -14,6 +14,7 @@ from django.utils.timezone import now
|
||||
from lxml import etree
|
||||
from onelogin.saml2.utils import OneLogin_Saml2_Utils
|
||||
from requests import exceptions
|
||||
from six import text_type
|
||||
|
||||
from third_party_auth.models import SAMLConfiguration, SAMLProviderConfig, SAMLProviderData
|
||||
|
||||
@@ -105,11 +106,11 @@ def fetch_saml_metadata():
|
||||
# RequestException is the base exception for any request related error that "requests" lib raises.
|
||||
# MetadataParseError is raised if there is error in the fetched meta data (e.g. missing @entityID etc.)
|
||||
|
||||
log.exception(error.message)
|
||||
log.exception(text_type(error))
|
||||
failure_messages.append(
|
||||
"{error_type}: {error_message}\nMetadata Source: {url}\nEntity IDs: \n{entity_ids}.".format(
|
||||
error_type=type(error).__name__,
|
||||
error_message=error.message,
|
||||
error_message=text_type(error),
|
||||
url=url,
|
||||
entity_ids="\n".join(
|
||||
["\t{}: {}".format(count, item) for count, item in enumerate(entity_ids, start=1)],
|
||||
@@ -117,7 +118,7 @@ def fetch_saml_metadata():
|
||||
)
|
||||
)
|
||||
except etree.XMLSyntaxError as error:
|
||||
log.exception(error.message)
|
||||
log.exception(text_type(error))
|
||||
failure_messages.append(
|
||||
"XMLSyntaxError: {error_message}\nMetadata Source: {url}\nEntity IDs: \n{entity_ids}.".format(
|
||||
error_message=str(error.error_log),
|
||||
|
||||
@@ -15,6 +15,7 @@ from pytz import UTC
|
||||
from mock import Mock, patch
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from opaque_keys.edx.locations import CourseLocator
|
||||
from six import text_type
|
||||
|
||||
import util.file
|
||||
from util.file import (
|
||||
@@ -95,7 +96,7 @@ class StoreUploadedFileTestCase(TestCase):
|
||||
"""
|
||||
Helper method to verify exception text.
|
||||
"""
|
||||
self.assertEqual(expected_message, error.exception.message)
|
||||
self.assertEqual(expected_message, text_type(error.exception))
|
||||
|
||||
def test_error_conditions(self):
|
||||
"""
|
||||
|
||||
@@ -50,6 +50,7 @@ import bleach
|
||||
import html5lib
|
||||
import pyparsing
|
||||
from lxml import etree
|
||||
from six import text_type
|
||||
|
||||
import xqueue_interface
|
||||
from calc.preview import latex_preview
|
||||
@@ -251,7 +252,7 @@ class InputTypeBase(object):
|
||||
except Exception as err:
|
||||
# Something went wrong: add xml to message, but keep the traceback
|
||||
msg = u"Error in xml '{x}': {err} ".format(
|
||||
x=etree.tostring(xml), err=err.message)
|
||||
x=etree.tostring(xml), err=text_type(err))
|
||||
raise Exception, msg, sys.exc_info()[2]
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -1601,14 +1601,14 @@ class NumericalResponse(LoncapaResponse):
|
||||
except UndefinedVariable as undef_var:
|
||||
raise StudentInputError(
|
||||
_(u"You may not use variables ({bad_variables}) in numerical problems.").format(
|
||||
bad_variables=undef_var.message,
|
||||
bad_variables=text_type(undef_var),
|
||||
)
|
||||
)
|
||||
except ValueError as val_err:
|
||||
if 'factorial' in val_err.message:
|
||||
if 'factorial' in text_type(val_err):
|
||||
# This is thrown when fact() or factorial() is used in an answer
|
||||
# that evaluates on negative and/or non-integer inputs
|
||||
# ve.message will be: `factorial() only accepts integral values` or
|
||||
# text_type(ve) will be: `factorial() only accepts integral values` or
|
||||
# `factorial() not defined for negative values`
|
||||
raise StudentInputError(
|
||||
_("Factorial function evaluated outside its domain:"
|
||||
@@ -2038,7 +2038,7 @@ class StringResponse(LoncapaResponse):
|
||||
except Exception as err:
|
||||
msg = u'[courseware.capa.responsetypes.stringresponse] {error}: {message}'.format(
|
||||
error=_('error'),
|
||||
message=err.message
|
||||
message=text_type(err)
|
||||
)
|
||||
log.error(msg, exc_info=True)
|
||||
raise ResponseError(msg)
|
||||
@@ -2511,7 +2511,7 @@ class CustomResponse(LoncapaResponse):
|
||||
|
||||
# Notify student with a student input error
|
||||
_, _, traceback_obj = sys.exc_info()
|
||||
raise ResponseError(err.message, traceback_obj)
|
||||
raise ResponseError(text_type(err), traceback_obj)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
@@ -3106,13 +3106,13 @@ class FormulaResponse(LoncapaResponse):
|
||||
cgi.escape(answer)
|
||||
)
|
||||
raise StudentInputError(
|
||||
_("Invalid input: {bad_input} not permitted in answer.").format(bad_input=err.message)
|
||||
_("Invalid input: {bad_input} not permitted in answer.").format(bad_input=text_type(err))
|
||||
)
|
||||
except ValueError as err:
|
||||
if 'factorial' in err.message:
|
||||
if 'factorial' in text_type(err):
|
||||
# This is thrown when fact() or factorial() is used in a formularesponse answer
|
||||
# that tests on negative and/or non-integer inputs
|
||||
# err.message will be: `factorial() only accepts integral values` or
|
||||
# text_type(err) will be: `factorial() only accepts integral values` or
|
||||
# `factorial() not defined for negative values`
|
||||
log.debug(
|
||||
('formularesponse: factorial function used in response '
|
||||
|
||||
@@ -5,6 +5,7 @@ from codejail.safe_exec import not_safe_exec as codejail_not_safe_exec
|
||||
from codejail.safe_exec import json_safe, SafeExecException
|
||||
from . import lazymod
|
||||
from dogapi import dog_stats_api
|
||||
from six import text_type
|
||||
|
||||
import hashlib
|
||||
|
||||
@@ -143,7 +144,7 @@ def safe_exec(
|
||||
python_path=python_path, extra_files=extra_files, slug=slug,
|
||||
)
|
||||
except SafeExecException as e:
|
||||
emsg = e.message
|
||||
emsg = text_type(e)
|
||||
else:
|
||||
emsg = None
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import textwrap
|
||||
import unittest
|
||||
|
||||
from nose.plugins.skip import SkipTest
|
||||
from six import text_type
|
||||
|
||||
from capa.safe_exec import safe_exec, update_hash
|
||||
from codejail.safe_exec import SafeExecException
|
||||
@@ -69,7 +70,7 @@ class TestSafeExec(unittest.TestCase):
|
||||
g = {}
|
||||
with self.assertRaises(SafeExecException) as cm:
|
||||
safe_exec("1/0", g)
|
||||
self.assertIn("ZeroDivisionError", cm.exception.message)
|
||||
self.assertIn("ZeroDivisionError", text_type(cm.exception))
|
||||
|
||||
|
||||
class TestSafeOrNot(unittest.TestCase):
|
||||
@@ -81,8 +82,8 @@ class TestSafeOrNot(unittest.TestCase):
|
||||
g = {}
|
||||
with self.assertRaises(SafeExecException) as cm:
|
||||
safe_exec("import os; files = os.listdir('/')", g)
|
||||
self.assertIn("OSError", cm.exception.message)
|
||||
self.assertIn("Permission denied", cm.exception.message)
|
||||
assert "OSError" in text_type(cm.exception)
|
||||
assert "Permission denied" in text_type(cm.exception)
|
||||
|
||||
def test_can_do_something_forbidden_if_run_unsafely(self):
|
||||
g = {}
|
||||
|
||||
@@ -15,6 +15,7 @@ import zipfile
|
||||
|
||||
import mock
|
||||
from pytz import UTC
|
||||
from six import text_type
|
||||
import requests
|
||||
|
||||
from capa.tests.helpers import new_loncapa_problem, test_capa_system, load_fixture
|
||||
@@ -798,7 +799,7 @@ class StringResponseTest(ResponseTest): # pylint: disable=missing-docstring
|
||||
problem = self.build_problem(answer="a2", case_sensitive=False, regexp=True, additional_answers=['?\\d?'])
|
||||
with self.assertRaises(Exception) as cm:
|
||||
self.assert_grade(problem, "a3", "correct")
|
||||
exception_message = cm.exception.message
|
||||
exception_message = text_type(cm.exception)
|
||||
self.assertIn("nothing to repeat", exception_message)
|
||||
|
||||
def test_hints(self):
|
||||
|
||||
@@ -544,7 +544,7 @@ class CapaMixin(ScorableXBlockMixin, CapaFields):
|
||||
|
||||
`err` is the Exception encountered while rendering the problem HTML.
|
||||
"""
|
||||
log.exception(err.message)
|
||||
log.exception(text_type(err))
|
||||
|
||||
# TODO (vshnayder): another switch on DEBUG.
|
||||
if self.runtime.DEBUG:
|
||||
@@ -553,7 +553,7 @@ class CapaMixin(ScorableXBlockMixin, CapaFields):
|
||||
u'Failed to generate HTML for problem {url}</font>'.format(
|
||||
url=cgi.escape(text_type(self.location)))
|
||||
)
|
||||
msg += u'<p>Error:</p><p><pre>{msg}</pre></p>'.format(msg=cgi.escape(err.message))
|
||||
msg += u'<p>Error:</p><p><pre>{msg}</pre></p>'.format(msg=cgi.escape(text_type(err)))
|
||||
msg += u'<p><pre>{tb}</pre></p>'.format(tb=cgi.escape(traceback.format_exc()))
|
||||
html = msg
|
||||
|
||||
@@ -1258,7 +1258,7 @@ class CapaMixin(ScorableXBlockMixin, CapaFields):
|
||||
self.set_score(self.score_from_lcp())
|
||||
|
||||
if self.runtime.DEBUG:
|
||||
msg = u"Error checking problem: {}".format(err.message)
|
||||
msg = u"Error checking problem: {}".format(text_type(err))
|
||||
msg += u'\nTraceback:\n{}'.format(traceback.format_exc())
|
||||
return {'success': msg}
|
||||
raise
|
||||
|
||||
@@ -16,6 +16,7 @@ from openedx.core.djangoapps.video_pipeline.models import VideoUploadsEnabledByD
|
||||
from openedx.core.lib.license import LicenseMixin
|
||||
from path import Path as path
|
||||
from pytz import utc
|
||||
from six import text_type
|
||||
from xblock.fields import Scope, List, String, Dict, Boolean, Integer, Float
|
||||
|
||||
from xmodule import course_metadata_utils
|
||||
@@ -943,7 +944,7 @@ class CourseDescriptor(CourseFields, SequenceDescriptor, LicenseMixin):
|
||||
if not getattr(self, "tabs", []):
|
||||
CourseTabList.initialize_default(self)
|
||||
except InvalidTabsException as err:
|
||||
raise type(err)('{msg} For course: {course_id}'.format(msg=err.message, course_id=unicode(self.id)))
|
||||
raise type(err)('{msg} For course: {course_id}'.format(msg=text_type(err), course_id=unicode(self.id)))
|
||||
|
||||
self.set_default_certificate_available_date()
|
||||
|
||||
|
||||
@@ -45,9 +45,6 @@ class HeartbeatFailure(Exception):
|
||||
Raised when heartbeat fails.
|
||||
"""
|
||||
|
||||
def __unicode__(self, *args, **kwargs):
|
||||
return self.message
|
||||
|
||||
def __init__(self, msg, service):
|
||||
"""
|
||||
In addition to a msg, provide the name of the service.
|
||||
|
||||
@@ -5,6 +5,7 @@ import time
|
||||
|
||||
import dateutil.parser
|
||||
from pytz import UTC
|
||||
from six import text_type
|
||||
from xblock.fields import JSONField
|
||||
from xblock.scorable import Score
|
||||
|
||||
@@ -175,7 +176,7 @@ class RelativeTime(JSONField):
|
||||
except ValueError as e:
|
||||
raise ValueError(
|
||||
"Incorrect RelativeTime value {!r} was set in XML or serialized. "
|
||||
"Original parse message is {}".format(value, e.message)
|
||||
"Original parse message is {}".format(value, text_type(e))
|
||||
)
|
||||
return datetime.timedelta(
|
||||
hours=obj_time.tm_hour,
|
||||
|
||||
@@ -12,6 +12,7 @@ import urllib
|
||||
|
||||
import mock
|
||||
from oauthlib.oauth1 import Client
|
||||
from six import text_type
|
||||
from webob import Response
|
||||
from xblock.core import XBlock
|
||||
|
||||
@@ -290,8 +291,8 @@ class LTI20ModuleMixin(object):
|
||||
try:
|
||||
self.verify_oauth_body_sign(request, content_type=LTI_2_0_JSON_CONTENT_TYPE)
|
||||
except (ValueError, LTIError) as err:
|
||||
log.info("[LTI]: v2.0 result service -- OAuth body verification failed: {}".format(err.message))
|
||||
raise LTIError(err.message)
|
||||
log.info("[LTI]: v2.0 result service -- OAuth body verification failed: {}".format(text_type(err)))
|
||||
raise LTIError(text_type(err))
|
||||
|
||||
def parse_lti_2_0_result_json(self, json_str):
|
||||
"""
|
||||
@@ -360,7 +361,7 @@ class LTI20ModuleMixin(object):
|
||||
log.info("[LTI] {}".format(msg))
|
||||
raise LTIError(msg)
|
||||
except (TypeError, ValueError) as err:
|
||||
msg = "Could not convert resultScore to float: {}".format(err.message)
|
||||
msg = "Could not convert resultScore to float: {}".format(text_type(err))
|
||||
log.info("[LTI] {}".format(msg))
|
||||
raise LTIError(msg)
|
||||
|
||||
|
||||
@@ -734,7 +734,7 @@ oauth_consumer_key="", oauth_signature="frVp4JuvT1mVXlxktiAUjQ7%2F1cw%3D"'}
|
||||
try:
|
||||
imsx_messageIdentifier, sourcedId, score, action = self.parse_grade_xml_body(request.body)
|
||||
except Exception as e:
|
||||
error_message = "Request body XML parsing error: " + escape(e.message)
|
||||
error_message = "Request body XML parsing error: " + escape(text_type(e))
|
||||
log.debug("[LTI]: " + error_message)
|
||||
failure_values['imsx_description'] = error_message
|
||||
return Response(response_xml_template.format(**failure_values), content_type="application/xml")
|
||||
@@ -744,7 +744,7 @@ oauth_consumer_key="", oauth_signature="frVp4JuvT1mVXlxktiAUjQ7%2F1cw%3D"'}
|
||||
self.verify_oauth_body_sign(request)
|
||||
except (ValueError, LTIError) as e:
|
||||
failure_values['imsx_messageIdentifier'] = escape(imsx_messageIdentifier)
|
||||
error_message = "OAuth verification error: " + escape(e.message)
|
||||
error_message = "OAuth verification error: " + escape(text_type(e))
|
||||
failure_values['imsx_description'] = error_message
|
||||
log.debug("[LTI]: " + error_message)
|
||||
return Response(response_xml_template.format(**failure_values), content_type="application/xml")
|
||||
|
||||
@@ -6,6 +6,7 @@ import threading
|
||||
import logging
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from contextlib import contextmanager
|
||||
from six import text_type
|
||||
from . import ModuleStoreEnum, BulkOperationsMixin
|
||||
from .exceptions import ItemNotFoundError
|
||||
|
||||
@@ -157,7 +158,7 @@ class ModuleStoreDraftAndPublished(BranchSettingMixin, BulkOperationsMixin):
|
||||
old_parent_item = self.get_item(old_parent_location) # pylint: disable=no-member
|
||||
new_parent_item = self.get_item(new_parent_location) # pylint: disable=no-member
|
||||
except ItemNotFoundError as exception:
|
||||
log.error('Unable to find the item : %s', exception.message)
|
||||
log.error('Unable to find the item : %s', text_type(exception))
|
||||
return
|
||||
|
||||
# Remove item from the list of children of old parent.
|
||||
|
||||
@@ -880,7 +880,7 @@ class CapaModuleTest(unittest.TestCase):
|
||||
' File "<string>", line 65, in check_func\\n'
|
||||
'Exception: test error\\n\' with status code: 1',)
|
||||
except ResponseError as err:
|
||||
mock_grade.side_effect = exception_class(err.message)
|
||||
mock_grade.side_effect = exception_class(six.text_type(err))
|
||||
get_request_dict = {CapaFactory.input_key(): '3.14'}
|
||||
result = module.submit_problem(get_request_dict)
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ from datetime import datetime, timedelta
|
||||
import ddt
|
||||
from pytz import UTC
|
||||
from lms.djangoapps.grades.scores import compute_percent
|
||||
from six import text_type
|
||||
from xmodule import graders
|
||||
from xmodule.graders import (
|
||||
AggregatedScore, ProblemScore, ShowCorrectness, aggregate_scores
|
||||
@@ -321,7 +322,7 @@ class GraderTest(unittest.TestCase):
|
||||
def test_grader_with_invalid_conf(self, invalid_conf, expected_error_message):
|
||||
with self.assertRaises(ValueError) as error:
|
||||
graders.grader_from_conf([invalid_conf])
|
||||
self.assertIn(expected_error_message, error.exception.message)
|
||||
self.assertIn(expected_error_message, text_type(error.exception))
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
|
||||
@@ -12,6 +12,7 @@ from pysrt import SubRipTime, SubRipItem, SubRipFile
|
||||
from pysrt.srtexc import Error
|
||||
from lxml import etree
|
||||
from HTMLParser import HTMLParser
|
||||
from six import text_type
|
||||
|
||||
from xmodule.exceptions import NotFoundError
|
||||
from xmodule.contentstore.content import StaticContent
|
||||
@@ -226,7 +227,7 @@ def generate_subs_from_source(speed_subs, subs_type, subs_filedata, item, langua
|
||||
srt_subs_obj = SubRipFile.from_string(subs_filedata)
|
||||
except Exception as ex:
|
||||
msg = _("Something wrong with SubRip transcripts file during parsing. Inner message is {error_message}").format(
|
||||
error_message=ex.message
|
||||
error_message=text_type(ex)
|
||||
)
|
||||
raise TranscriptsGenerationException(msg)
|
||||
if not srt_subs_obj:
|
||||
@@ -459,7 +460,7 @@ def generate_sjson_for_all_speeds(item, user_filename, result_subs_dict, lang):
|
||||
srt_transcripts = contentstore().find(Transcript.asset_location(item.location, user_filename))
|
||||
except NotFoundError as ex:
|
||||
raise TranscriptException(_("{exception_message}: Can't find uploaded transcripts: {user_filename}").format(
|
||||
exception_message=ex.message,
|
||||
exception_message=text_type(ex),
|
||||
user_filename=user_filename
|
||||
))
|
||||
|
||||
@@ -612,7 +613,7 @@ class Transcript(object):
|
||||
error_handling=SubRipFile.ERROR_RAISE
|
||||
)
|
||||
except Error as ex: # Base exception from pysrt
|
||||
raise TranscriptsGenerationException(ex.message)
|
||||
raise TranscriptsGenerationException(text_type(ex))
|
||||
|
||||
return generate_sjson_from_srt(srt_subs)
|
||||
|
||||
|
||||
@@ -291,7 +291,7 @@ class VideoStudentViewHandlers(object):
|
||||
except (TypeError, TranscriptException, NotFoundError) as ex:
|
||||
# Catching `TranscriptException` because its also getting raised at places
|
||||
# when transcript is not found in contentstore.
|
||||
log.debug(ex.message)
|
||||
log.debug(six.text_type(ex))
|
||||
# Try to return static URL redirection as last resort
|
||||
# if no translation is required
|
||||
response = self.get_static_transcript(request, transcripts)
|
||||
@@ -313,7 +313,7 @@ class VideoStudentViewHandlers(object):
|
||||
|
||||
return response
|
||||
except (UnicodeDecodeError, TranscriptsGenerationException) as ex:
|
||||
log.info(ex.message)
|
||||
log.info(six.text_type(ex))
|
||||
response = Response(status=404)
|
||||
else:
|
||||
response = Response(transcript, headerlist=[('Content-Language', language)])
|
||||
|
||||
@@ -14,6 +14,7 @@ from pkg_resources import (
|
||||
resource_string,
|
||||
resource_isdir,
|
||||
)
|
||||
from six import text_type
|
||||
from web_fragments.fragment import Fragment
|
||||
from webob import Response
|
||||
from webob.multidict import MultiDict
|
||||
@@ -420,8 +421,8 @@ class XModuleMixin(XModuleFields, XBlock):
|
||||
result[field.name] = field.read_json(self)
|
||||
except TypeError as exception:
|
||||
exception_message = "{message}, Block-location:{location}, Field-name:{field_name}".format(
|
||||
message=exception.message,
|
||||
location=unicode(self.location),
|
||||
message=text_type(exception),
|
||||
location=text_type(self.location),
|
||||
field_name=field.name
|
||||
)
|
||||
raise TypeError(exception_message)
|
||||
|
||||
Reference in New Issue
Block a user