diff --git a/cms/djangoapps/contentstore/views/preview.py b/cms/djangoapps/contentstore/views/preview.py index b188036492..29ebd1492c 100644 --- a/cms/djangoapps/contentstore/views/preview.py +++ b/cms/djangoapps/contentstore/views/preview.py @@ -16,7 +16,7 @@ from xmodule.modulestore.django import modulestore from xmodule.x_module import ModuleSystem from xblock.runtime import DbModel -from lms.xblock.field_data import LmsFieldData +from lms.lib.xblock.field_data import LmsFieldData from util.sandboxing import can_execute_unsafe_code diff --git a/cms/envs/common.py b/cms/envs/common.py index 3434185209..5d72556e52 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -28,7 +28,7 @@ import lms.envs.common from lms.envs.common import USE_TZ, TECH_SUPPORT_EMAIL, PLATFORM_NAME, BUGS_EMAIL from path import path -from lms.xblock.mixin import LmsBlockMixin +from lms.lib.xblock.mixin import LmsBlockMixin from cms.xmodule_namespace import CmsBlockMixin from xmodule.modulestore.inheritance import InheritanceMixin from xmodule.x_module import XModuleMixin diff --git a/common/djangoapps/student/management/commands/sync_user_info.py b/common/djangoapps/student/management/commands/sync_user_info.py index 04257e2a5d..d7fdd3323f 100644 --- a/common/djangoapps/student/management/commands/sync_user_info.py +++ b/common/djangoapps/student/management/commands/sync_user_info.py @@ -4,7 +4,7 @@ from django.core.management.base import BaseCommand from django.contrib.auth.models import User -import comment_client as cc +import lms.lib.comment_client as cc class Command(BaseCommand): diff --git a/common/djangoapps/student/models.py b/common/djangoapps/student/models.py index 6387f282e1..e1c4ff1123 100644 --- a/common/djangoapps/student/models.py +++ b/common/djangoapps/student/models.py @@ -27,7 +27,7 @@ import django.dispatch from django.forms import ModelForm, forms from course_modes.models import CourseMode -import comment_client as cc +import lms.lib.comment_client as cc from pytz import UTC import crum diff --git a/common/lib/logsettings.py b/common/lib/logsettings.py index 26ef3c8478..aff9f81237 100644 --- a/common/lib/logsettings.py +++ b/common/lib/logsettings.py @@ -82,7 +82,7 @@ def get_logger_config(log_dir, }, 'newrelic': { 'level': 'ERROR', - 'class': 'newrelic_logging.NewRelicHandler', + 'class': 'lms.lib.newrelic_logging.NewRelicHandler', 'formatter': 'raw', } }, diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index 863c71f372..4529b1e280 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -20,7 +20,7 @@ from capa.xqueue_interface import XQueueInterface from courseware.access import has_access from courseware.masquerade import setup_masquerade from courseware.model_data import FieldDataCache, DjangoKeyValueStore -from lms.xblock.field_data import LmsFieldData +from lms.lib.xblock.field_data import LmsFieldData from mitxmako.shortcuts import render_to_string from psychometrics.psychoanalyze import make_psychometrics_data_update_handler from student.models import unique_id_for_user diff --git a/lms/djangoapps/courseware/tests/__init__.py b/lms/djangoapps/courseware/tests/__init__.py index 3fcfd42324..e64cb539f1 100644 --- a/lms/djangoapps/courseware/tests/__init__.py +++ b/lms/djangoapps/courseware/tests/__init__.py @@ -21,7 +21,7 @@ from xmodule.modulestore import Location from xmodule.modulestore.django import modulestore from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase -from lms.xblock.field_data import LmsFieldData +from lms.lib.xblock.field_data import LmsFieldData @override_settings(MODULESTORE=TEST_DATA_MIXED_MODULESTORE) diff --git a/lms/djangoapps/courseware/tests/tests.py b/lms/djangoapps/courseware/tests/tests.py index 1ab22060ce..a6a265763d 100644 --- a/lms/djangoapps/courseware/tests/tests.py +++ b/lms/djangoapps/courseware/tests/tests.py @@ -20,7 +20,7 @@ from courseware.tests.modulestore_config import TEST_DATA_DIR, \ TEST_DATA_MONGO_MODULESTORE, \ TEST_DATA_DRAFT_MONGO_MODULESTORE, \ TEST_DATA_MIXED_MODULESTORE -from lms.xblock.field_data import LmsFieldData +from lms.lib.xblock.field_data import LmsFieldData class ActivateLoginTest(LoginEnrollmentTestCase): diff --git a/lms/djangoapps/django_comment_client/base/tests.py b/lms/djangoapps/django_comment_client/base/tests.py index 473cce917a..8709d670eb 100644 --- a/lms/djangoapps/django_comment_client/base/tests.py +++ b/lms/djangoapps/django_comment_client/base/tests.py @@ -18,7 +18,7 @@ log = logging.getLogger(__name__) @override_settings(MODULESTORE=TEST_DATA_MIXED_MODULESTORE) -@patch('comment_client.utils.requests.request') +@patch('lms.lib.comment_client.utils.requests.request') class ViewsTestCase(UrlResetMixin, ModuleStoreTestCase): @patch.dict("django.conf.settings.MITX_FEATURES", {"ENABLE_DISCUSSION_SERVICE": True}) diff --git a/lms/djangoapps/django_comment_client/base/views.py b/lms/djangoapps/django_comment_client/base/views.py index c6ea414f82..4600f121f7 100644 --- a/lms/djangoapps/django_comment_client/base/views.py +++ b/lms/djangoapps/django_comment_client/base/views.py @@ -6,7 +6,7 @@ import logging import urlparse import functools -import comment_client as cc +import lms.lib.comment_client as cc import django_comment_client.utils as utils import django_comment_client.settings as cc_settings @@ -72,7 +72,7 @@ def create_thread(request, course_id, commentable_id): """ Given a course and commentble ID, create the thread """ - + log.debug("Creating new thread in %r, id %r", course_id, commentable_id) course = get_course_with_access(request.user, course_id, 'load') post = request.POST diff --git a/lms/djangoapps/django_comment_client/forum/views.py b/lms/djangoapps/django_comment_client/forum/views.py index fb53f3c0b7..dac91512d6 100644 --- a/lms/djangoapps/django_comment_client/forum/views.py +++ b/lms/djangoapps/django_comment_client/forum/views.py @@ -17,7 +17,7 @@ from courseware.access import has_access from django_comment_client.permissions import cached_has_permission from django_comment_client.utils import (merge_dict, extract, strip_none, add_courseware_context) import django_comment_client.utils as utils -import comment_client as cc +import lms.lib.comment_client as cc THREADS_PER_PAGE = 20 INLINE_THREADS_PER_PAGE = 20 diff --git a/lms/djangoapps/django_comment_client/management/commands/reload_forum_users.py b/lms/djangoapps/django_comment_client/management/commands/reload_forum_users.py index 53d76cda8f..81154da69a 100644 --- a/lms/djangoapps/django_comment_client/management/commands/reload_forum_users.py +++ b/lms/djangoapps/django_comment_client/management/commands/reload_forum_users.py @@ -4,7 +4,7 @@ Reload forum (comment client) users from existing users. from django.core.management.base import BaseCommand from django.contrib.auth.models import User -import comment_client as cc +import lms.lib.comment_client as cc class Command(BaseCommand): diff --git a/lms/djangoapps/django_comment_client/middleware.py b/lms/djangoapps/django_comment_client/middleware.py index 3a4031f871..7e2daab8ac 100644 --- a/lms/djangoapps/django_comment_client/middleware.py +++ b/lms/djangoapps/django_comment_client/middleware.py @@ -1,4 +1,4 @@ -from comment_client import CommentClientRequestError +from lms.lib.comment_client import CommentClientRequestError from django_comment_client.utils import JsonError import json import logging diff --git a/lms/xblock/__init__.py b/lms/djangoapps/django_comment_client/tests/__init__.py similarity index 100% rename from lms/xblock/__init__.py rename to lms/djangoapps/django_comment_client/tests/__init__.py diff --git a/lms/djangoapps/django_comment_client/tests/test_middleware.py b/lms/djangoapps/django_comment_client/tests/test_middleware.py index 6b21fe056d..a7e869fac0 100644 --- a/lms/djangoapps/django_comment_client/tests/test_middleware.py +++ b/lms/djangoapps/django_comment_client/tests/test_middleware.py @@ -2,7 +2,7 @@ import django.http from django.test import TestCase import json -import comment_client +import lms.lib.comment_client import django_comment_client.middleware as middleware @@ -11,9 +11,9 @@ class AjaxExceptionTestCase(TestCase): self.a = middleware.AjaxExceptionMiddleware() self.request1 = django.http.HttpRequest() self.request0 = django.http.HttpRequest() - self.exception1 = comment_client.CommentClientRequestError('{}', 401) - self.exception2 = comment_client.CommentClientRequestError('Foo!', 404) - self.exception0 = comment_client.CommentClient500Error("Holy crap the server broke!") + self.exception1 = lms.lib.comment_client.CommentClientRequestError('{}', 401) + self.exception2 = lms.lib.comment_client.CommentClientRequestError('Foo!', 404) + self.exception0 = lms.lib.comment_client.CommentClient500Error("Holy crap the server broke!") self.request1.META['HTTP_X_REQUESTED_WITH'] = "XMLHttpRequest" self.request0.META['HTTP_X_REQUESTED_WITH'] = "SHADOWFAX" diff --git a/lms/djangoapps/django_comment_client/tests/test_utils.py b/lms/djangoapps/django_comment_client/tests/test_utils.py index 4ba950ace6..acc0d4655f 100644 --- a/lms/djangoapps/django_comment_client/tests/test_utils.py +++ b/lms/djangoapps/django_comment_client/tests/test_utils.py @@ -4,7 +4,7 @@ from django.test import TestCase from django.test.utils import override_settings from student.tests.factories import UserFactory, CourseEnrollmentFactory from django_comment_common.models import Role, Permission -from factories import RoleFactory +from django_comment_client.tests.factories import RoleFactory import django_comment_client.utils as utils from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase diff --git a/lms/envs/common.py b/lms/envs/common.py index de148ef3c8..8420e53ab1 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -30,7 +30,7 @@ from path import path from .discussionsettings import * -from lms.xblock.mixin import LmsBlockMixin +from lms.lib.xblock.mixin import LmsBlockMixin from xmodule.modulestore.inheritance import InheritanceMixin from xmodule.x_module import XModuleMixin @@ -213,9 +213,9 @@ COURSES_ROOT = ENV_ROOT / "data" DATA_DIR = COURSES_ROOT +# TODO: Remove the rest of the sys.path modification here and in cms/envs/common.py sys.path.append(REPO_ROOT) sys.path.append(PROJECT_ROOT / 'djangoapps') -sys.path.append(PROJECT_ROOT / 'lib') sys.path.append(COMMON_ROOT / 'djangoapps') sys.path.append(COMMON_ROOT / 'lib') @@ -917,7 +917,7 @@ INSTALLED_APPS = ( # Our courseware 'circuit', 'courseware', - 'perfstats', + 'lms.lib.perfstats', 'student', 'static_template_view', 'staticbook', diff --git a/lms/lib/__init__.py b/lms/lib/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lms/lib/xblock/__init__.py b/lms/lib/xblock/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lms/xblock/field_data.py b/lms/lib/xblock/field_data.py similarity index 92% rename from lms/xblock/field_data.py rename to lms/lib/xblock/field_data.py index 03b3deafac..e26897b884 100644 --- a/lms/xblock/field_data.py +++ b/lms/lib/xblock/field_data.py @@ -16,7 +16,7 @@ class LmsFieldData(SplitFieldData): def __init__(self, authored_data, student_data): # Make sure that we don't repeatedly nest LmsFieldData instances if isinstance(authored_data, LmsFieldData): - authored_data = authored_data._authored_data + authored_data = authored_data._authored_data # pylint: disable=protected-member else: authored_data = ReadOnlyFieldData(authored_data) diff --git a/lms/xblock/mixin.py b/lms/lib/xblock/mixin.py similarity index 100% rename from lms/xblock/mixin.py rename to lms/lib/xblock/mixin.py diff --git a/lms/urls.py b/lms/urls.py index 7186cfff3b..765c714da7 100644 --- a/lms/urls.py +++ b/lms/urls.py @@ -144,7 +144,7 @@ for key, value in settings.MKTG_URL_LINK_MAP.items(): if settings.PERFSTATS: - urlpatterns += (url(r'^reprofile$', 'perfstats.views.end_profile'),) + urlpatterns += (url(r'^reprofile$', 'lms.lib.perfstats.views.end_profile'),) # Multicourse wiki (Note: wiki urls must be above the courseware ones because of # the custom tab catch-all) diff --git a/rakelib/quality.rake b/rakelib/quality.rake index dd34b0ccf4..0add71f727 100644 --- a/rakelib/quality.rake +++ b/rakelib/quality.rake @@ -1,5 +1,10 @@ def run_pylint(system, report_dir, flags='') - apps = Dir["#{system}", "#{system}/djangoapps/*", "#{system}/lib/*"].map do |app| + apps = Dir["#{system}", "#{system}/djangoapps/*"] + if system != 'lms' + apps += Dir["#{system}/lib/*"] + end + + apps.map do |app| File.basename(app) end.select do |app| app !=~ /.pyc$/ diff --git a/setup.cfg b/setup.cfg index abc86c43fd..45d3aa27cf 100644 --- a/setup.cfg +++ b/setup.cfg @@ -7,6 +7,10 @@ with-id=1 exclude-dir=lms/envs cms/envs +# Without this flag, nose adds /lib directories to the path, +# which shadows the xblock library (among other things) +no-path-adjustment=1 + # Uncomment the following lines to open pdb when a test fails #nocapture=1 #pdb=1