From 39380f2d2226f0d89fa9d2a5f2fc53aa4047522f Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 2 Jan 2014 14:27:52 -0500 Subject: [PATCH] Very Minor tweaks to the LMS and CMS startup. I was going to do something in the startup code, then changed my mind, but didn't want to just discard these changes. --- cms/startup.py | 2 -- common/lib/django_startup.py | 11 +++++++++-- lms/startup.py | 6 ++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/cms/startup.py b/cms/startup.py index 111cb9f96a..f152dfd6df 100644 --- a/cms/startup.py +++ b/cms/startup.py @@ -1,7 +1,6 @@ """ Module with code executed during Studio startup """ -import logging from django.conf import settings # Force settings to run so that the python path is modified @@ -9,7 +8,6 @@ settings.INSTALLED_APPS # pylint: disable=W0104 from django_startup import autostartup -log = logging.getLogger(__name__) # TODO: Remove this code once Studio/CMS runs via wsgi in all environments INITIALIZED = False diff --git a/common/lib/django_startup.py b/common/lib/django_startup.py index 1432ea073f..1980420e0d 100644 --- a/common/lib/django_startup.py +++ b/common/lib/django_startup.py @@ -1,3 +1,7 @@ +""" +Automatic execution of startup modules in Django apps. +""" + from importlib import import_module from django.conf import settings @@ -6,9 +10,12 @@ def autostartup(): Execute app.startup:run() for all installed django apps """ for app in settings.INSTALLED_APPS: + # See if there's a startup module in each app. try: mod = import_module(app + '.startup') - if hasattr(mod, 'run'): - mod.run() except ImportError: continue + + # If the module has a run method, run it. + if hasattr(mod, 'run'): + mod.run() diff --git a/lms/startup.py b/lms/startup.py index ead831600d..d6034aa443 100644 --- a/lms/startup.py +++ b/lms/startup.py @@ -1,7 +1,6 @@ """ Module for code that should run during LMS startup """ -import logging from django.conf import settings @@ -11,7 +10,6 @@ settings.INSTALLED_APPS # pylint: disable=W0104 from django_startup import autostartup from xmodule.modulestore.django import modulestore -log = logging.getLogger(__name__) def run(): """ @@ -19,8 +17,8 @@ def run(): """ autostartup() - # Trigger a forced initialization of our modulestores since this can take a while to complete - # and we want this done before HTTP requests are accepted. + # Trigger a forced initialization of our modulestores since this can take a + # while to complete and we want this done before HTTP requests are accepted. if settings.INIT_MODULESTORE_ON_STARTUP: for store_name in settings.MODULESTORE: modulestore(store_name)