diff --git a/cms/djangoapps/contentstore/management/commands/import-library.py b/cms/djangoapps/contentstore/management/commands/import-library.py index 05b40603b17d..f1c283451f0f 100644 --- a/cms/djangoapps/contentstore/management/commands/import-library.py +++ b/cms/djangoapps/contentstore/management/commands/import-library.py @@ -12,11 +12,12 @@ from xmodule.modulestore.django import modulestore from xmodule.modulestore.xml_importer import import_library_from_xml + class Command(BaseCommand): """ Import the specified library data directory into the default ModuleStore """ - help = """ + help = """ Import the specified library(s) data directory into the default ModuleStore Usage: cms import-library [--nostatic] [...] @@ -30,7 +31,7 @@ class Command(BaseCommand): action='store_true', help='Skip import of static content'), ) - + def handle(self, *args, **options): """ Execute the command @@ -38,25 +39,25 @@ def handle(self, *args, **options): do_import_static = not options.get('nostatic', False) if len(args) < 2: raise CommandError("ERROR: import-library requires at least two arguments: [--nostatic] [...]") - + data_dir = args[0] if len(args) > 1: source_dirs = args[1:] else: raise CommandError("ERROR: import-library requires at least one library_dir as argument") - + self.stdout.write("Importing. Data_dir={data}, source_dirs={courses}\n".format( data=data_dir, courses=source_dirs, )) - + course_items = import_library_from_xml( modulestore(), ModuleStoreEnum.UserID.mgmt_command, data_dir, source_dirs, load_error_modules=False, static_content_store=contentstore(), verbose=True, do_import_static=do_import_static, create_if_not_present=True, ) - + if course_items: self.stdout.write("Successfully imported {} libraries.\n".format(len(course_items))) else: diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_import_library.py b/cms/djangoapps/contentstore/management/commands/tests/test_import_library.py index 108514faf237..872127916ac6 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_import_library.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_import_library.py @@ -15,6 +15,7 @@ from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase + @ddt.ddt class TestImportLibrary(ModuleStoreTestCase): """ @@ -56,7 +57,7 @@ def test_library_import(self): Compare library_key of imported library with self-generated """ self.assertEqual(unicode(self.library_from_store.location.library_key), unicode(self.library_key)) - """ + """ Compare display_name of imported library with original """ self.assertEqual(unicode(self.library_from_store), u"Library: " + unicode(self.display_name)) @@ -66,4 +67,3 @@ def test_library_import_invalid_dirs(self, invalid_source_dir): errstring = "Imported libraries count is zero" with self.assertRaisesRegexp(CommandError, errstring): call_command('import-library', self.content_dir, invalid_source_dir) - diff --git a/cms/envs/static_collector.py b/cms/envs/static_collector.py index a7e9738297db..d5ee0ebd9d5a 100644 --- a/cms/envs/static_collector.py +++ b/cms/envs/static_collector.py @@ -3,5 +3,5 @@ EDX_PLATFORM_STATIC_ROOT_BASE = settings.STATIC_ROOT_BASE -STATIC_ROOT_BASE=os.environ.get('STATIC_COLLECTOR_ROOT', '/edx/var/edxapp/static_collector') +STATIC_ROOT_BASE = os.environ.get('STATIC_COLLECTOR_ROOT', '/edx/var/edxapp/static_collector') STATIC_ROOT = path(STATIC_ROOT_BASE) / EDX_PLATFORM_REVISION diff --git a/lms/djangoapps/bulk_email/models.py b/lms/djangoapps/bulk_email/models.py index a4ea19578a8f..8399d0504a55 100644 --- a/lms/djangoapps/bulk_email/models.py +++ b/lms/djangoapps/bulk_email/models.py @@ -165,9 +165,10 @@ class CourseEmail(Email): class Meta(object): app_label = "bulk_email" - DEFAULT_FROM_EMAIL = (settings.FEATURES.get('BULK_EMAIL_FROM_DIFFERENT_ADDRESSES') - and None - or getattr(settings, 'BULK_EMAIL_DEFAULT_FROM_EMAIL', None)) + DEFAULT_FROM_EMAIL = ( + settings.FEATURES.get('BULK_EMAIL_FROM_DIFFERENT_ADDRESSES') and None + or getattr(settings, 'BULK_EMAIL_DEFAULT_FROM_EMAIL', None) + ) course_id = CourseKeyField(max_length=255, db_index=True) # to_option is deprecated and unused, but dropping db columns is hard so it's still here for legacy reasons @@ -399,4 +400,4 @@ def __unicode__(self): return u"BulkEmailFlag: enabled {}, require_course_email_auth: {}".format( current_model.is_enabled(), current_model.require_course_email_auth -) + ) diff --git a/lms/djangoapps/certificates/tests/test_webview_views.py b/lms/djangoapps/certificates/tests/test_webview_views.py index 00c91f897fa0..90a0d2096baf 100644 --- a/lms/djangoapps/certificates/tests/test_webview_views.py +++ b/lms/djangoapps/certificates/tests/test_webview_views.py @@ -1161,9 +1161,9 @@ def test_certificate_evidence_event_emitted(self): course_id=unicode(self.course.id) ) new_user = UserFactory.create( - email='other_user@edx.org', - username='other_user', - password='foo' + email='other_user@edx.org', + username='other_user', + password='foo' ) new_user.profile.name = "Other User" new_user.profile.save() diff --git a/lms/djangoapps/dashboard/sysadmin.py b/lms/djangoapps/dashboard/sysadmin.py index 10d3f742aa47..7663c48c8be2 100644 --- a/lms/djangoapps/dashboard/sysadmin.py +++ b/lms/djangoapps/dashboard/sysadmin.py @@ -502,7 +502,7 @@ def post(self, request): result_ids = [result["data"]["id"] for result in response["results"]] self._searcher.remove('courseware_content', result_ids) self._searcher.remove('course_info', [course_id]) - except Exception as e: # pragma: no cover + except Exception as e: # pragma: no cover log.error(e.message) CourseOverview.objects.filter(id=course.id).delete() diff --git a/lms/djangoapps/instructor/enrollment.py b/lms/djangoapps/instructor/enrollment.py index f139dca3a333..ff88714d7f5f 100644 --- a/lms/djangoapps/instructor/enrollment.py +++ b/lms/djangoapps/instructor/enrollment.py @@ -485,8 +485,12 @@ def send_mail_to_student(student, param_dict, language=None): ) try: - subject, html_message = render_message_to_string(subject_template, - html_message_template, param_dict, language=language) + subject, html_message = render_message_to_string( + subject_template, + html_message_template, + param_dict, + language=language + ) except: html_message = None diff --git a/lms/djangoapps/instructor_task/models.py b/lms/djangoapps/instructor_task/models.py index e6bd3bfa74d2..0c9c6f1a1d90 100644 --- a/lms/djangoapps/instructor_task/models.py +++ b/lms/djangoapps/instructor_task/models.py @@ -309,9 +309,9 @@ def links_for(self, course_id): files = [(filename, os.path.join(course_dir, filename)) for filename in filenames] files.sort(key=lambda f: self.storage.modified_time(f[1]), reverse=True) - if (settings.GRADES_DOWNLOAD['STORAGE_TYPE']=='azure' or settings.GRADES_DOWNLOAD['STORAGE_TYPE']=='s3'): + if (settings.GRADES_DOWNLOAD['STORAGE_TYPE'] == 'azure' or settings.GRADES_DOWNLOAD['STORAGE_TYPE'] == 's3'): return [ - (filename, self.storage.url(full_path)) + (filename, self.storage.url(full_path)) for filename, full_path in files ] else: diff --git a/lms/djangoapps/shoppingcart/models.py b/lms/djangoapps/shoppingcart/models.py index 1ffc90f36520..80c06479e85c 100644 --- a/lms/djangoapps/shoppingcart/models.py +++ b/lms/djangoapps/shoppingcart/models.py @@ -380,22 +380,22 @@ def send_confirmation_emails(self, orderitems, is_order_type_business, csv_file, for recipient in recipient_list: email_context = { 'order': self, - 'recipient_name': recipient[0], - 'recipient_type': recipient[2], - 'site_name': site_name, - 'order_items': orderitems, - 'course_names': ", ".join(course_names), - 'dashboard_url': dashboard_url, - 'currency_symbol': settings.PAID_COURSE_REGISTRATION_CURRENCY[1], - 'order_placed_by': '{username} ({email})'.format( - username=self.user.username, email=self.user.email - ), - 'has_billing_info': settings.FEATURES['STORE_BILLING_INFO'], - 'platform_name': configuration_helpers.get_value('platform_name', settings.PLATFORM_NAME), - 'payment_support_email': configuration_helpers.get_value( - 'payment_support_email', settings.PAYMENT_SUPPORT_EMAIL, - ), - 'payment_email_signature': configuration_helpers.get_value('payment_email_signature'), + 'recipient_name': recipient[0], + 'recipient_type': recipient[2], + 'site_name': site_name, + 'order_items': orderitems, + 'course_names': ", ".join(course_names), + 'dashboard_url': dashboard_url, + 'currency_symbol': settings.PAID_COURSE_REGISTRATION_CURRENCY[1], + 'order_placed_by': '{username} ({email})'.format( + username=self.user.username, email=self.user.email + ), + 'has_billing_info': settings.FEATURES['STORE_BILLING_INFO'], + 'platform_name': configuration_helpers.get_value('platform_name', settings.PLATFORM_NAME), + 'payment_support_email': configuration_helpers.get_value( + 'payment_support_email', settings.PAYMENT_SUPPORT_EMAIL, + ), + 'payment_email_signature': configuration_helpers.get_value('payment_email_signature'), } message = render_to_string( 'emails/business_order_confirmation_email.txt' if is_order_type_business else 'emails/order_confirmation_email.txt', diff --git a/lms/envs/aws.py b/lms/envs/aws.py index 4394913cceb5..2050f228f68c 100644 --- a/lms/envs/aws.py +++ b/lms/envs/aws.py @@ -918,4 +918,3 @@ ORA2_FILEUPLOAD_ROOT = ENV_TOKENS.get('ORA2_FILEUPLOAD_ROOT', ORA2_FILEUPLOAD_ROOT) SEARCH_SKIP_ENROLLMENT_START_DATE_FILTERING = FEATURES.get("SEARCH_SKIP_ENROLLMENT_START_DATE_FILTERING", True) #### RaccoonGang #### - diff --git a/lms/envs/common.py b/lms/envs/common.py index 20b62e56745e..1931aaf34885 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -3041,4 +3041,3 @@ ############## Settings for the Enterprise App ###################### ENTERPRISE_ENROLLMENT_API_URL = LMS_ROOT_URL + "/api/enrollment/v1/" - diff --git a/lms/envs/static_collector.py b/lms/envs/static_collector.py index cf5f20d20a11..0bd0afa6615c 100644 --- a/lms/envs/static_collector.py +++ b/lms/envs/static_collector.py @@ -3,5 +3,5 @@ EDX_PLATFORM_STATIC_ROOT_BASE = settings.STATIC_ROOT_BASE -STATIC_ROOT_BASE=os.environ.get('STATIC_COLLECTOR_ROOT', '/edx/var/edxapp/static_collector') +STATIC_ROOT_BASE = os.environ.get('STATIC_COLLECTOR_ROOT', '/edx/var/edxapp/static_collector') STATIC_ROOT = path(STATIC_ROOT_BASE) diff --git a/openedx/core/djangoapps/dark_lang/middleware.py b/openedx/core/djangoapps/dark_lang/middleware.py index a408d10712a8..622059f204de 100644 --- a/openedx/core/djangoapps/dark_lang/middleware.py +++ b/openedx/core/djangoapps/dark_lang/middleware.py @@ -147,7 +147,7 @@ def process_request(self, request): if not DarkLangConfig.current().enabled: return - reload(sys) + reload(sys) sys.setdefaultencoding('utf8') language = translation.get_language_from_request(request) @@ -155,4 +155,3 @@ def process_request(self, request): locale.setlocale(locale.LC_ALL, settings.LOCALESET_FROM_REQUEST.get(language)) except: pass - diff --git a/openedx/core/storage.py b/openedx/core/storage.py index 7f276e4b2460..a5352cd06a0f 100644 --- a/openedx/core/storage.py +++ b/openedx/core/storage.py @@ -25,6 +25,7 @@ from storages.backends.azure_storage import AzureStorage from azure.storage import AccessPolicy, SharedAccessPolicy + class ProductionStorage( PipelineForgivingStorage, OptimizedFilesMixin, diff --git a/pavelib/assets.py b/pavelib/assets.py index 6c56f4b7f5ec..fcd8e6830de7 100644 --- a/pavelib/assets.py +++ b/pavelib/assets.py @@ -22,7 +22,7 @@ from openedx.core.djangoapps.theming.paver_helpers import get_theme_paths -from pwd import getpwnam +from pwd import getpwnam from django.core.wsgi import get_wsgi_application from django.conf import settings as django_settings @@ -83,9 +83,11 @@ # Collectstatic log directory setting COLLECTSTATIC_LOG_DIR_ARG = "collect_log_dir" + def get_static_collector_root(): return os.environ.get('STATIC_COLLECTOR_ROOT', '/edx/var/edxapp/static_collector') + def get_sass_directories(system, theme_dir=None): """ Determine the set of SASS directories to be compiled for the specified list of system and theme @@ -663,6 +665,7 @@ def collect_assets(systems, settings, **kwargs): ))) print("\t\tFinished collecting {} assets.".format(sys)) + def _collect_assets_cmd(system, **kwargs): """ Returns the collecstatic command to be used for the given system @@ -783,6 +786,7 @@ def watch_assets(options): observer.stop() print("\nStopped asset watcher.") + @task @needs( 'pavelib.prereqs.install_node_prereqs', @@ -837,7 +841,7 @@ def update_assets(args): if args.system[0] == 'studio': current_sys = 'cms' - os.environ.setdefault("SERVICE_VARIANT","{sys}".format(sys=current_sys)) + os.environ.setdefault("SERVICE_VARIANT", "{sys}".format(sys=current_sys)) os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{sys}.envs.static_collector".format(sys=current_sys)) application = get_wsgi_application() # pylint: disable=invalid-name @@ -845,12 +849,11 @@ def update_assets(args): if hasattr(django_settings, 'STATIC_COLLECTOR_ROOT'): STATIC_COLLECTOR_ROOT = django_settings.STATIC_COLLECTOR_ROOT else: - STATIC_COLLECTOR_ROOT= get_static_collector_root() + STATIC_COLLECTOR_ROOT = get_static_collector_root() if not os.path.isdir(STATIC_COLLECTOR_ROOT): os.mkdir(STATIC_COLLECTOR_ROOT) - print('\t\tDirectory "STATIC_COLLECTOR_ROOT" has been created to store ' - ' static files.') + print('\t\tDirectory "STATIC_COLLECTOR_ROOT" has been created to store static files.') process_xmodule_assets() process_npm_assets()