From f441a262cdd6a654dffa53f438f3a33b20341a7f Mon Sep 17 00:00:00 2001 From: msingh Date: Tue, 11 Jun 2019 15:20:37 -0400 Subject: [PATCH 1/3] INCR-482: ran python modernization and isort --- lms/envs/bok_choy.py | 12 ++++++++---- lms/envs/devstack.py | 14 +++++++++----- lms/envs/devstack_optimized.py | 2 ++ lms/envs/devstack_with_worker.py | 2 ++ lms/envs/static.py | 5 ++++- 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/lms/envs/bok_choy.py b/lms/envs/bok_choy.py index 1d19a45624..ae61591741 100644 --- a/lms/envs/bok_choy.py +++ b/lms/envs/bok_choy.py @@ -11,13 +11,20 @@ support both generating static assets to a directory and also serving static from the same directory. """ +from __future__ import absolute_import + +# Silence noisy logs +import logging import os -from path import Path as path from tempfile import mkdtemp from django.utils.translation import ugettext_lazy +from path import Path as path + from openedx.core.release import RELEASE_LINE +from .production import * # pylint: disable=wildcard-import, unused-wildcard-import, wrong-import-position + CONFIG_ROOT = path(__file__).abspath().dirname() TEST_ROOT = CONFIG_ROOT.dirname().dirname() / "test_root" @@ -33,7 +40,6 @@ os.environ['LMS_CFG'] = str.format("{config_root}/{service_variant}.yml", config_root=os.environ['CONFIG_ROOT'], service_variant=os.environ['SERVICE_VARIANT']) -from .production import * # pylint: disable=wildcard-import, unused-wildcard-import, wrong-import-position ######################### Testing overrides #################################### @@ -123,8 +129,6 @@ EDXNOTES_READ_TIMEOUT = 10 # time in seconds NOTES_DISABLED_TABS = [] -# Silence noisy logs -import logging LOG_OVERRIDES = [ ('track.middleware', logging.CRITICAL), ('edxmako.shortcuts', logging.ERROR), diff --git a/lms/envs/devstack.py b/lms/envs/devstack.py index fdad39946d..64225c3898 100644 --- a/lms/envs/devstack.py +++ b/lms/envs/devstack.py @@ -1,10 +1,19 @@ """ Specific overrides to the base prod settings to make development easier. """ +from __future__ import absolute_import + +# Silence noisy logs +import logging from os.path import abspath, dirname, join from corsheaders.defaults import default_headers as corsheaders_default_headers +# pylint: enable=unicode-format-string +##################################################################### +from openedx.core.djangoapps.plugins import constants as plugin_constants +from openedx.core.djangoapps.plugins import plugin_settings + from .production import * # pylint: disable=wildcard-import, unused-wildcard-import # Don't use S3 in devstack, fall back to filesystem @@ -31,8 +40,6 @@ IDA_LOGOUT_URI_LIST = [ ################################ LOGGERS ###################################### -# Silence noisy logs -import logging LOG_OVERRIDES = [ ('track.contexts', logging.CRITICAL), ('track.middleware', logging.CRITICAL), @@ -260,9 +267,6 @@ JWT_AUTH.update({ 'y5ZLcTUomo4rZLjghVpq6KZxfS6I1Vz79ZsMVUWEdXOYePCKKsrQG20ogQEkmTf9FT_SouC6jPcHLXw"}]}' ), }) -# pylint: enable=unicode-format-string -##################################################################### -from openedx.core.djangoapps.plugins import plugin_settings, constants as plugin_constants plugin_settings.add_plugins(__name__, plugin_constants.ProjectType.LMS, plugin_constants.SettingsType.DEVSTACK) diff --git a/lms/envs/devstack_optimized.py b/lms/envs/devstack_optimized.py index c13f6320bd..4070c771dc 100644 --- a/lms/envs/devstack_optimized.py +++ b/lms/envs/devstack_optimized.py @@ -18,6 +18,8 @@ as they are for non-optimized devstack. Instead, update_assets must be invoked each time that changes have been made. """ +from __future__ import absolute_import + import os ########################## Devstack settings ################################### diff --git a/lms/envs/devstack_with_worker.py b/lms/envs/devstack_with_worker.py index 0f4b610054..6516c1597b 100644 --- a/lms/envs/devstack_with_worker.py +++ b/lms/envs/devstack_with_worker.py @@ -11,6 +11,8 @@ In two separate processes on devstack: ./manage.py lms celery worker --settings=devstack_with_worker """ +from __future__ import absolute_import + import os # We intentionally define lots of variables that aren't used, and diff --git a/lms/envs/static.py b/lms/envs/static.py index 1954f73504..3e43371dca 100644 --- a/lms/envs/static.py +++ b/lms/envs/static.py @@ -12,10 +12,13 @@ sessions. Assumes structure: # want to import all variables from base settings files # pylint: disable=wildcard-import, unused-wildcard-import -from .common import * +from __future__ import absolute_import + from openedx.core.lib.derived import derive_settings from openedx.core.lib.logsettings import get_logger_config +from .common import * + STATIC_GRAB = True LOGGING = get_logger_config(ENV_ROOT / "log", From 7e26fa38231de2074a125fb3aabbd97d890d50bf Mon Sep 17 00:00:00 2001 From: msingh Date: Wed, 12 Jun 2019 10:42:48 -0400 Subject: [PATCH 2/3] Fixing quility test --- lms/envs/bok_choy.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lms/envs/bok_choy.py b/lms/envs/bok_choy.py index ae61591741..ebb5f544d7 100644 --- a/lms/envs/bok_choy.py +++ b/lms/envs/bok_choy.py @@ -39,9 +39,6 @@ os.environ['CONFIG_ROOT'] = CONFIG_ROOT os.environ['LMS_CFG'] = str.format("{config_root}/{service_variant}.yml", config_root=os.environ['CONFIG_ROOT'], service_variant=os.environ['SERVICE_VARIANT']) - - - ######################### Testing overrides #################################### # Redirect to the test_root folder within the repo @@ -122,11 +119,9 @@ XQUEUE_INTERFACE['url'] = 'http://localhost:8040' EDXNOTES_PUBLIC_API = 'http://localhost:8042/api/v1' EDXNOTES_INTERNAL_API = 'http://localhost:8042/api/v1' - EDXNOTES_CONNECT_TIMEOUT = 10 # time in seconds EDXNOTES_READ_TIMEOUT = 10 # time in seconds - NOTES_DISABLED_TABS = [] LOG_OVERRIDES = [ From 215dde1ecadb6de5dbeda38752c52352c983e53f Mon Sep 17 00:00:00 2001 From: msingh Date: Wed, 12 Jun 2019 10:55:32 -0400 Subject: [PATCH 3/3] Fixing error introduced by formatter --- lms/envs/bok_choy.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lms/envs/bok_choy.py b/lms/envs/bok_choy.py index ebb5f544d7..a0f18b6105 100644 --- a/lms/envs/bok_choy.py +++ b/lms/envs/bok_choy.py @@ -23,8 +23,6 @@ from path import Path as path from openedx.core.release import RELEASE_LINE -from .production import * # pylint: disable=wildcard-import, unused-wildcard-import, wrong-import-position - CONFIG_ROOT = path(__file__).abspath().dirname() TEST_ROOT = CONFIG_ROOT.dirname().dirname() / "test_root" @@ -39,6 +37,9 @@ os.environ['CONFIG_ROOT'] = CONFIG_ROOT os.environ['LMS_CFG'] = str.format("{config_root}/{service_variant}.yml", config_root=os.environ['CONFIG_ROOT'], service_variant=os.environ['SERVICE_VARIANT']) +from .production import * # pylint: disable=wildcard-import, unused-wildcard-import, wrong-import-position + + ######################### Testing overrides #################################### # Redirect to the test_root folder within the repo