Cannot run flake8 because django settings are not configured

Bug #1191748 reported by Akihiro Motoki
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Fix Released
Low
Kieran Spear

Bug Description

After commit cea720e7937775 (Sort imports alphabetically), flake8 outputs the following messages below.
It happens with Django 1.5 series.

Even when the following errors are output, flake8 seems to be done as expected.
flake8 fails as expected when I enabled some checks currently ignored in tox.ini.
Thus it is not critical but it makes it harder to check the flake8 warnings.

Traceback (most recent call last):
  File "/opt/stack/horizon/.tox/pep8/local/lib/python2.7/site-packages/hacking/core.py", line 279, in is_module_for_sure
    __import__(mod)
  File "/opt/stack/horizon/.tox/pep8/local/lib/python2.7/site-packages/horizon/tabs/__init__.py", line 17, in <module>
    from horizon.tabs.base import Tab
  File "/opt/stack/horizon/.tox/pep8/local/lib/python2.7/site-packages/horizon/tabs/base.py", line 23, in <module>
    from horizon import exceptions
  File "/opt/stack/horizon/.tox/pep8/local/lib/python2.7/site-packages/horizon/exceptions.py", line 198, in <module>
    UNAUTHORIZED = tuple(HORIZON_CONFIG['exceptions']['unauthorized'])
  File "/opt/stack/horizon/.tox/pep8/local/lib/python2.7/site-packages/horizon/conf/__init__.py", line 32, in __getitem__
    self._setup(name)
  File "/opt/stack/horizon/.tox/pep8/local/lib/python2.7/site-packages/horizon/conf/__init__.py", line 10, in _setup
    from horizon.conf.default import HORIZON_CONFIG as DEFAULT_CONFIG
  File "/opt/stack/horizon/.tox/pep8/local/lib/python2.7/site-packages/horizon/conf/default.py", line 13, in <module>
    'user_home': settings.LOGIN_REDIRECT_URL,
  File "/opt/stack/horizon/.tox/pep8/local/lib/python2.7/site-packages/django/conf/__init__.py", line 53, in __getattr__
    self._setup(name)
  File "/opt/stack/horizon/.tox/pep8/local/lib/python2.7/site-packages/django/conf/__init__.py", line 46, in _setup
    % (desc, ENVIRONMENT_VARIABLE))
ImproperlyConfigured: Requested setting LOGIN_REDIRECT_URL, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

David Lyle (david-lyle)
Changed in horizon:
status: New → Confirmed
Kieran Spear (kspear)
Changed in horizon:
assignee: nobody → Kieran Spear (kspear)
importance: Undecided → Low
milestone: none → havana-2
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to horizon (master)

Fix proposed to branch: master
Review: https://review.openstack.org/33625

Changed in horizon:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to horizon (master)

Reviewed: https://review.openstack.org/33625
Committed: http://github.com/openstack/horizon/commit/86a3d3d3bb316fbe78edeb37e8df81f9db3d3bbe
Submitter: Jenkins
Branch: master

commit 86a3d3d3bb316fbe78edeb37e8df81f9db3d3bbe
Author: Kieran Spear <email address hidden>
Date: Wed Jun 19 19:50:27 2013 +1000

    Ensure flake8 runs with a valid settings file

    The H301 check sometimes imports a file when trying to tell whether it
    is a module. Ensure we run flake8 in a valid environment to avoid
    any side-effects from this.

    Fixes bug #1191748.

    Change-Id: I35fdefcd8f4c465a89f884299a0a9f4a4c79a6f6

Changed in horizon:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in horizon:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in horizon:
milestone: havana-2 → 2013.2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.