Skip to content

Commit

Permalink
Python Requirements Update (#959)
Browse files Browse the repository at this point in the history
* Updating Python Requirements

* remove unicode string

* update documents

* add encoding info on file read

* update linting for superfluous-parens

* version bump

* update change log

Co-authored-by: Leangseu Kim <[email protected]>
  • Loading branch information
edx-requirements-bot and leangseu-edx authored Sep 9, 2021
1 parent b781d85 commit d75a8f6
Show file tree
Hide file tree
Showing 33 changed files with 302 additions and 288 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ Change Log
Unreleased
~~~~~~~~~~

[3.24.6] - 2021-09-03
* Upgrade edx-lint for linting
* Update code style
* Handler test refactor

[3.24.5] - 2021-09-02
Expand Down
4 changes: 2 additions & 2 deletions docs/backends.rst
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ It is possible to add support for an instructor dashboard for reviewing proctore

The ``get_instructor_url`` method of the backend will return a URL on the PS end that will redirect to the instructor dashboard.

By default, this URL will be ``base_url + u'/api/v1/instructor/{client_id}/?jwt={jwt}'``. This URL template is specified by the ``instructor_url`` property.
By default, this URL will be ``base_url +'/api/v1/instructor/{client_id}/?jwt={jwt}'``. This URL template is specified by the ``instructor_url`` property.
You may override this property to modify the URL template.

The JWT_ will be signed with the client_secret configured for the backend, and the decoded token contains the following data::
Expand Down Expand Up @@ -269,7 +269,7 @@ Onboarding Status API Endpoint

A backend can also be configured to support an onboarding status API endpoint. This endpoint should return a learner's onboarding status and expiration according to the provider.

By default, this URL for this endpoint will be ``base_url + u'/api/v1/courses/{course_id}/onboarding_statuses'``, with the following optional query parameters:
By default, this URL for this endpoint will be ``base_url +'/api/v1/courses/{course_id}/onboarding_statuses'``, with the following optional query parameters:

* ``user_id``: a string for the id of a specific user.
* ``status``: a string representing the status that should be filtered for
Expand Down
2 changes: 1 addition & 1 deletion edx_proctoring/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"""

# Be sure to update the version number in edx_proctoring/package.json
__version__ = '3.24.5'
__version__ = '3.24.6'

default_app_config = 'edx_proctoring.apps.EdxProctoringConfig' # pylint: disable=invalid-name
2 changes: 1 addition & 1 deletion edx_proctoring/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def lookups(self, request, model_admin):
# prepend the exam_name with a parsed out course_id
lookups += ((
exam.id,
u'{course_id}: {exam_name}'.format(
'{course_id}: {exam_name}'.format(
course_id=prettify_course_id(course_id),
exam_name=exam.exam_name
)
Expand Down
40 changes: 20 additions & 20 deletions edx_proctoring/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ def add_bulk_allowances(exam_ids, user_ids, allowance_type, value):
multiplier = 0
if allowance_type == constants.TIME_MULTIPLIER:
err_msg = (
u'allowance_value "{value}" should be a float value greater than 1.'
'allowance_value "{value}" should be a float value greater than 1.'
).format(value=value)
try:
multiplier = float(value) - 1
Expand All @@ -574,7 +574,7 @@ def add_bulk_allowances(exam_ids, user_ids, allowance_type, value):

if allowance_type in ProctoredExamStudentAllowance.ADDITIONAL_TIME_GRANTED:
err_msg = (
u'allowance_value "{value}" should be a non-negative integer value'
'allowance_value "{value}" should be a non-negative integer value'
).format(value=value)
if not value.isdigit():
raise AllowanceValueNotAllowedException(err_msg)
Expand All @@ -595,8 +595,8 @@ def add_bulk_allowances(exam_ids, user_ids, allowance_type, value):
failures += 1
data.append({

'exam_id': exam_id,
'user_id': user_id,
'exam_id': exam_id,
'user_id': user_id,
})
continue
if allowance_type == constants.TIME_MULTIPLIER:
Expand All @@ -611,8 +611,8 @@ def add_bulk_allowances(exam_ids, user_ids, allowance_type, value):
successes += 1
data.append({

'exam_id': exam_id,
'user_id': user_id,
'exam_id': exam_id,
'user_id': user_id,
})

except ProctoredBaseException:
Expand All @@ -627,8 +627,8 @@ def add_bulk_allowances(exam_ids, user_ids, allowance_type, value):
failures += 1
data.append({

'exam_id': exam_id,
'user_id': user_id,
'exam_id': exam_id,
'user_id': user_id,
})
else:
for user_id in user_ids:
Expand All @@ -639,8 +639,8 @@ def add_bulk_allowances(exam_ids, user_ids, allowance_type, value):
successes += 1
data.append({

'exam_id': exam_id,
'user_id': user_id,
'exam_id': exam_id,
'user_id': user_id,
})
except ProctoredBaseException:
log_message = (
Expand All @@ -654,8 +654,8 @@ def add_bulk_allowances(exam_ids, user_ids, allowance_type, value):
failures += 1
data.append({

'exam_id': exam_id,
'user_id': user_id,
'exam_id': exam_id,
'user_id': user_id,
})
return data, successes, failures

Expand Down Expand Up @@ -1522,7 +1522,7 @@ def update_attempt_status(attempt_id, to_status,
earned_all=REJECTED_GRADE_OVERRIDE_EARNED,
earned_graded=REJECTED_GRADE_OVERRIDE_EARNED,
overrider=update_attributable_to,
comment=(u'Failed {backend} proctoring'.format(backend=backend.verbose_name)
comment=('Failed {backend} proctoring'.format(backend=backend.verbose_name)
if backend
else 'Failed Proctoring')
)
Expand Down Expand Up @@ -1668,7 +1668,7 @@ def create_proctoring_attempt_status_email(user_id, exam_attempt_obj, course_nam
user = USER_MODEL.objects.get(id=user_id)
course_info_url = ''
email_subject = (
_(u'Proctoring Results For {course_name} {exam_name}').format(
_('Proctoring Results For {course_name} {exam_name}').format(
course_name=course_name,
exam_name=exam_attempt_obj.proctored_exam.exam_name
)
Expand All @@ -1677,7 +1677,7 @@ def create_proctoring_attempt_status_email(user_id, exam_attempt_obj, course_nam
if status == ProctoredExamStudentAttemptStatus.submitted:
template_name = 'proctoring_attempt_submitted_email.html'
email_subject = (
_(u'Proctoring Review In Progress For {course_name} {exam_name}').format(
_('Proctoring Review In Progress For {course_name} {exam_name}').format(
course_name=course_name,
exam_name=exam_attempt_obj.proctored_exam.exam_name
)
Expand Down Expand Up @@ -1711,7 +1711,7 @@ def create_proctoring_attempt_status_email(user_id, exam_attempt_obj, course_nam
course_info_url=course_info_url
)
exam_name = exam_attempt_obj.proctored_exam.exam_name
support_email_subject = _(u'Proctored exam {exam_name} in {course_name} for user {username}').format(
support_email_subject = _('Proctored exam {exam_name} in {course_name} for user {username}').format(
exam_name=exam_name,
course_name=course_name,
username=user.username,
Expand Down Expand Up @@ -1894,7 +1894,7 @@ def remove_exam_attempt(attempt_id, requesting_user):
credit_service.remove_credit_requirement_status(
user_id=user_id,
course_key_or_id=course_id,
req_namespace=u'proctored_exam',
req_namespace='proctored_exam',
req_name=content_id
)

Expand Down Expand Up @@ -2083,7 +2083,7 @@ def _are_prerequirements_satisfied(
evaluate_for_requirement_name=None,
filter_out_namespaces=None
):
u"""
"""
Returns a dict about the fulfillment of any pre-requisites in order to this exam
as proctored. The pre-requisites are taken from the credit requirements table. So if ordering
of requirements are - say - ICRV1, Proctoring1, ICRV2, and Proctoring2, then the user cannot take
Expand Down Expand Up @@ -2528,7 +2528,7 @@ def _get_proctored_exam_context(exam, attempt, user_id, course_id, is_practice_e
password_assistance_url=password_assistance_url
)
except NoReverseMatch:
log.exception(u"Can't find password reset link")
log.exception("Can't find password reset link")

has_due_date = exam['due_date'] is not None
attempt_time = attempt.get('allowed_time_limit_mins', None) if attempt else None
Expand Down Expand Up @@ -2961,7 +2961,7 @@ def get_exam_violation_report(course_id, include_practice_exams=False):
attempts_by_code[attempt_code]['review_status'] = review.review_status

for comment in review.proctoredexamsoftwaresecurecomment_set.all():
comments_key = u'{status} Comments'.format(status=comment.status)
comments_key = '{status} Comments'.format(status=comment.status)

if comments_key not in attempts_by_code[attempt_code]:
attempts_by_code[attempt_code][comments_key] = []
Expand Down
52 changes: 26 additions & 26 deletions edx_proctoring/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,24 @@ def make_worker_config(backends, out='/tmp/workers.json'):
try:
package = backend.npm_module
package_file = os.path.join(settings.NODE_MODULES_ROOT, package, 'package.json')
with open(package_file, 'r') as package_fp:
with open(package_file, 'r', encoding='utf-8') as package_fp:
package_json = json.load(package_fp)
main_file = package_json['main']
config[package] = ['babel-polyfill', os.path.join(settings.NODE_MODULES_ROOT, package, main_file)]
except AttributeError:
# no npm module defined
continue
except IOError:
warnings.warn(u'Proctoring backend %s defined an npm module,'
u'but it is not installed at %r' % (backend.__class__, package_file))
warnings.warn('Proctoring backend %s defined an npm module,'
'but it is not installed at %r' % (backend.__class__, package_file))
except KeyError:
warnings.warn(u'%r does not contain a `main` entry' % package_file)
warnings.warn('%r does not contain a `main` entry' % package_file)
if config:
try:
with open(out, 'wb+') as outfp:
outfp.write(json.dumps(config).encode('utf-8'))
except IOError:
warnings.warn(u"Could not write worker config to %s" % out)
warnings.warn("Could not write worker config to %s" % out)
else:
# make sure that this file is group writable, because it may be written by different users
os.chmod(out, 0o664)
Expand All @@ -83,28 +83,28 @@ class EdxProctoringConfig(AppConfig):
Configuration for the edx_proctoring Django application.
"""

name = u'edx_proctoring'
name = 'edx_proctoring'
plugin_app = {
u'url_config': {
u'lms.djangoapp': {
u'namespace': u'edx_proctoring',
u'regex': u'^api/',
u'relative_path': u'urls',
'url_config': {
'lms.djangoapp': {
'namespace': 'edx_proctoring',
'regex': '^api/',
'relative_path': 'urls',
},
u'cms.djangoapp': {
u'namespace': u'edx_proctoring',
u'regex': u'^api/',
u'relative_path': u'instructor_dashboard_exam_urls',
'cms.djangoapp': {
'namespace': 'edx_proctoring',
'regex': '^api/',
'relative_path': 'instructor_dashboard_exam_urls',
},
},
u'settings_config': {
u'lms.djangoapp': {
u'common': {'relative_path': u'settings.common'},
u'production': {'relative_path': u'settings.production'},
'settings_config': {
'lms.djangoapp': {
'common': {'relative_path': 'settings.common'},
'production': {'relative_path': 'settings.production'},
},
u'cms.djangoapp': {
u'common': {'relative_path': u'settings.common'},
u'production': {'relative_path': u'settings.production'},
'cms.djangoapp': {
'common': {'relative_path': 'settings.common'},
'production': {'relative_path': 'settings.production'},
}

},
Expand All @@ -116,7 +116,7 @@ def get_backend_choices(self):
backend_name, verbose name
"""
for name, backend in self.backends.items():
yield name, getattr(backend, 'verbose_name', u'Unknown')
yield name, getattr(backend, 'verbose_name', 'Unknown')

def get_backend(self, name=None):
"""
Expand All @@ -129,13 +129,13 @@ def get_backend(self, name=None):
try:
name = settings.PROCTORING_BACKENDS['DEFAULT']
except (KeyError, AttributeError) as exc:
raise ImproperlyConfigured(u"No default proctoring backend set in settings.PROCTORING_BACKENDS") \
raise ImproperlyConfigured("No default proctoring backend set in settings.PROCTORING_BACKENDS") \
from exc
try:
return self.backends[name]
except KeyError as error:
raise NotImplementedError(u"No proctoring backend configured for '{}'. "
u"Available: {}".format(name, list(self.backends))) from error
raise NotImplementedError("No proctoring backend configured for '{}'. "
"Available: {}".format(name, list(self.backends))) from error

def ready(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion edx_proctoring/backends/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ProctoringBackendProvider(metaclass=abc.ABCMeta):
"""
The base abstract class for all proctoring service providers
"""
verbose_name = u'Unknown'
verbose_name = 'Unknown'
ping_interval = constants.DEFAULT_DESKTOP_APPLICATION_PING_INTERVAL_SECONDS
tech_support_email = ''
learner_notification_from_email = ''
Expand Down
2 changes: 1 addition & 1 deletion edx_proctoring/backends/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class MockProctoringBackendProvider(ProctoringBackendProvider):
"""
Implementation of the ProctoringBackendProvider that bypasses proctoring setup.
"""
verbose_name = u'Mock Backend'
verbose_name = 'Mock Backend'

def __init__(self, *args, **kwargs):
ProctoringBackendProvider.__init__(self)
Expand Down
2 changes: 1 addition & 1 deletion edx_proctoring/backends/null.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class NullBackendProvider(ProctoringBackendProvider):
"""
Implementation of the ProctoringBackendProvider that does nothing
"""
verbose_name = u'Null Backend'
verbose_name = 'Null Backend'

def register_exam_attempt(self, exam, context):
"""
Expand Down
Loading

0 comments on commit d75a8f6

Please sign in to comment.