diff --git a/common/djangoapps/entitlements/models.py b/common/djangoapps/entitlements/models.py index 08e9369038..348c87f92a 100644 --- a/common/djangoapps/entitlements/models.py +++ b/common/djangoapps/entitlements/models.py @@ -444,7 +444,7 @@ class CourseEntitlement(TimeStampedModel): refund_successful = refund_entitlement(course_entitlement=self) if not refund_successful: # This state is achieved in most cases by a failure in the ecommerce service to process the refund. - log.warn( + log.warning( u'Entitlement Refund failed for Course Entitlement [%s], alert User', self.uuid ) diff --git a/common/lib/xmodule/xmodule/conditional_module.py b/common/lib/xmodule/xmodule/conditional_module.py index bb3f141caf..cd45d7b835 100644 --- a/common/lib/xmodule/xmodule/conditional_module.py +++ b/common/lib/xmodule/xmodule/conditional_module.py @@ -166,7 +166,7 @@ class ConditionalModule(ConditionalFields, XModule, StudioEditableModule): if module is not None: # We do not want to log when module is None, and it is when requester # does not have access to the requested required module. - log.warn('Error in conditional module: \ + log.warning('Error in conditional module: \ required module {module} has no {module_attr}'.format(module=module, module_attr=attr_name)) return False diff --git a/common/lib/xmodule/xmodule/modulestore/split_migrator.py b/common/lib/xmodule/xmodule/modulestore/split_migrator.py index 1fcc9f8645..68af627aca 100644 --- a/common/lib/xmodule/xmodule/modulestore/split_migrator.py +++ b/common/lib/xmodule/xmodule/modulestore/split_migrator.py @@ -170,7 +170,7 @@ class SplitMigrator(object): draft_location, revision=ModuleStoreEnum.RevisionOption.draft_preferred, **kwargs ) if parent_loc is None: - log.warn(u'No parent found in source course for %s', draft_location) + log.warning(u'No parent found in source course for %s', draft_location) continue old_parent = self.source_modulestore.get_item(parent_loc, **kwargs) split_parent_loc = new_draft_course_loc.make_usage_key( diff --git a/common/lib/xmodule/xmodule/video_module/video_utils.py b/common/lib/xmodule/xmodule/video_module/video_utils.py index d05464ea68..8b6f0e3bee 100644 --- a/common/lib/xmodule/xmodule/video_module/video_utils.py +++ b/common/lib/xmodule/xmodule/video_module/video_utils.py @@ -69,7 +69,7 @@ def rewrite_video_url(cdn_base_url, original_video_url): validator(rewritten_url) return rewritten_url except ValidationError: - log.warn("Invalid CDN rewrite URL encountered, %s", rewritten_url) + log.warning("Invalid CDN rewrite URL encountered, %s", rewritten_url) # Mimic the behavior of removed get_video_from_cdn in this regard and # return None causing the caller to use the original URL. diff --git a/lms/djangoapps/commerce/utils.py b/lms/djangoapps/commerce/utils.py index 1c6ea8be4a..e82f469603 100644 --- a/lms/djangoapps/commerce/utils.py +++ b/lms/djangoapps/commerce/utils.py @@ -208,7 +208,7 @@ def refund_entitlement(course_entitlement): always_notify=True, ) else: - log.warn(u'No refund opened for user [%s], course entitlement [%s]', enrollee.id, entitlement_uuid) + log.warning(u'No refund opened for user [%s], course entitlement [%s]', enrollee.id, entitlement_uuid) return False diff --git a/openedx/core/djangoapps/course_date_signals/__init__.py b/openedx/core/djangoapps/course_date_signals/__init__.py index e69de29bb2..4d9e1da841 100644 --- a/openedx/core/djangoapps/course_date_signals/__init__.py +++ b/openedx/core/djangoapps/course_date_signals/__init__.py @@ -0,0 +1,5 @@ +""" +Django app to manage course content dates, and ingesting them into edx-when for later use by the LMS. +""" + +default_app_config = 'openedx.core.djangoapps.course_date_signals.apps.CourseDatesSignalsConfig' # pylint: disable=invalid-name diff --git a/openedx/core/djangoapps/course_date_signals/apps.py b/openedx/core/djangoapps/course_date_signals/apps.py index 70fb3a1526..17119d49e3 100644 --- a/openedx/core/djangoapps/course_date_signals/apps.py +++ b/openedx/core/djangoapps/course_date_signals/apps.py @@ -1,12 +1,12 @@ """ -Django app configuration for openedx.core.djangoapps.course_dates_signals +Django App Configuration for the course_date_signals app """ from django.apps import AppConfig class CourseDatesSignalsConfig(AppConfig): - name = 'openedx.core.djangoapps.course_dates_signals' + name = 'openedx.core.djangoapps.course_date_signals' def ready(self): """ diff --git a/openedx/core/djangoapps/course_date_signals/handlers.py b/openedx/core/djangoapps/course_date_signals/handlers.py index 2544356bd0..f88648d32a 100644 --- a/openedx/core/djangoapps/course_date_signals/handlers.py +++ b/openedx/core/djangoapps/course_date_signals/handlers.py @@ -7,18 +7,17 @@ from django.dispatch import receiver from six import text_type from xblock.fields import Scope from xmodule.modulestore.django import SignalHandler, modulestore - from edx_when.api import FIELDS_TO_EXTRACT, set_dates_for_course log = logging.getLogger(__name__) -def date_field_values(date_fields, xblock): +def _field_values(fields, xblock): """ - Read field values for the specified date fields from the supplied xblock. + Read field values for the specified fields from the supplied xblock. """ result = {} - for field_name in date_fields: + for field_name in fields: if field_name not in xblock.fields: continue field = xblock.fields[field_name] @@ -39,18 +38,18 @@ def extract_dates_from_course(course): """ Extract all dates from the supplied course. """ - log.info('Publishing course dates for %s', course.id) + log.info('Extracting course dates for %s', course.id) if course.self_paced: - metadata = date_field_values(FIELDS_TO_EXTRACT, course) + metadata = _field_values(FIELDS_TO_EXTRACT, course) # self-paced courses may accidentally have a course due date metadata.pop('due', None) date_items = [(course.location, metadata)] else: date_items = [] items = modulestore().get_items(course.id) - log.info('extracting dates from %d items in %s', len(items), course.id) + log.info('Extracting dates from %d items in %s', len(items), course.id) for item in items: - date_items.append((item.location, date_field_values(FIELDS_TO_EXTRACT, item))) + date_items.append((item.location, _field_values(FIELDS_TO_EXTRACT, item))) return date_items @@ -59,12 +58,10 @@ def extract_dates(sender, course_key, **kwargs): # pylint: disable=unused-argum """ Extract dates from blocks when publishing a course. """ - log.info("Extracting dates from %s", course_key) - course = modulestore().get_course(course_key) if not course: - log.info("No course found for key %s", course_key) + log.info("No course found for key %s to extract dates from", course_key) return date_items = extract_dates_from_course(course) @@ -72,4 +69,4 @@ def extract_dates(sender, course_key, **kwargs): # pylint: disable=unused-argum try: set_dates_for_course(course_key, date_items) except Exception: # pylint: disable=broad-except - log.exception('setting dates for %s', course_key) + log.exception('Unable to set dates for %s on course publish', course_key) diff --git a/openedx/core/djangoapps/django_comment_common/models.py b/openedx/core/djangoapps/django_comment_common/models.py index 6f11b1165e..efd2709ead 100644 --- a/openedx/core/djangoapps/django_comment_common/models.py +++ b/openedx/core/djangoapps/django_comment_common/models.py @@ -1,4 +1,4 @@ -# pylint: disable=missing-docstring,unused-argument,model-missing-unicode +# pylint: disable=missing-docstring,unused-argument import json diff --git a/openedx/core/djangoapps/geoinfo/middleware.py b/openedx/core/djangoapps/geoinfo/middleware.py index 6f0399d9ed..dbc01ec95a 100644 --- a/openedx/core/djangoapps/geoinfo/middleware.py +++ b/openedx/core/djangoapps/geoinfo/middleware.py @@ -41,7 +41,6 @@ class CountryMiddleware(MiddlewareMixin): reader = geoip2.database.Reader(settings.GEOIP_PATH) try: response = reader.country(new_ip_address) - # pylint: disable=no-member country_code = response.country.iso_code except geoip2.errors.AddressNotFoundError: country_code = "" diff --git a/openedx/core/djangoapps/site_configuration/tests/test_middleware.py b/openedx/core/djangoapps/site_configuration/tests/test_middleware.py index 890c6453c2..1932b7e104 100644 --- a/openedx/core/djangoapps/site_configuration/tests/test_middleware.py +++ b/openedx/core/djangoapps/site_configuration/tests/test_middleware.py @@ -4,9 +4,6 @@ Test site_configuration middleware. """ -from mock import patch - -from django.conf import settings from django.test import TestCase from django.test.client import Client from django.test.utils import override_settings