diff --git a/lms/djangoapps/dashboard/management/commands/git_add_course.py b/lms/djangoapps/dashboard/management/commands/git_add_course.py index f588920e303d..7da8228922b1 100644 --- a/lms/djangoapps/dashboard/management/commands/git_add_course.py +++ b/lms/djangoapps/dashboard/management/commands/git_add_course.py @@ -40,9 +40,8 @@ def add_repo(repo, rdir_in): # Allow overrides if hasattr(settings, 'MONGODB_LOG'): for config_item in ['host', 'user', 'password', 'db', ]: - if hasattr(settings.MONGODB_LOG, config_item): - mongo_db[config_item] = settings.MONGODB_LOG.get( - config_item, mongo_db[config_item]) + mongo_db[config_item] = settings.MONGODB_LOG.get( + config_item, mongo_db[config_item]) if not os.path.isdir(GIT_REPO_DIR): log.critical(_("Path {0} doesn't exist, please create it, " @@ -119,8 +118,8 @@ def add_repo(repo, rdir_in): except CommandError: log.exception(_('Unable to run import command.')) return -1 - except NotImplementedError, ex: - log.critical(_('The underlying module store does not support import.')) + except NotImplementedError: + log.exception(_('The underlying module store does not support import.')) return -1 ret_import = output.getvalue() @@ -148,7 +147,7 @@ def add_repo(repo, rdir_in): if os.path.exists(cdir) and not os.path.islink(cdir): log.debug(_(' -> exists, but is not symlink')) - log.debug(subprocess.check_output(['ls', 'l', ], + log.debug(subprocess.check_output(['ls', '-l', ], cwd=os.path.abspath(cdir))) try: os.rmdir(os.path.abspath(cdir)) @@ -165,9 +164,7 @@ def add_repo(repo, rdir_in): cwd=os.path.abspath(cdir))) # store import-command-run output in mongo - mongouri = 'mongodb://{0}:{1}@{2}/{3}'.format( - mongo_db['user'], mongo_db['password'], - mongo_db['host'], mongo_db['db']) + mongouri = 'mongodb://{user}:{password}@{host}/{db}'.format(**mongo_db) try: if mongo_db['user'] and mongo_db['password']: diff --git a/lms/djangoapps/dashboard/sysadmin.py b/lms/djangoapps/dashboard/sysadmin.py index 042ac4649c00..d46b9f894dc8 100644 --- a/lms/djangoapps/dashboard/sysadmin.py +++ b/lms/djangoapps/dashboard/sysadmin.py @@ -644,13 +644,10 @@ def get(self, request, *args, **kwargs): # Allow overrides if hasattr(settings, 'MONGODB_LOG'): for config_item in ['host', 'user', 'password', 'db', ]: - if hasattr(settings.MONGODB_LOG, config_item): - mongo_db[config_item] = settings.MONGODB_LOG.get( - config_item, mongo_db[config_item]) + mongo_db[config_item] = settings.MONGODB_LOG.get( + config_item, mongo_db[config_item]) - mongouri = 'mongodb://{0}:{1}@{2}/{3}'.format( - mongo_db['user'], mongo_db['password'], - mongo_db['host'], mongo_db['db']) + mongouri = 'mongodb://{user}:{password}@{host}/{db}'.format(**mongo_db) error_msg = '' @@ -659,10 +656,9 @@ def get(self, request, *args, **kwargs): mdb = mongoengine.connect(mongo_db['db'], host=mongouri) else: mdb = mongoengine.connect(mongo_db['db'], host=mongo_db['host']) - except mongoengine.connection.ConnectionError, ex: - logging.critical(_('Unable to connect to mongodb to save log, ' - 'please check MONGODB_LOG settings. ' - 'error: {0}').format(str(ex))) + except mongoengine.connection.ConnectionError: + logging.exception(_('Unable to connect to mongodb to save log, ' + 'please check MONGODB_LOG settings.')) if course_id is None: # Require staff if not going to specific course diff --git a/lms/envs/aws.py b/lms/envs/aws.py index 0c777d1cda9a..4489403c3138 100644 --- a/lms/envs/aws.py +++ b/lms/envs/aws.py @@ -293,7 +293,7 @@ MODULESTORE = AUTH_TOKENS.get('MODULESTORE', MODULESTORE) CONTENTSTORE = AUTH_TOKENS.get('CONTENTSTORE', CONTENTSTORE) DOC_STORE_CONFIG = AUTH_TOKENS.get('DOC_STORE_CONFIG',DOC_STORE_CONFIG) -MONGODB_LOG = AUTH_TOKENS.get('MONGODB_LOG') +MONGODB_LOG = AUTH_TOKENS.get('MONGODB_LOG', {}) OPEN_ENDED_GRADING_INTERFACE = AUTH_TOKENS.get('OPEN_ENDED_GRADING_INTERFACE', OPEN_ENDED_GRADING_INTERFACE)