Use the python real executable

Use the real python executable as shebang
Use exec instead of execfile if using python 3

Change-Id: I8acea40851c7e9dc248751be967859b2b9430af7
Closes-Bug: #1836580
This commit is contained in:
Yves-Gwenael Bourhis 2019-07-15 15:49:43 +02:00
parent 350efbe4f2
commit 66144165ff
4 changed files with 30 additions and 7 deletions

View File

@ -2,7 +2,7 @@
[MASTER] [MASTER]
# Add <file or directory> to the black list. It should be a base name, not a # Add <file or directory> to the black list. It should be a base name, not a
# path. You may set this option multiple times. # path. You may set this option multiple times.
ignore=test,tests,tests.py,local_settings.py ignore=test,tests,tests.py,local_settings.py,horizon_wsgi.py
[Messages Control] [Messages Control]
disable= disable=

View File

@ -1,11 +1,31 @@
#!/usr/bin/env python #!{{ PYTHON_EXEC }}
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
{% if ACTIVATE_THIS %}
activate_this = '{{ ACTIVATE_THIS }}'
{% if PY2 %}
execfile(activate_this, dict(__file__=activate_this))
{% elif PY3 %}
exec(
compile(open(activate_this, "rb").read(), activate_this, 'exec'),
dict(__file__=activate_this)
)
{% endif %}
# We import now instead of at the top of the module to use the virtual env
{% endif %}
import os import os
import sys import sys
{% if ACTIVATE_THIS %}
activate_this = '{{ ACTIVATE_THIS }}'
execfile(activate_this, dict(__file__=activate_this))
{% endif %}
sys.path.insert(0, '{{ PROJECT_ROOT }}') sys.path.insert(0, '{{ PROJECT_ROOT }}')
os.environ['DJANGO_SETTINGS_MODULE'] = '{{ DJANGO_SETTINGS_MODULE }}' os.environ['DJANGO_SETTINGS_MODULE'] = '{{ DJANGO_SETTINGS_MODULE }}'

View File

@ -78,6 +78,9 @@ context = template.Context({
'SSLKEY': '/etc/pki/tls/private/ca.key', 'SSLKEY': '/etc/pki/tls/private/ca.key',
'CACERT': None, 'CACERT': None,
'PROCESSES': multiprocessing.cpu_count() + 1, 'PROCESSES': multiprocessing.cpu_count() + 1,
'PY2': six.PY2,
'PY3': six.PY3,
'PYTHON_EXEC': sys.executable,
}) })
context['PROJECT_ROOT'] = os.path.dirname(context['PROJECT_PATH']) context['PROJECT_ROOT'] = os.path.dirname(context['PROJECT_PATH'])

View File

@ -177,7 +177,7 @@ commands = bandit-baseline -r horizon openstack_auth openstack_dashboard -n5 -x
[flake8] [flake8]
filename = *.py,django.wsgi filename = *.py,django.wsgi
exclude = .git,.tox,dist,*lib/python*,*egg,build,panel_template,dash_template,local_settings.py,*/local/*,*/test/test_plugins/*,.ropeproject,node_modules,openstack_dashboard/enabled/* exclude = .git,.tox,dist,*lib/python*,*egg,build,panel_template,dash_template,local_settings.py,*/local/*,*/test/test_plugins/*,.ropeproject,node_modules,openstack_dashboard/enabled/*,horizon_wsgi.py
# W504 line break after binary operator # W504 line break after binary operator
# (W503 and W504 are incompatible and we need to choose one of them. # (W503 and W504 are incompatible and we need to choose one of them.
# Existing codes follows W503, so we disable W504.) # Existing codes follows W503, so we disable W504.)