diff --git a/cms/djangoapps/contentstore/management/commands/import.py b/cms/djangoapps/contentstore/management/commands/import.py index 74df1cc5ad..bd8056a7b0 100644 --- a/cms/djangoapps/contentstore/management/commands/import.py +++ b/cms/djangoapps/contentstore/management/commands/import.py @@ -3,7 +3,7 @@ Script for importing courseware from XML format """ from django.core.management.base import BaseCommand from django_comment_common.utils import are_permissions_roles_seeded, seed_permissions_roles -from lms.djangoapps.dashboard.git_import import DEFAULT_COURSE_CODE_LIB_FILENAME +from lms.djangoapps.dashboard.git_import import DEFAULT_PYTHON_LIB_FILENAME from xmodule.contentstore.django import contentstore from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.django import modulestore @@ -24,15 +24,15 @@ class Command(BaseCommand): parser.add_argument('--nostatic', action='store_true', help='Skip import of static content') - parser.add_argument('--nocodelib', + parser.add_argument('--nopythonlib', action='store_true', help=( 'Skip import of custom code library if it exists' '(NOTE: If static content is imported, the code library will also ' 'be imported and this flag will be ignored)' )), - parser.add_argument('--code-lib-filename', - default=DEFAULT_COURSE_CODE_LIB_FILENAME, + parser.add_argument('--python-lib-filename', + default=DEFAULT_PYTHON_LIB_FILENAME, help='Filename of the course code library (if it exists)') def handle(self, *args, **options): @@ -41,8 +41,8 @@ class Command(BaseCommand): if len(source_dirs) == 0: source_dirs = None do_import_static = not options.get('nostatic', False) - do_import_code_lib = not options.get('nocodelib', False) - course_code_lib_filename = options.get('code_lib_filename') + do_import_python_lib = not options.get('nopythonlib', False) + python_lib_filename = options.get('python_lib_filename') self.stdout.write("Importing. Data_dir={data}, source_dirs={courses}\n".format( data=data_dir, @@ -53,9 +53,9 @@ class Command(BaseCommand): course_items = import_course_from_xml( mstore, ModuleStoreEnum.UserID.mgmt_command, data_dir, source_dirs, load_error_modules=False, static_content_store=contentstore(), verbose=True, - do_import_static=do_import_static, do_import_code_lib=do_import_code_lib, + do_import_static=do_import_static, do_import_python_lib=do_import_python_lib, create_if_not_present=True, - python_lib_filename=course_code_lib_filename, + python_lib_filename=python_lib_filename, ) for course in course_items: diff --git a/common/djangoapps/util/sandboxing.py b/common/djangoapps/util/sandboxing.py index fa90ec8f4f..9a2127be4f 100644 --- a/common/djangoapps/util/sandboxing.py +++ b/common/djangoapps/util/sandboxing.py @@ -1,7 +1,7 @@ import re from django.conf import settings -from lms.djangoapps.dashboard.git_import import DEFAULT_COURSE_CODE_LIB_FILENAME +from lms.djangoapps.dashboard.git_import import DEFAULT_PYTHON_LIB_FILENAME def can_execute_unsafe_code(course_id): @@ -31,7 +31,7 @@ def can_execute_unsafe_code(course_id): def get_python_lib_zip(contentstore, course_id): """Return the bytes of the course code library file, if it exists.""" - python_lib_filename = getattr(settings, 'COURSE_CODE_LIB_FILENAME', DEFAULT_COURSE_CODE_LIB_FILENAME) + python_lib_filename = getattr(settings, 'PYTHON_LIB_FILENAME', DEFAULT_PYTHON_LIB_FILENAME) asset_key = course_id.make_asset_key("asset", python_lib_filename) zip_lib = contentstore().find(asset_key, throw_on_not_found=False) if zip_lib is not None: diff --git a/common/lib/xmodule/xmodule/modulestore/xml_importer.py b/common/lib/xmodule/xmodule/modulestore/xml_importer.py index 5e0bf94ce4..342175847c 100644 --- a/common/lib/xmodule/xmodule/modulestore/xml_importer.py +++ b/common/lib/xmodule/xmodule/modulestore/xml_importer.py @@ -194,7 +194,7 @@ class ImportManager(object): default_class='xmodule.raw_module.RawDescriptor', load_error_modules=True, static_content_store=None, target_id=None, verbose=False, - do_import_static=True, do_import_code_lib=True, + do_import_static=True, do_import_python_lib=True, create_if_not_present=False, raise_on_failure=False, static_content_subdir=DEFAULT_STATIC_CONTENT_SUBDIR, python_lib_filename='python_lib.zip', @@ -210,7 +210,7 @@ class ImportManager(object): self.static_content_subdir = static_content_subdir self.python_lib_filename = python_lib_filename self.do_import_static = do_import_static - self.do_import_code_lib = do_import_code_lib + self.do_import_python_lib = do_import_python_lib self.create_if_not_present = create_if_not_present self.raise_on_failure = raise_on_failure self.xml_module_store = self.store_class( @@ -247,10 +247,10 @@ class ImportManager(object): "Skipping import of static content, " "since do_import_static=%s", self.do_import_static ) - if self.do_import_code_lib: + if self.do_import_python_lib: log.debug( "Importing code library anyway " - "since do_import_code_lib=%s", self.do_import_code_lib + "since do_import_python_lib=%s", self.do_import_python_lib ) if self.static_content_store is not None: @@ -259,7 +259,7 @@ class ImportManager(object): static_content_importer.import_static_content_directory( content_subdir=self.static_content_subdir, verbose=self.verbose ) - elif self.do_import_code_lib and self.python_lib_filename: + elif self.do_import_python_lib and self.python_lib_filename: python_lib_dir_path = data_path / self.static_content_subdir python_lib_full_path = python_lib_dir_path / self.python_lib_filename if os.path.isfile(python_lib_full_path): diff --git a/lms/djangoapps/dashboard/git_import.py b/lms/djangoapps/dashboard/git_import.py index 4a187ea9a7..2472b37430 100644 --- a/lms/djangoapps/dashboard/git_import.py +++ b/lms/djangoapps/dashboard/git_import.py @@ -22,7 +22,7 @@ from dashboard.models import CourseImportLog log = logging.getLogger(__name__) DEFAULT_GIT_REPO_DIR = '/edx/var/app/edxapp/course_repos' -DEFAULT_COURSE_CODE_LIB_FILENAME = 'python_lib.zip' +DEFAULT_PYTHON_LIB_FILENAME = 'python_lib.zip' class GitImportError(Exception): @@ -185,8 +185,8 @@ def add_repo(repo, rdir_in, branch=None): git_repo_dir = getattr(settings, 'GIT_REPO_DIR', DEFAULT_GIT_REPO_DIR) git_import_static = getattr(settings, 'GIT_IMPORT_STATIC', True) - git_import_code_lib = getattr(settings, 'GIT_IMPORT_CODE_LIB', True) - course_code_lib_filename = getattr(settings, 'COURSE_CODE_LIB_FILENAME', DEFAULT_COURSE_CODE_LIB_FILENAME) + git_import_python_lib = getattr(settings, 'GIT_IMPORT_PYTHON_LIB', True) + python_lib_filename = getattr(settings, 'PYTHON_LIB_FILENAME', DEFAULT_PYTHON_LIB_FILENAME) # Set defaults even if it isn't defined in settings mongo_db = { @@ -276,8 +276,8 @@ def add_repo(repo, rdir_in, branch=None): try: management.call_command( 'import', git_repo_dir, rdir, - nostatic=not git_import_static, nocodelib=not git_import_code_lib, - code_lib_filename=course_code_lib_filename + nostatic=not git_import_static, nopythonlib=not git_import_python_lib, + python_lib_filename=python_lib_filename ) except CommandError: raise GitImportErrorXmlImportFailed() diff --git a/lms/envs/aws.py b/lms/envs/aws.py index 55981d8c8e..3aa5e39ba1 100644 --- a/lms/envs/aws.py +++ b/lms/envs/aws.py @@ -371,8 +371,8 @@ BADGR_TIMEOUT = ENV_TOKENS.get('BADGR_TIMEOUT', BADGR_TIMEOUT) # git repo loading environment GIT_REPO_DIR = ENV_TOKENS.get('GIT_REPO_DIR', '/edx/var/edxapp/course_repos') GIT_IMPORT_STATIC = ENV_TOKENS.get('GIT_IMPORT_STATIC', True) -GIT_IMPORT_CODE_LIB = ENV_TOKENS.get('GIT_IMPORT_CODE_LIB', True) -COURSE_CODE_LIB_FILENAME = ENV_TOKENS.get('COURSE_CODE_LIB_FILENAME', 'python_lib.zip') +GIT_IMPORT_PYTHON_LIB = ENV_TOKENS.get('GIT_IMPORT_PYTHON_LIB', True) +PYTHON_LIB_FILENAME = ENV_TOKENS.get('PYTHON_LIB_FILENAME', 'python_lib.zip') for name, value in ENV_TOKENS.get("CODE_JAIL", {}).items(): oldvalue = CODE_JAIL.get(name)